Skip to content

Commit

Permalink
fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
yzld2002 committed Sep 6, 2024
1 parent 405f5ac commit c00a3d1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vision_agent/utils/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def play_video(video_base64: str) -> None:
cv2.destroyAllWindows()


def _resize_frame(frame):
def _resize_frame(frame: np.ndarray) -> np.ndarray:
height, width = frame.shape[:2]
new_width = width - (width % 2)
new_height = height - (height % 2)
Expand All @@ -62,7 +62,10 @@ def video_writer(
stream.height = frames[0].shape[0]
stream.pix_fmt = "yuv420p"
for frame in frames:
frame_rgb = _resize_frame(frame[:, :, :3])
# Remove the alpha channel (convert RGBA to RGB)
frame_rgb = frame[:, :, :3]
# Resize the frame to make dimensions divisible by 2
frame_rgb = _resize_frame(frame_rgb)
av_frame = av.VideoFrame.from_ndarray(frame_rgb, format="rgb24")
for packet in stream.encode(av_frame):
container.mux(packet)
Expand Down

0 comments on commit c00a3d1

Please sign in to comment.