Skip to content

Commit

Permalink
fix(video): add num_copies to write_video_event (#732)
Browse files Browse the repository at this point in the history
  • Loading branch information
abrichr authored Jun 9, 2024
1 parent 094984a commit ca04b6d
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions openadapt/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ def write_video_event(
video_stream: av.stream.Stream,
video_start_timestamp: float,
last_pts: int = 0,
num_copies: int = 2,
**kwargs: dict,
) -> dict[str, Any]:
"""Write a screen event to the video file and update the performance queue.
Expand All @@ -456,22 +457,28 @@ def write_video_event(
video_start_timestamp (float): The base timestamp from which the video
recording started.
last_pts: The last presentation timestamp.
num_copies: The number of times to write the frame.
Returns:
dict containing state.
"""
screenshot_image = event.data
screenshot_timestamp = event.timestamp
force_key_frame = last_pts == 0
last_pts = video.write_video_frame(
video_container,
video_stream,
screenshot_image,
screenshot_timestamp,
video_start_timestamp,
last_pts,
force_key_frame,
)
# ensure that the first frame is available (otherwise occasionally it is not)
# TODO: why isn't force_key_frame sufficient?
if last_pts != 0:
num_copies = 1
for _ in range(num_copies):
last_pts = video.write_video_frame(
video_container,
video_stream,
screenshot_image,
screenshot_timestamp,
video_start_timestamp,
last_pts,
force_key_frame,
)
perf_q.put((f"{event.type}(video)", event.timestamp, utils.get_timestamp()))
return {
**kwargs,
Expand Down

0 comments on commit ca04b6d

Please sign in to comment.