Skip to content

Commit

Permalink
Manually track frame index
Browse files Browse the repository at this point in the history
  • Loading branch information
domstoppable committed Aug 5, 2024
1 parent 4fa219f commit 1b14e9d
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/pupil_labs/neon_recording/stream/av_stream/base_av_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def __init__(self, container, timestamps):
self.container = container
self.timestamps = timestamps
self.current_frame = None
self.frame_idx = -1

def goto_index(self, frame_idx, frame_generator):
video = self.container.streams.video[0]
Expand All @@ -108,15 +109,9 @@ def goto_index(self, frame_idx, frame_generator):
for _ in range(self.frame_idx, frame_idx):
self.current_frame = next(frame_generator)

return self.current_frame

@property
def frame_idx(self):
if self.current_frame is None:
return -1
self.frame_idx = frame_idx

video = self.container.streams.video[0]
return int(self.current_frame.pts * video.time_base * video.average_rate)
return self.current_frame


class BaseAVStream(StreamSampler):
Expand Down

0 comments on commit 1b14e9d

Please sign in to comment.