Skip to content

Commit

Permalink
tested post frame processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishaan-Datta committed Nov 6, 2024
1 parent afed47e commit 8297eb9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tools/video/mp4-recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def record_zed_to_mp4(output_file="output.mp4", fps=30, duration=10):
# Prepare the runtime parameters
runtime_parameters = sl.RuntimeParameters()

frames = []

# Main loop
frame_count = int(duration * fps)
start_time = time.time()
Expand All @@ -51,8 +53,7 @@ def record_zed_to_mp4(output_file="output.mp4", fps=30, duration=10):
frame = zed_image.get_data()
frame = cv2.cvtColor(frame, cv2.COLOR_RGBA2RGB) # Convert RGBA to RGB

# Write the frame to the video file
video_writer.write(frame)
frames.append(frame)

# Print status update
elapsed_time = i / fps
Expand All @@ -63,14 +64,15 @@ def record_zed_to_mp4(output_file="output.mp4", fps=30, duration=10):
# if cv2.waitKey(1) & 0xFF == ord('q'):
# break

# Calculate the time to wait to maintain the frame rate
time_to_wait = (i + 1) / fps - (time.time() - start_time)
if time_to_wait > 0:
time.sleep(time_to_wait)

else:
print("Frame grab failed")
break

print("finished recording frames, now compiling")

# Write the frame to the video file
for frame in frames:
video_writer.write(frame)

# Release resources
video_writer.release()
Expand Down

0 comments on commit 8297eb9

Please sign in to comment.