Search code examples
c++opencvffmpegvideo-processingvideo-capture

Writing a video with H.264 in OpenCV with High profile from a high profile mp4 file


I have High profile mp4 video i am using opencv to overlay some text inside but output.mp4 is writing in simple profile format. is there a way to write it in high profile I am using opencv 3.4.16 latest

Devlopment platform is: Windows C++ VS2019

VideoWriter videocc(destFile, VideoWriter::fourcc('M', 'P', '4', 'V'), fps, cv::Size(width, height));

I have tried X264 , H264 ,AVC1 in fourcc, But not writing in high profile

Is there a way or sample available to generate high profile output video format

please find the following attachment for main profile coded problem

enter image description here


Solution

  • You would need to pass parameters through OpenCV, to ffmpeg and libx264.

    As far as I can tell from official documentation, OpenCV doesn't support that.

    However, the source contains access to the environment variable OPENCV_FFMPEG_WRITER_OPTIONS

    You should be able to pass parameters like you would give them to ffmpeg, except the syntax is a little weird (semicolon between key and value, pipe between pairs).

    Here is some talk of such facilities:

    You should pass avc1 as fourcc. AFAIK that's the fourcc defined by standards. It does not however guarantee that you get libx264, only that you get some encoder for AVC.

    I've opened an issue for this. Documentation issues are always a nice way for newbies to get their feet wet contributing to an open source project.