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

cudacodec::VideoReader::get returns incorect frame index for CAP_PROP_POS_FRAMES #3541

Closed
4 tasks done
cudawarped opened this issue Aug 1, 2023 · 0 comments · Fixed by #3542
Closed
4 tasks done

Comments

@cudawarped
Copy link
Contributor

cudawarped commented Aug 1, 2023

System information (version)
  • OpenCV => 4.8.0:
  • Operating System / Platform => Windows 11
  • Compiler => Visual Studio 2022
Detailed description

Due to the multi-threaded implementation of VideoReader, calling cudacodec::VideoReader::get() with CAP_PROP_POS_FRAMES will return the latest frame which has been input to the parser not the latest decoded frame as a user would expect.

The easiest fix would be to internally store the decoded frame index in VideoReaderImpl and intercept queries for CAP_PROP_POS_FRAMES in VideoReader::get before they are internally passed to VideoCapture.

Steps to reproduce
cv::Ptr<cv::cudacodec::VideoReader> reader = cv::cudacodec::createVideoReader(inputFile, {}, params);
double iFrame  = 0;
reader->get(cv::VideoCaptureProperties::CAP_PROP_POS_FRAMES, iFrame);

iFrame should be zero but it is guaranteed to be greater due to the fact that createVideoReader doesn't return until the decoder is initialized.

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
asmorkalov pushed a commit that referenced this issue Nov 16, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants