mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 07:13:02 +04:00
4c024c35fbc7f0610501e087a9ef20c336a75e2b
FIX: CvCapture_FFMPEG::setProperty(CAP_PROP_POS_*) followed by getProperty #27523 Partially fixes #23088 and #23472. This PR fixes `get(CAP_PROP_POS_MSEC)` calls after a `set(CAP_PROP_POS_*)` without calling `read` first. Since `seek` calls `grabFrame` which already sets `picture_pts`, manually setting `picture_pts` anywhere else in the call stack should not be necessary (except for the special case of seeking to frame 0). Minimal example from #23088 ```cpp for(int i = 0; i < 3; i++) cap.read(img); printf("at: %f frames, %f msec\n", cap.get(CAP_PROP_POS_FRAMES), cap.get(CAP_PROP_POS_MSEC)); cap.set(CAP_PROP_POS_FRAMES, 3); printf("at: %f frames, %f msec\n", cap.get(CAP_PROP_POS_FRAMES), cap.get(CAP_PROP_POS_MSEC)); ``` Current ```txt at: 3.000000 frames, 80.000000 msec at: 3.000000 frames, 0.234375 msec ``` PR ```txt at: 3.000000 frames, 80.000000 msec at: 3.000000 frames, 80.000000 msec ``` It similarly helps with `CAP_PROP_POS_MSEC`: Current ```txt at: 3.000000 frames, 80.000000 msec at: 2.000000 frames, 6.250000 msec ``` PR ```txt at: 3.000000 frames, 80.000000 msec at: 2.000000 frames, 40.000000 msec ``` Note the seek operation is still inconsistent between the `CAP_PROP_POS_*` options as mentioned by #23088, and VFR video seeking has issues discussed in #9053. For fixed-frame rate video, we could change 0.5 to 1 in `void CvCapture_FFMPEG::seek(double sec);` to align `CAP_PROP_POS_MSEC` with `CAP_PROP_POS_FRAMES`, but `CAP_POS_AVI_RATIO` and VFR video would still be broken. ### 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
OpenCV: Open Source Computer Vision Library
Resources
- Homepage: https://opencv.org
- Courses: https://opencv.org/courses
- Docs: https://docs.opencv.org/4.x/
- Q&A forum: https://forum.opencv.org
- previous forum (read only): http://answers.opencv.org
- Issue tracking: https://github.com/opencv/opencv/issues
- Additional OpenCV functionality: https://github.com/opencv/opencv_contrib
- Donate to OpenCV: https://opencv.org/support/
Contributing
Please read the contribution guidelines before starting work on a pull request.
Summary of the guidelines:
- One pull request per issue;
- Choose the right base branch;
- Include tests and documentation;
- Clean up "oops" commits before submitting;
- Follow the coding style guide.
Additional Resources
- Submit your OpenCV-based project for inclusion in Community Friday on opencv.org
- Subscribe to the OpenCV YouTube Channel featuring OpenCV Live, an hour-long streaming show
- Follow OpenCV on LinkedIn for daily posts showing the state-of-the-art in computer vision & AI
- Apply to be an OpenCV Volunteer to help organize events and online campaigns as well as amplify them
- Follow OpenCV on Mastodon in the Fediverse
- Follow OpenCV on Twitter
- OpenCV.ai: Computer Vision and AI development services from the OpenCV team.
Description
Languages
C++
87.6%
C
3.1%
Python
2.9%
CMake
2%
Java
1.5%
Other
2.7%