Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

cudacodec: VideoWriter fails to compile with Nvidia Video Codec SDK 12.2 #3711

Closed
4 tasks done
cudawarped opened this issue Apr 2, 2024 · 1 comment · Fixed by #3717
Closed
4 tasks done

cudacodec: VideoWriter fails to compile with Nvidia Video Codec SDK 12.2 #3711

cudawarped opened this issue Apr 2, 2024 · 1 comment · Fixed by #3717

Comments

@cudawarped
Copy link
Contributor

cudawarped commented Apr 2, 2024

Nvidia has changed the nvEncodeAPI.h interface in the new Video Codec SDK 12.2 replacing

NV_ENC_CONFIG_HEVC::pixelBitDepthMinus8 - Specifies pixel bit depth minus 8.

with

NV_ENC_CONFIG_HEVC::outputBitDepth - Specifies pixel bit depth of encoded video.
NV_ENC_CONFIG_HEVC::inputBitDepth - Specifies pixel bit depth of video input.

resulting in the following compilation errors when building opencv_cudacodec

D:\repos\opencv\contrib\modules\cudacodec\src\NvEncoder.cpp(119): error C2039: 'pixelBitDepthMinus8': is not a member of '_NV_ENC_CONFIG_HEVC'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.3\include\nvEncodeAPI.h(1820): note: see declaration of '_NV_ENC_CONFIG_HEVC'
D:\repos\opencv\contrib\modules\cudacodec\src\NvEncoder.cpp(174): error C2039: 'pixelBitDepthMinus8': is not a member of '_NV_ENC_CONFIG_HEVC'
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.3\include\nvEncodeAPI.h(1820): note: see declaration of '_NV_ENC_CONFIG_HEVC'

System information (version)
  • OpenCV => 4.9
  • Operating System / Platform => Windows 64 Bit
  • Compiler => Visual Studio 2022
Steps to reproduce

Build opencv_cudacodec against Nvidia Video Codec SDK 12.2

Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc
@vbickov
Copy link

vbickov commented Apr 4, 2024

Just FYI, maybe useful.

According to the latest ncEncodeAPI.h the parameter pixelBitDepthMinus8 has been replaced with two new ones:

`NV_ENC_BIT_DEPTH outputBitDepth; /**< [in]: Specifies pixel bit depth of encoded video. Should be set to NV_ENC_BIT_DEPTH_8 for 8 bit, NV_ENC_BIT_DEPTH_10 for 10 bit.
SW will do the bitdepth conversion internally from inputBitDepth -> outputBitDepth if bit depths differ
Support for 8 bit input to 10 bit encode conversion only*/

NV_ENC_BIT_DEPTH inputBitDepth; /**< [in]: Specifies pixel bit depth of video input. Should be set to NV_ENC_BIT_DEPTH_8 for 8 bit input, NV_ENC_BIT_DEPTH_10 for 10 bit input.*/`

I've modified NvEncoder.cpp:

Line 119:

pIntializeParams->encodeConfig->encodeCodecConfig.hevcConfig.inputBitDepth = pIntializeParams->encodeConfig->encodeCodecConfig.hevcConfig.outputBitDepth = (m_eBufferFormat == NV_ENC_BUFFER_FORMAT_YUV420_10BIT || m_eBufferFormat == NV_ENC_BUFFER_FORMAT_YUV444_10BIT) ? NV_ENC_BIT_DEPTH_10 : NV_ENC_BIT_DEPTH_8;

Line 177 to:

if (yuv10BitFormat && pEncoderParams->encodeConfig->encodeCodecConfig.hevcConfig.outputBitDepth != NV_ENC_BIT_DEPTH_10)

This seems fixed the issue. However, I'm not sure about the inputBitDepth parameter. I'm not even sure what meaning this parameter has for the encoder.

asmorkalov added a commit that referenced this issue Apr 15, 2024
…c_sdk_12_2

cudacodec: fix #3711 (update for Nvidia Video Codec SDK 12.2)
cudawarped added a commit to cudawarped/opencv_contrib that referenced this issue Feb 4, 2025
asmorkalov added a commit that referenced this issue Feb 10, 2025
…rsion_checks

cudacodec: fix VideoWriter version check bug introduced in #3711
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants