Question
People commonly ask on the Zoom Developer Forum:
How do I encode the raw video obtained from startRawRecording? I’m grabbing YUV frames from onRawDataReceived (ZoomSDKYUVRawDataI420) on macOS, writing them to disk, and then using ffmpeg to encode. The output quality is poor and I’m seeing a green bar at the top. What’s the correct way to save the raw Y, U, V planes and encode them?
Answer
When recording I420 raw frames, you must write each frame’s planes in the correct order and size, and be careful not to overwrite the file. Writing the wrong lengths or including padded bytes can cause artifacts like a green bar.
-
Write frames in I420 (YUV420p) plane order per callback: - For each onRawDataReceived callback, append to a single .yuv file:
- Append Y plane bytes: length = width * height
- Append U plane bytes: length = (width/2) * (height/2) = width * height / 4
- Append V plane bytes: length = width * height / 4
- Use [data getYBuffer], [data getUBuffer], [data getVBuffer] for the plane pointers.
- Do not use [data getBufferLen] for each plane (that’s the total frame size, not per-plane).
- Don’t call writeToFile three times to the same path (that overwrites). Instead, keep one file/buffer open and append each plane in order per frame.
-
Watch out for padding/stride: - If the raw planes include row padding, copying the entire plane as one block may introduce extra bytes per row (often shows up as a green bar). - In that case, copy row-by-row for each plane using the visible width (Y rows are width bytes; U/V rows are width/2 bytes), skipping any padding between rows before appending to the output file.
-
Encode with matching parameters in ffmpeg: - Ensure -video_size and -framerate match what you wrote (for example: 640x360 at 25 fps). - Example: ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 640x360 -framerate 25 -i rawRecording.yuv -f mp4 rawRecording.mp4
If you prefer a walkthrough on turning Zoom raw data into frames/MP4, there’s a referenced blog post titled “HOW TO CONVERT ZOOM RAW DATA INTO PNG AND MP4” on recall.ai in the forum thread.
Zoom Developer Forum Examples
Some examples of this question are:
