Skip to content

Commit

Permalink
Add yuv420 encoding to opencv-video-capture (#725)
Browse files Browse the repository at this point in the history
YUV420 encoding has the advantage to be slightly more compressed when
comparing to a raw images.

Ex: raw size in RGB (480, 640, 3)  -> size in YUV420 (720, 640) 

This will enable encoding in av1.
  • Loading branch information
haixuanTao authored Dec 1, 2024
2 parents 48e2efe + 0514044 commit c5c1222
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions node-hub/opencv-video-capture/opencv_video_capture/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def main():
# Get the right encoding
if encoding == "rgb8":
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
elif encoding == "yuv420":
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2YUV_I420)
elif encoding in ["jpeg", "jpg", "jpe", "bmp", "webp", "png"]:
ret, frame = cv2.imencode("." + encoding, frame)
if not ret:
Expand Down

0 comments on commit c5c1222

Please sign in to comment.