Through this ffmpeg-rockchip fork, users can obtain the fastest hardware transcoding and filtering speed on the Rockchip platform via CLI (command line). And the code style has been kept as consistent as possible with the upstream FFmpeg, making it easy to read and maintain.
This project was originally part of jellyfin/jellyfin-ffmpeg, but I have now separated it for community use and issue collection.
ffmpeg-rockchip
This project aims to provide full hardware transcoding pipeline in FFmpeg CLI for Rockchip platforms that support MPP (Media Process Platform) and RGA (2D Raster Graphic Acceleration). This includes hardware decoders, encoders and filters. A typical target platform is RK3588/3588s based devices.
Hightlights
MPP decoders support up to 8K 10-bit H.264, HEVC, VP9 and AV1 decoding
MPP decoders support producing AFBC (ARM Frame Buffer Compression) image
MPP decoders support de-interlace using IEP (Image Enhancement Processor)
MPP decoders support allocator half-internal and pure-external modes
MPP encoders support up to 8K H.264 and HEVC encoding
MPP encoders support async encoding, AKA frame-parallel
MPP encoders support consuming AFBC image
RGA filters support image scaling and pixel format conversion
RGA filters support image cropping
RGA filters support image transposing
RGA filters support blending two images
RGA filters support async operation
RGA filters support producing and consuming AFBC image
Zero-copy DMA in above stages
How to use
The documentation is available on the Wiki page of this project.
Thank you and all other contributors for this nice package. I was already checking it out in jellyfin and it’s working great. Big step forward for the board!!
This is feasible, but the code review will take a long time or even get bogged down because I’m sure the ffmpeg devs don’t have any RK3588 devices. RGA is another tricky spot, its only publicly available official repo airockchip/librga does not contain source code, which can be very problematic.
MJPEG/JPEG in MPP uses a different interface from video codec, namely MppTask. RK devs mentioned that they would consider making this change, but didn’t say an ETA.
Great work! I’ve been using hbiyik’s ffmpeg for quite some time now.
What’s the difference between scale_rkrga and vpp_rkrga?
Which one is faster, more performant for things like frigate? If I want to downscale a 4k video to 1080p.
Which one is faster, more performant for things like frigate? If I want to downscale a 4k video to 1080p.
In terms of decoding, the two speeds are about the same. In terms of encoding, this is twice as fast as before and can achieve more complex filter combinations.
This fork does not use libyuv from google, so hwupload is more expensive.
Encoders -c:v {h264,hevc}_rkmpp and -c:v copy are incompatible. The former is re-encoding, and the latter is just copying the stream.
Edit:
Additionally, you should refer to the VideoTranscode chapter to enable -hwaccel rkmpp -hwaccel_output_format drm_prime hardware decoding. Currently your command line is software decoding + hardware filter + hardware encoding, which is not optimal.
Also, on rk3588, unless you have reason to use yuv420p, it is more efficient to use nv12, which is determined by the RGA3 hardware capabilities.
I would like to copy the stream, downsize it and output it in yuv420p for frigate, all in hardware. most of it can be done with hbiyik’s ffmpeg. why doesn’t it work with ffmpeg-rockchip?
[hevc_rkmpp @ 0x55c15a57d0] MPP doesn’t support codec ‘hevc’ with pix_fmt ‘yuvj420p’
[vist#0:0/hevc @ 0x55c15154e0] Error while opening decoder: Function not implemented
[vost#0:0/libx264 @ 0x55c1851500] Error initializing a simple filtergraph
Error opening output file /tmp/tmp.mp4.
Error opening output files: Function not implemented
Impossible to convert between the formats supported by the filter ‘Parsed_scale_rkrga_1’ and the filter ‘auto_scale_0’
[vf#0:0 @ 0x55aa4f3710] Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while filtering: Function not implemented
[out#0/mp4 @ 0x55aa4c7930] Nothing was written into output file, because at least one of its streams received no packets.
[vost#0:0/copy @ 0x557c3c8980] Filtergraph ‘hwupload,scale_rkrga=w=1920:h=1080’ was specified, but codec copy was selected. Filtering and streamcopy cannot be used together.
Error opening output file /tmp/tmp.mp4.
Error opening output files: Function not implemented
This ffmpeg CLI syntax is incorrect, a common sense is that scaling cannot be used with -c:v copy. Scaling modifies the video source file, so it must be re-encoded.