The issue of input image format support for hardware encoding with h264_rkmpp. #141

Closed
opened 2025-12-23 10:34:07 +01:00 by backuprepo · 1 comment
Owner

Originally created by @wangchao118 on GitHub (Jan 20, 2025).

Hello, after following your compilation steps, I called avcodec_find_encoder_by_name("h264_rkmpp"), and I found that the h264_rkmpp encoder has a requirement for the input image format—it must be converted to yuv420p in order to encode properly. I have a USB camera connected to the rk3399 board for real-time 1080p@30hz hardware encoding. The input image from the USB camera is in yuvj422p format, which cannot be directly encoded using h264_rkmpp and must be converted to yuv420p. This conversion is done on the rk3399 CPU, which feels resource-intensive. I would like to know if there's any step during the compilation process where I can set the input image format for the encoder, so that h264_rkmpp can directly support yuvj422p format input?

Thank you!

Originally created by @wangchao118 on GitHub (Jan 20, 2025). Hello, after following your compilation steps, I called avcodec_find_encoder_by_name("h264_rkmpp"), and I found that the h264_rkmpp encoder has a requirement for the input image format—it must be converted to yuv420p in order to encode properly. I have a USB camera connected to the rk3399 board for real-time 1080p@30hz hardware encoding. The input image from the USB camera is in yuvj422p format, which cannot be directly encoded using h264_rkmpp and must be converted to yuv420p. This conversion is done on the rk3399 CPU, which feels resource-intensive. I would like to know if there's any step during the compilation process where I can set the input image format for the encoder, so that h264_rkmpp can directly support yuvj422p format input? Thank you!
backuprepo 2025-12-23 10:34:07 +01:00
Author
Owner

@nyanmisaka commented on GitHub (Jan 20, 2025):

YUVJ support is now added in the latest commits. 37d4c2129b

Note that RK3399's video encoder doesn't support YUV(J)422P, which is a planar format. YCbYCr 4:2:2 means YUYV422, which is a packed format.

So the RGA filter is needed to convert YUV(J)422P to YUV(J)420P/NV12 before encoding.

./ffmpeg -init_hw_device rkmpp=hw -f v4l2 -i /dev/video* \
-an -sn -dn -vf hwupload,scale_rkrga=format=yuvj420p \
-c:v h264_rkmpp -qp_init 24 -vframes 1000 -y /tmp/test.mp4

Image

@nyanmisaka commented on GitHub (Jan 20, 2025): YUVJ support is now added in the latest commits. https://github.com/nyanmisaka/ffmpeg-rockchip/commit/37d4c2129ba7515b56e80ed581597058722da433 Note that RK3399's video encoder doesn't support YUV(J)422P, which is a planar format. YCbYCr 4:2:2 means YUYV422, which is a packed format. So the RGA filter is needed to convert YUV(J)422P to YUV(J)420P/NV12 before encoding. ``` ./ffmpeg -init_hw_device rkmpp=hw -f v4l2 -i /dev/video* \ -an -sn -dn -vf hwupload,scale_rkrga=format=yuvj420p \ -c:v h264_rkmpp -qp_init 24 -vframes 1000 -y /tmp/test.mp4 ``` ![Image](https://github.com/user-attachments/assets/e8d805dd-836b-4a2c-88dd-e51430917ca0)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: starred/ffmpeg-rockchip#141
No description provided.