Repository navigation
Keep OpenCV position on the last frame at the end of VFR video - #586
Open
sungbin1015 wants to merge 1 commit into
Open
sungbin1015 wants to merge 1 commit into
sungbin1015 wants to merge 1 commit into
Conversation
After the final failed grab(), CAP_PROP_POS_MSEC can report an earlier time than the last frame read, so the last scene ended early on VFR input (Breakthrough#561). Remember the last frame's timecode and report it until the next successful read, seek or reset.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #561
With the OpenCV backend,
positionmoves backwards onceread()hits the end of a VFR video: after the last failedgrab(),CAP_PROP_POS_MSECreports an earlier time than the last frame that was actually read.SceneManagerusesvideo.positionafter the loop as the end of the last scene, so that scene ends early, and if the last cut falls after that point the end comes out before the start, which is the invalid end time in #561. PyAV doesn't do this, and CFR files are fine with both backends.It shows up with
goldeneye-vfr-drop3.mp4from the resources branch:VideoStreamCv2.read()now remembers the timecode of the last frame it read and keeps reporting it after a failed read, until the next successful read,seek()orreset(). Nothing changes while frames are being read.I couldn't test with the DVD from #561, so I'm not marking it as fixed. On a synthetic MPEG-2 MKV with a timestamp gap, the last scene now ends at the same time as with PyAV instead of about 0.65 s early.
Added
test_vfr_position_after_eof_opencv, which fails on main and passes with this change.pytest,ruff check,ruff format --checkandpyrightpass locally; the two moviepy CLI tests that fail here fail the same way on main.