Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix cudacodec::VideoWriter #3360

Merged
merged 8 commits into from Oct 28, 2022
Merged

Fix cudacodec::VideoWriter #3360

merged 8 commits into from Oct 28, 2022

Conversation

cudawarped
Copy link
Contributor

@cudawarped cudawarped commented Oct 9, 2022

cudacodec::VideoWriter has been broken for a while (since hevc encoding support was added in 2015).

This PR adds raw video wrting (.h264 and .hevc) support back to cudacodec::VideoWriter. Additionaly the modules for video decoding (NVCUVID) and/or encoding (NVCUVENC) can now be included seperately using combinations of the below flags

-DWITH_NVCUVID=ON -DWITH_NVCUVENC=ON

The functions within NvEncoder.cpp and NvEncoderCuda.cpp are taken from Nvidia's Video Codec SDK.

Dependant on opencv/opencv#22615

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

modules/cudacodec/CMakeLists.txt Outdated Show resolved Hide resolved
modules/cudacodec/CMakeLists.txt Show resolved Hide resolved
@asmorkalov
Copy link
Contributor

The new branch with encoder produces a lot of warnings during build. Unfortunately we do not have CI build with CUDA right now. My build log (Ubuntu 18.04, CUDA 10.2):

/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp: In function ‘cv::cudacodec::ENC_BUFFER_FORMAT cv::cudacodec::NvSurfaceFormat(cv::cudacodec::COLOR_FORMAT_CV)’:
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:136:19: warning: no previous declaration for ‘cv::cudacodec::ENC_BUFFER_FORMAT cv::cudacodec::NvSurfaceFormat(cv::cudacodec::COLOR_FORMAT_CV)’ [-Wmissing-declarations]
 ENC_BUFFER_FORMAT NvSurfaceFormat(const COLOR_FORMAT_CV format) {
                   ^~~~~~~~~~~~~~~
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp: In function ‘int cv::cudacodec::NChannels(cv::cudacodec::COLOR_FORMAT_CV)’:
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:147:5: warning: no previous declaration for ‘int cv::cudacodec::NChannels(cv::cudacodec::COLOR_FORMAT_CV)’ [-Wmissing-declarations]
 int NChannels(const COLOR_FORMAT_CV format) {
     ^~~~~~~~~
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp: In function ‘int cv::cudacodec::NChannels(cv::cudacodec::ENC_BUFFER_FORMAT)’:
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:158:5: warning: no previous declaration for ‘int cv::cudacodec::NChannels(cv::cudacodec::ENC_BUFFER_FORMAT)’ [-Wmissing-declarations]
 int NChannels(const ENC_BUFFER_FORMAT format) {
     ^~~~~~~~~
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp: In function ‘GUID cv::cudacodec::CodecGuid(cv::cudacodec::VideoWriterCodec)’:
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:208:6: warning: no previous declaration for ‘GUID cv::cudacodec::CodecGuid(cv::cudacodec::VideoWriterCodec)’ [-Wmissing-declarations]
 GUID CodecGuid(const VideoWriterCodec codec) {
      ^~~~~~~~~
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp: In function ‘void cv::cudacodec::FrameRate(double, uint32_t&, uint32_t&)’:
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:243:6: warning: no previous declaration for ‘void cv::cudacodec::FrameRate(double, uint32_t&, uint32_t&)’ [-Wmissing-declarations]
 void FrameRate(const double fps, uint32_t& frameRateNum, uint32_t& frameRateDen) {
      ^~~~~~~~~
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp: In function ‘GUID cv::cudacodec::EncodingProfileGuid(cv::cudacodec::ENC_PROFILE)’:
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:255:6: warning: no previous declaration for ‘GUID cv::cudacodec::EncodingProfileGuid(cv::cudacodec::ENC_PROFILE)’ [-Wmissing-declarations]
 GUID EncodingProfileGuid(const ENC_PROFILE encodingProfile) {
      ^~~~~~~~~~~~~~~~~~~
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp: In function ‘GUID cv::cudacodec::EncodingPresetGuid(cv::cudacodec::ENC_PRESET)’:
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:275:6: warning: no previous declaration for ‘GUID cv::cudacodec::EncodingPresetGuid(cv::cudacodec::ENC_PRESET)’ [-Wmissing-declarations]
 GUID EncodingPresetGuid(const ENC_PRESET nvPreset) {
      ^~~~~~~~~~~~~~~~~~
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp: In function ‘bool cv::cudacodec::Equal(const GUID&, const GUID&)’:
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:291:6: warning: no previous declaration for ‘bool cv::cudacodec::Equal(const GUID&, const GUID&)’ [-Wmissing-declarations]
 bool Equal(const GUID& g1, const GUID& g2) {
      ^~~~~
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp: In member function ‘void cv::cudacodec::VideoWriterImpl::InitializeEncoder(cv::cudacodec::NvEncoderCuda*, GUID, double)’:
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::encodeGUID’ [-Wmissing-field-initializers]
     NV_ENC_INITIALIZE_PARAMS initializeParams = { NV_ENC_INITIALIZE_PARAMS_VER };
                                                                                ^
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::presetGUID’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::encodeWidth’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::encodeHeight’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::darWidth’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::darHeight’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::frameRateNum’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::frameRateDen’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::enablePTD’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::reportSliceOffsets’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::enableSubFrameWrite’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::enableExternalMEHints’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::enableMEOnlyMode’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::enableWeightedPrediction’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::reservedBitFields’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::privDataSize’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::privData’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::encodeConfig’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::maxEncodeWidth’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::maxEncodeHeight’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::tuningInfo’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::bufferFormat’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::reserved’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:299:80: warning: missing initializer for member ‘_NV_ENC_INITIALIZE_PARAMS::reserved2’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:300:54: warning: missing initializer for member ‘_NV_ENC_CONFIG::profileGUID’ [-Wmissing-field-initializers]
     NV_ENC_CONFIG encodeConfig = { NV_ENC_CONFIG_VER };
                                                      ^
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:300:54: warning: missing initializer for member ‘_NV_ENC_CONFIG::gopLength’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:300:54: warning: missing initializer for member ‘_NV_ENC_CONFIG::frameIntervalP’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:300:54: warning: missing initializer for member ‘_NV_ENC_CONFIG::monoChromeEncoding’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:300:54: warning: missing initializer for member ‘_NV_ENC_CONFIG::frameFieldMode’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:300:54: warning: missing initializer for member ‘_NV_ENC_CONFIG::mvPrecision’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:300:54: warning: missing initializer for member ‘_NV_ENC_CONFIG::rcParams’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:300:54: warning: missing initializer for member ‘_NV_ENC_CONFIG::encodeCodecConfig’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:300:54: warning: missing initializer for member ‘_NV_ENC_CONFIG::reserved’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:300:54: warning: missing initializer for member ‘_NV_ENC_CONFIG::reserved2’ [-Wmissing-field-initializers]
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp: In member function ‘void cv::cudacodec::VideoWriterImpl::CopyToNvSurface(cv::InputArray)’:
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:335:16: warning: unused variable ‘pDst’ [-Wunused-variable]
         Npp8u* pDst[3] = { dst, &dst[encoderInputFrame->pitch * pEnc->GetEncodeHeight()], &dst[encoderInputFrame->pitch * pEnc->GetEncodeHeight() * 2] };
                ^~~~
/mnt/projects/Projects/OpenCV/opencv_contrib/modules/cudacodec/src/video_writer.cpp:336:24: warning: unused variable ‘oSizeROI’ [-Wunused-variable]
         const NppiSize oSizeROI = { pEnc->GetEncodeWidth(), pEnc->GetEncodeHeight() };
                        ^~~~~~~~

@cudawarped
Copy link
Contributor Author

Unfortunately we do not have CI build with CUDA right now. My build log (Ubuntu 18.04, CUDA 10.2):

Do you see the same runtime errrors as detailed in #3362 on your local build?

@asmorkalov
Copy link
Contributor

No, I have codec library version and kernel driver version conflict. It's miss configuration on my side and I plan to fix it for testing. Andrey works on CI configuration for CUDA support.

modules/cudacodec/include/opencv2/cudacodec.hpp Outdated Show resolved Hide resolved
Comment on lines 80 to 105
enum COLOR_FORMAT_CV {
UNDEFINED = 0,
BGR = 1, //!< Default OpenCV color format.
RGB = 2,
BGRA = 3,
RGBA = 4,
GRAY = 5
};

enum SurfaceFormat
/** @brief Nvidia Video Codec SDK surface formats.
*/
enum ENC_BUFFER_FORMAT
{
SF_UYVY = 0,
SF_YUY2,
SF_YV12,
SF_NV12,
SF_IYUV,
SF_BGR,
SF_GRAY = SF_BGR
BF_UNDEFINED = 0x00000000, //!< Undefined buffer format.
BF_NV12 = 0x00000001, //!< Semi-Planar YUV [Y plane followed by interleaved UV plane].
BF_YV12 = 0x00000010, //!< Planar YUV [Y plane followed by V and U planes].
BF_IYUV = 0x00000100, //!< Planar YUV [Y plane followed by U and V planes].
BF_YUV444 = 0x00001000, //!< Planar YUV [Y plane followed by U and V planes].
BF_YUV420_10BIT = 0x00010000, //!< 10 bit Semi-Planar YUV [Y plane followed by interleaved UV plane]. Each pixel of size 2 bytes. Most Significant 10 bits contain pixel data.
BF_YUV444_10BIT = 0x00100000, //!< 10 bit Planar YUV444 [Y plane followed by U and V planes]. Each pixel of size 2 bytes. Most Significant 10 bits contain pixel data.
BF_ARGB = 0x01000000, //!< 8 bit Packed A8R8G8B8. This is a word-ordered format where a pixel is represented by a 32-bit word with B in the lowest 8 bits, G in the next 8 bits, R in the 8 bits after that and A in the highest 8 bits.
BF_ARGB10 = 0x02000000, //!< 10 bit Packed A2R10G10B10. This is a word-ordered format where a pixel is represented by a 32-bit word with B in the lowest 10 bits, G in the next 10 bits, R in the 10 bits after that and A in the highest 2 bits.
BF_AYUV = 0x04000000, //!< 8 bit Packed A8Y8U8V8. This is a word-ordered format where a pixel is represented by a 32-bit word with V in the lowest 8 bits, U in the next 8 bits, Y in the 8 bits after that and A in the highest 8 bits.
BF_ABGR = 0x10000000, //!< 8 bit Packed A8B8G8R8. This is a word-ordered format where a pixel is represented by a 32-bit word with R in the lowest 8 bits, G in the next 8 bits, B in the 8 bits after that and A in the highest 8 bits.
BF_ABGR10 = 0x20000000, //!< 10 bit Packed A2B10G10R10. This is a word-ordered format where a pixel is represented by a 32-bit word with R in the lowest 10 bits, G in the next 10 bits, B in the 10 bits after that and A in the highest 2 bits.
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, COLOR_FORMAT_CV and ENC_BUFFER_FORMAT has strong correlation. In case if user define OpenCV style color then particular buffer format should be used. It means, that 2 options are redundant and only OpenCV style format should be presumed as API. Also ARGB10, ABGR10 and other 10 bit options are not achievable with OpenCV and I do not see a reason to expose them as API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to add surface types

  1. for users who are familiar with Nvidia's Video Coding SDK (maybe unecessary) and
  2. because apart from BF_ARGB and BF_BGRA they are not the same format as that produced by cv::cvtColor.

I could add the 8 bit versions to the existing COLOR_FORMAT_CV enum and rename it to COLOR_FORMAT as

enum COLOR_FORMAT {
    UNDEFINED = 0,
    BGR = 1, //!< Default OpenCV color format.
    RGB = 2,
    BGRA = 3,
    RGBA = 4,
    GRAY = 5,

    NV_NV12,
    NV_YV12,
    etc. 
};

which would reduce the number of factory methods while allowing users who have manually created say a YV12 Mat/GpuMat to use the encoder.

Do you see any problem/issues with this approach?

cap = cv.VideoCapture(fname,cv.CAP_FFMPEG)
self.assert_true(cap.isOpened())
ret, blankFrameOut = cap.read()
self.assert_true(ret and blankFrameOut.shape == blankFrameIn.download().shape)
except cv.error as e:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test does not remove the temporary file.


if (writer.empty()) {
frameSz = frame.size();
writer = cv::cudacodec::createVideoWriter(outputFile, frameSz, codec, fps, surfaceFormatNv, stream);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test does not remove temporary files.

@asmorkalov
Copy link
Contributor

@cudawarped Thanks a lot for the contribution! I updated CUDA driver and tests work on Ubuntu 18.04 + CUDA 10.2 and latest video codec sdk. Several thoughts on the PR:

  • As soon as callback is changed there is no much sense to support compatibility with old API. I think it makes sense to reduce factory methods and make callback as a default parameter with nullptr value.
  • I propose to hide surface type from API as it's hardware internals and it correlates 1:1 with OpenCV style color.

@asmorkalov asmorkalov self-assigned this Oct 13, 2022
@cudawarped
Copy link
Contributor Author

cudawarped commented Oct 14, 2022

@asmorkalov

As soon as callback is changed there is no much sense to support compatibility with old API. I think it makes sense to reduce factory methods and make callback as a default parameter with nullptr value.

In

CV_EXPORTS_W Ptr<cudacodec::VideoWriter> createVideoWriter(const String& fileName, const Size frameSize, const CODEC_VW codec = CODEC_VW::H264,
    const double fps = 25.0, const COLOR_FORMAT_VW colorFormat = BGR, const Ptr<EncoderCallback> encoderCallback = 0, const Stream& stream = Stream::Null());

fileName would become redundant if encoderCallback is not null? Is this better than having two extra factory methods? Hiding the surface type remove 4 of the factory methods so if we leave in the encoderCallback there will just be 4 in total.

@asmorkalov
Copy link
Contributor

I still see a lot of .h265 and .hevc files in tmp after test execution.

@cudawarped
Copy link
Contributor Author

Updated, sorry I forgot to add to the accuracy test, updated now.

@asmorkalov
Copy link
Contributor

Thanks a lot for the patch. I reviewed the model API and have couple of ideas:

  • OpenCV uses camel-case naming for classes and types. I propose to rename types like ENC_PARAMS_RC_MODE to EncoderParamsRCMode.
  • _VW stands for VideoWriter. but looks very cryptic in general context of OpenCV. I propose to reuse and extend enumerations that we have in the header bellow. For example there are COLOR_FORMAT_VW vs ColorFormat and CODEC_VW vs Codec.

@cudawarped
Copy link
Contributor Author

Agreed. I have changed ColorForamt::YUV from the original enum to ColorForamt::NV_NV12 to avoid duplication as they refer to the same format.

Unfortunately this will brake any code which currently sets the output color format for cudacodec::VideoReader to ColorFormat::YUV.

*/
void load(const String& configFile);
/** @brief Saves parameters to config file.
/** @brief ColorFormat for the frame returned by VideoReader::nextFrame()/VideoReader::retrieve() or used to initialize a VideoWriter.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BuildBot warning on documentation:

/build/precommit-contrib_docs/4.x/opencv_contrib/modules/cudacodec/include/opencv2/cudacodec.hpp:96: warning: explicit link request to 'retrieve()' could not be resolved

Please do not use slash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants