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
videoio: Add raw encoded video stream encapsulation to cv::VideoWriter
with CAP_FFMPEG
#24363
videoio: Add raw encoded video stream encapsulation to cv::VideoWriter
with CAP_FFMPEG
#24363
Conversation
cda7666
to
16c58e5
Compare
@asmorkalov Thanks for running the CI, unfortunately I left in one of my own tests
I've removed the test, so everything should pass now. |
cv::VideoWriter
with CAP_FFMEG
cv::VideoWriter
with CAP_FFMPEG
|
Looks like |
16c58e5
to
b0f4231
Compare
This is the same test which timed out last time, I don't have access to macOS-ARM64 to debug this, should I just disable that test to see if it passes? |
I get strange test failures locally:
Example:
OS: Ubuntu 18.04 with default FFmpeg instance. |
I knew this PR was a bad idea, so it works on FFMpeg 2.8.17 and 4.2.4 but not 3.4.8. I'll take a look. |
b0f4231
to
c03ae53
Compare
@asmorkalov It looks like the problem is not that the keyframe is not marked when the stream is encapsulated but that FFMpeg discards that information when the stream is read back and filtered. In FFMpeg >= 3.1 I've introduced a workaround which fixes the issue on Ubuntu 20.04 with OpencV built against the lattest version of FFMpeg 3.4 (3.4.13) and would appreciate it if you could test it again on your Ubuntu 18.04 instance. |
c03ae53
to
6ebc81e
Compare
@cudawarped Thanks a lot for the effort. I tried Ubuntu 16.04, 18.04, 22.04. The last 2 works great! Ubuntu 16.04 triggers some errors with h264 and h265 codecs in the same way as on Buildbot. I'll try to debug it tomorrow. Error message example:
|
@cudawarped I tuned test parameters a bit to satisfy old FFmpeg versions. Looks like they support not all combinations of codec-container. Please take a look. |
@asmorkalov Nice fix, working on my Ubuntu 20.04 with FFMpeg 2.8.17 and its passing on IOS! I was also thinking to reduce the number of frames in the following to 10 as there is only one key frame so it doesn't make any sense to read all 125. i.e. From
to
Do you want to do that or should I? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
…ream_encapsulation videoio: Add raw encoded video stream muxing to cv::VideoWriter with CAP_FFMPEG opencv#24363 Allow raw encoded video streams (e.g. h264[5]) to be encapsulated by `cv::VideoWriter` to video containers (e.g. mp4/mkv). Operates in a similar way to opencv#15290 where encapsulation is enabled by setting the `VideoWriterProperties::VIDEOWRITER_PROP_RAW_VIDEO` flag when constructing `cv::VideoWriter` e.g. ``` VideoWriter container(fileNameOut, api, fourcc, fps, { width, height }, { VideoWriterProperties::VIDEOWRITER_PROP_RAW_VIDEO, 1 }); ``` and each raw encoded frame is passed as single row of a `CV_8U` `cv::Mat`. The main reason for this PR is to allow `cudacodec::VideoWriter` to output its encoded streams to a suitable container, see opencv/opencv_contrib#3569. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
…ream_encapsulation videoio: Add raw encoded video stream muxing to cv::VideoWriter with CAP_FFMPEG opencv#24363 Allow raw encoded video streams (e.g. h264[5]) to be encapsulated by `cv::VideoWriter` to video containers (e.g. mp4/mkv). Operates in a similar way to opencv#15290 where encapsulation is enabled by setting the `VideoWriterProperties::VIDEOWRITER_PROP_RAW_VIDEO` flag when constructing `cv::VideoWriter` e.g. ``` VideoWriter container(fileNameOut, api, fourcc, fps, { width, height }, { VideoWriterProperties::VIDEOWRITER_PROP_RAW_VIDEO, 1 }); ``` and each raw encoded frame is passed as single row of a `CV_8U` `cv::Mat`. The main reason for this PR is to allow `cudacodec::VideoWriter` to output its encoded streams to a suitable container, see opencv/opencv_contrib#3569. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
Allow raw encoded video streams (e.g. h264[5]) to be encapsulated by
cv::VideoWriter
to video containers (e.g. mp4/mkv).Operates in a similar way to #15290 where encapsulation is enabled by setting the
VideoWriterProperties::VIDEOWRITER_PROP_RAW_VIDEO
flag when constructingcv::VideoWriter
e.g.and each raw encoded frame is passed as single row of a
CV_8U
cv::Mat
.The main reason for this PR is to allow
cudacodec::VideoWriter
to output its encoded streams to a suitable container, see opencv/opencv_contrib#3569.Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.