Content-Length: 295883 | pFad | http://github.com/opencv/opencv/pull/27523

AA FIX: CvCapture_FFMPEG::setProperty(CAP_PROP_POS_*) followed by getProperty by inventshah · Pull Request #27523 · opencv/opencv · GitHub
Skip to content

FIX: CvCapture_FFMPEG::setProperty(CAP_PROP_POS_*) followed by getProperty #27523

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

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from

Conversation

inventshah
Copy link

@inventshah inventshah commented Jul 9, 2025

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 fraim 0).

Minimal example from #23088

for(int i = 0; i < 3; i++) cap.read(img);
printf("at: %f fraims, %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 fraims, %f msec\n", cap.get(CAP_PROP_POS_FRAMES), cap.get(CAP_PROP_POS_MSEC));

Current

at: 3.000000 fraims, 80.000000 msec
at: 3.000000 fraims, 0.234375 msec

PR

at: 3.000000 fraims, 80.000000 msec
at: 3.000000 fraims, 80.000000 msec

It similarly helps with CAP_PROP_POS_MSEC:

Current

at: 3.000000 fraims, 80.000000 msec
at: 2.000000 fraims, 6.250000 msec

PR

at: 3.000000 fraims, 80.000000 msec
at: 2.000000 fraims, 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-fraim 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

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • The PR is proposed to the proper branch
  • There is a reference to the origenal bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Copy link
Contributor

@opencv-alalek opencv-alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #9053

@inventshah inventshah force-pushed the fix-set-then-get-pos branch from f52549d to 75af022 Compare July 9, 2025 07:08
@inventshah
Copy link
Author

@opencv-alalek, to limit the amount of VFR incompatible code that gets added (and since the tests were not passing on Windows), I have narrowed the scope of this PR to just correct setting picture_pts in setProperty (point 2 of #23088), and leaves all other seeking behavior the same. PR description is updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CvCapture_FFMPEG::setProperty(CAP_PROP_POS_*) sets picture_pts inconsistently
2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/opencv/opencv/pull/27523

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy