InputContainer.seek(backward=True, any_frame=False) overshoots #1982
Unanswered
nikonikolov
asked this question in
1. Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to get a specific frame index from a video as fast as possible. The strategy I follow is what the docs of
InputContainer.seek
suggest - I callInputContainer.seek(backward=True, any_frame=False)
so that I get the closest previous keyframe and then decode forward sequentially to the desired frame. I am using the following codeI am testing this with a video with 5 FPS and keyframes at indices 0, 20, 40, 60. All frames from 0 to 35 work fine, but when I pass
frame_index=36
, the first framecontainer.decode(stream)
returns in the for loop after the call tocontainer.seek
is the keyframe at index 40. If I instead seek withcontainer.seek(int(target_timestamp_sec * av.time_base), backward=True, any_frame=False)
, the error happens at index 19 and the keyframe returned is 20. The video is encoded with x265 andstream.time_base = 1 / 10240
. The frames also have the expected time and pts:Beta Was this translation helpful? Give feedback.
All reactions