VideoCapture: remove decoder initialization when demuxing#24012
VideoCapture: remove decoder initialization when demuxing#24012asmorkalov merged 1 commit intoopencv:4.xfrom
VideoCapture: remove decoder initialization when demuxing#24012Conversation
| if(rawMode) | ||
| return true; |
There was a problem hiding this comment.
It breaks some properties like CAP_PROP_FRAME_WIDTH, CAP_PROP_FRAME_HEIGHT, information about camera rotation. Also video_st pointer is not initialized.
There was a problem hiding this comment.
Yes sorry I thought the change would be simple but I was using the the wrong test case from cudacodec where CAP_PROP_FORMAT is set after initialization. I'll push the new changes a bit later after some more testing.
67baadc to
66c9e34
Compare
|
|
|
@asmorkalov can you let me know which version of FFmpeg you are using please? |
|
It's default FFmpeg instance in Ubuntu 18.04: |
|
@asmorkalov I have built OpenCV against the same version of FFmpeg (3.4.13), but on my version of Ubuntu (20.04) all the FFmpeg
caused by which "looks" to be unrelated to my changes, I assumed was down to the version of FFmpeg but it must be something different. Do the tests still fail if you run them in isolation i.e.
and do they still fail on your set up without my changes? I have noticed that seeking, which is not currently tested, won't work at the moment and I have left some debug output in the test. I am addressing both these issues at the moment but it would be good to fix your test failure at the same time. |
66c9e34 to
72cea1b
Compare
|
@asmorkalov Fixed seek functionality but I still can't recreate your errors using the same version of FFmpeg. |
72cea1b to
974151b
Compare
|
@cudawarped Thanks for the patch. All tests passed with the lat commit. |
|
@cudawarped FFmpeg for Windows is not built in CI and updated before release. You have to support the configuration with old version of cap_ffmpeg_impl.hpp and wrap new tests in |
| frame.height = video_st->codecpar->height; | ||
| frame.width = video_st->codecpar->width; | ||
| #endif | ||
| return true; |
There was a problem hiding this comment.
I propose to add get_rotation_angle() too. The encoded stream may contain rotation meta. In this case cuda codec has to handle it too (w and h may be swapped).
There was a problem hiding this comment.
As rotation isn't supported by the Nvidia Video Codec SDK and RAW streams returned by VideoCapture will be encoded without the rotation shouldn't we just return the encoded width and height? This should be automatic as the rotation_angle == 0 in raw mode.
case CAP_PROP_FRAME_WIDTH:
return (double)((rotation_auto && ((rotation_angle%180) != 0)) ? frame.height : frame.width);
case CAP_PROP_FRAME_HEIGHT:
return (double)((rotation_auto && ((rotation_angle%180) != 0)) ? frame.width : frame.height);
… (rawMode == true)
974151b to
e4ad7e3
Compare
|
@opencv-alalek could you take a look too? |
cudacodec::VideoReader: allow frame seek on initialization #3542 Allow seeking of video source on initialization of `cudacodec::VideoReader` when new variable `VideoReaderInitParams::iFirstFrame` != 0. Dependant on opencv/opencv#24012 Fixes #3541. ### 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
As discussed in opencv/opencv_contrib#3488 (comment) decoder initialization when
VideoCaptureis only used for demuxing (CAP_PROP_FORMAT== -1,rawMode == true) is unecessary. Additionally if video sources can be parsed but not decoded,VideoCapturereturns an error on decoder initialization preventing it from being used for demuxing.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.