mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-24 10:16:09 +00:00
fix(PyAV container seek): fixing initial PyAV container seek to be robust againsy codec choice
This commit is contained in:
@@ -152,7 +152,13 @@ def decode_video_frames_pyav(
|
|||||||
# https://pyav.basswood-io.com/docs/stable/api/container.html#av.container.InputContainer.seek
|
# https://pyav.basswood-io.com/docs/stable/api/container.html#av.container.InputContainer.seek
|
||||||
with av.open(video_path) as container:
|
with av.open(video_path) as container:
|
||||||
stream = container.streams.video[0]
|
stream = container.streams.video[0]
|
||||||
container.seek(int(first_ts * av.time_base), backward=True)
|
# Seek to the nearest keyframe at or before `first_ts` with a 1 frame margin
|
||||||
|
container.seek(
|
||||||
|
round(first_ts / stream.time_base) - 1,
|
||||||
|
backward=True,
|
||||||
|
any_frame=False,
|
||||||
|
stream=stream,
|
||||||
|
)
|
||||||
|
|
||||||
for frame in container.decode(stream):
|
for frame in container.decode(stream):
|
||||||
if frame.pts is None:
|
if frame.pts is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user