Compiled Ffmpeg With HW Decoding Mjpeg (Rockchip)
Compiled FFmpeg with HW Decoding MJPEG (Rockchip)
Hardware-accelerated MJPEG Decoding with mjpeg_rkmpp
in FFmpeg for Frigate (Rockchip)
In this article, we will explore the process of compiling FFmpeg for Frigate (Rockchip) with support for hardware-accelerated MJPEG decoding using mjpeg_rkmpp
. This patch was based on this Pull Request.
Using Hardware Decoding
Using hardware decoding with the parameter input_args: -c:v mjpeg_rkmpp ...
significantly reduces CPU load for MJPEG cameras. Previously, with input_args: -c:v mjpeg
in my config.yaml
, I observed high CPU usage: "Camera1 has high FFMPEG CPU usage (60%)". After applying the patch and switching to hardware decoding, the CPU usage dropped to "Camera1 has high FFMPEG CPU usage (21%)" (assuming the correct hwaccel_args
are set in the configuration).
FFmpeg Decoder Information
Below is the output of ffmpeg -decoders | grep rkmpp
:
deoptim@rock-3a:~$ ffmpeg -decoders | grep rkmpp
ffmpeg version 7.1.1-Jellyfin Copyright (c) 2000-2025 the FFmpeg developers
built with gcc 14.2.0 (crosstool-NG 1.27.0.18_7458341)
configuration: --prefix=/ffbuild/prefix --pkg-config=pkg-config --pkg-config-flags=--static --cross-prefix=aarch64-ffbuild-linux-gnu- --arch=aarch64 --cpu=armv8-a --target-os=linux --extra-version=Jellyfin --extra-cflags= --extra-cxxflags= --extra-ldflags= --extra-ldexeflags=-pie --extra-libs=-ldl --enable-gpl --enable-version3 --disable-ffplay --disable-debug --disable-doc --disable-sdl2 --disable-libxcb --disable-xlib --enable-lto=auto --enable-iconv --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-libxml2 --enable-openssl --enable-lzma --enable-fontconfig --enable-libharfbuzz --enable-libvorbis --enable-opencl --enable-chromaprint --enable-libdav1d --enable-libfdk-aac --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libopenmpt --enable-rkmpp --enable-rkrga --enable-libsrt --enable-libsvtav1 --enable-libdrm --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libzimg --enable-libzvbi
libavutil 59. 39.100 / 59. 39.100
libavcodec 61. 19.101 / 61. 19.101
libavformat 61. 7.100 / . 7.100
libavdevice 61. 3.100 / 61. 3.100
libavfilter 10. 4.100 / 10. 4.100
libswscale 8. 3.100 / 8. 3.100
libswresample 5. 3.100 / 5. 3.100
libpostproc 58. 3.100 / 58. 3.100
V..... av1_rkmpp Rockchip MPP (Media Process Platform) AV1 decoder (codec av1)
V..... h263_rkmpp Rockchip MPP (Media Process Platform) H263 decoder (codec h263)
V..... h264_rkmpp Rockchip MPP (Media Process Platform) H264 decoder (codec h264)
V..... hevc_rkmpp Rockchip MPP (Media Process Platform) HEVC decoder (codec hevc)
V..... mjpeg_rkmpp Rockchip MPP (Media Process Platform) MJPEG decoder (codec mjpeg)
V..... mpeg1_rkmpp Rockchip MPP (Media Process Platform) MPEG1VIDEO decoder (codec mpeg1video)
V..... mpeg2_rkmpp Rockchip MPP (Media Process Platform) MPEG2VIDEO decoder (codec mpeg2video)
V..... mpeg4_rkmpp Rockchip MPP (Media Process Platform) MPEG4 decoder (codec mpeg4)
V..... vp8_rkmpp Rockchip MPP (Media Process Platform) VP8 decoder (codec vp8)
V..... vp9_rkmpp Rockchip MPP (Media Process Platform) VP9 decoder (codec vp9)
deoptim@rock-3a:~$
deoptim@rock-3a:~$ ffmpeg -h decoder=mjpeg_rkmpp
ffmpeg version 7.1.1-Jellyfin Copyright (c) 2000-2025 the FFmpeg developers
built with gcc 14.2.0 (crosstool-NG 1.27.0.18_7458341)
configuration: --prefix=/ffbuild/prefix --pkg-config=pkg-config --pkg-config-flags=--static --cross-prefix=aarch64-ffbuild-linux-gnu- --arch=aarch64 --cpu=armv8-a --target-os=linux --extra-version=Jellyfin --extra-cflags= --extra-cxxflags= --extra-ldflags= --extra-ldexeflags=-pie --extra-libs=-ldl --enable-gpl --enable-version3 --disable-ffplay --disable-debug --disable-doc --disable-sdl2 --disable-libxcb --disable-xlib --enable-lto=auto --enable-iconv --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-libxml2 --enable-openssl --enable-lzma --enable-fontconfig --enable-libharfbuzz --enable-libvorbis --enable-opencl --enable-chromaprint --enable-libdav1d --enable-libfdk-aac --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libv --enable-libwebp --enable-libopenmpt --enable-rkmpp --enable-rkrga --enable-libsrt --enable-libsvtav1 --enable-libdrm --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libzimg --enable-libzvbi
libavutil 59. 39.100 / 59. 39.100
libavcodec 61. 19.101 / 61. 19.101
libavformat 61. 7.100 / 61. 7.100
libavdevice 61. 3.100 / 61. 3.100
libavfilter 10. 4.100 / 10. 4.100
libswscale 8. 3.100 / 8. 3.100
libswresample 5. 3.100 / 5. 3.100
libpostproc 58. 3.100 / 58. 3.100
Decoder mjpeg_rkmpp [Rockchip MPP (Media Process Platform) MJPEG decoder]:
General capabilities: delay avoidprobe hardware
Threading capabilities: none
Supported hardware devices: rkmpp
mjpeg_rkmpp_decoder AVOptions:
-deint <boolean> .D.V....... Enable IEP (Image Enhancement Processor) for de-interlacing (default true)
-afbc <int> .D.V....... Enable AFBC (Arm Frame Buffer Compression) to save bandwidth (from 0 to 2) (default off)
off 0 .D.V....... Disable AFBC support
on 1 .D.V....... Enable AFBC support
rga 2 .D.V....... Enable AFBC if capable RGA is available
-fast_parse <boolean> .D.V....... Enable fast parsing to improve decoding parallelism (default true)
-buf_mode <int> .D.V....... Set the buffer mode for MPP decoder (from 0 to 1) (default half)
half 0 .D.V....... Half internal mode
ext 1 .D.V....... Pure external mode
deoptim@rock-3a:~$
Instructions for Using Custom FFmpeg in Frigate Container (Docker Compose)
Below are the steps to use a custom FFmpeg version in a Frigate container (assuming Docker Compose is
Q&A: Compiled FFmpeg with HW Decoding MJPEG (Rockchip)
Q: What is the purpose of compiling FFmpeg with HW decoding MJPEG (Rockchip)?
A: The purpose of compiling FFmpeg with HW decoding MJPEG (Rockchip) is to reduce CPU load for MJPEG cameras. This is achieved by using the mjpeg_rkmpp
decoder, which is a hardware-accelerated MJPEG decoder.
Q: What is the difference between mjpeg
and mjpeg_rkmpp
decoders?
A: The mjpeg
decoder is a software-based MJPEG decoder, while the mjpeg_rkmpp
decoder is a hardware-accelerated MJPEG decoder. The mjpeg_rkmpp
decoder uses the Rockchip MPP (Media Process Platform) to accelerate the decoding process, resulting in lower CPU usage.
Q: How do I use the mjpeg_rkmpp
decoder in FFmpeg?
A: To use the mjpeg_rkmpp
decoder in FFmpeg, you need to specify the -c:v mjpeg_rkmpp
option in the input_args
parameter of your config.yaml
file.
Q: What are the benefits of using the mjpeg_rkmpp
decoder?
A: The benefits of using the mjpeg_rkmpp
decoder include:
- Reduced CPU usage: The
mjpeg_rkmpp
decoder uses the Rockchip MPP to accelerate the decoding process, resulting in lower CPU usage. - Improved performance: The
mjpeg_rkmpp
decoder can handle MJPEG streams more efficiently than themjpeg
decoder. - Better support for MJPEG cameras: The
mjpeg_rkmpp
decoder provides better support for MJPEG cameras, including those with high-resolution video.
Q: How do I compile FFmpeg with HW decoding MJPEG (Rockchip) support?
A: To compile FFmpeg with HW decoding MJPEG (Rockchip) support, you need to apply the patch for the mjpeg_rkmpp
decoder to the FFmpeg source code. You can find the patch in the Jellyfin 7.1.1-2 version.
Q: What are the system requirements for compiling FFmpeg with HW decoding MJPEG (Rockchip) support?
A: The system requirements for compiling FFmpeg with HW decoding MJPEG (Rockchip) support include:
- A 64-bit Linux system
- A Rockchip-based SoC (System-on-Chip)
- A compatible version of FFmpeg (7.1.1-2 or later)
Q: How do I install the compiled FFmpeg with HW decoding MJPEG (Rockchip) support?
A: To install the compiled FFmpeg with HW decoding MJPEG (Rockchip) support, you need to copy the compiled FFmpeg binaries to a convenient location on your system and update the volumes
parameter in your docker-compose.yml
file to point to the new location.
Q: What are the troubleshooting steps for issues related to the mjpeg_rkmpp
decoder?
A: The troubleshooting steps for issues related to the mjpeg_rkmpp
decoder include:
- Checking the system requirements and ensuring that the system meets the minimum requirements for compiling and running FFmpeg with HW decoding MJPEG (Rockchip) support.
- Verifying that the
mjpeg_rkmpp
decoder is enabled in the FFmpeg configuration. - Checking the log files for any errors or warnings related to the
mjpeg_rkmpp
decoder. - Consulting the FFmpeg documentation and online resources for further assistance.