Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.
Hüseyin BIYIK edited this page Jul 21, 2023 · 17 revisions

COMPILATION

FFmpeg has various compilation options, i will only talk about how to enable RKMPP decoders and encoders here.

To enable rkmpp decoder and encoder you need below extra libraries:

Please prefer latest versions of those libraries.

To compile the rkmpp you need to configure the ffmpeg with the flag --enable-rkmpp and this will lead the below command with its dependencies

./configure --enable-rkmpp --enable-version3 --enable-libdrm
make

Please note that, for fast memory transfers, mpp library uses /dev/dma_heap/system-uncached-dma32 device. And on default rockchip vendor kernel those devices are restricted to video user group.

This means that if you want to use rkmpp based decoders make sure your user acccount is a member of video

You can check which group membership that the logged in user has with

groups

command, and if the video group is not there, you can add with

sudo usermod -a -G video accountusername

ENCODER USAGE

To transcode to h264

ffmpeg -i input.mp4 -c:v h264 out.mp4

To transcode to h265/hevc

ffmpeg -i input.mp4 -c:v hevc out.mp4

To transcode to vp8

ffmpeg -i input.mp4 -c:v out out.kv

To capture screen with kmsgrab

sudo ffmpeg -device /dev/dri/card0 -framerate 60 -f kmsgrab -i - -c:v h264 out.mp4

To capture webcam (/dev/video1 is the v4l2 device)

ffmpeg -f v4l2 -i /dev/video1 -framerate 60 -video_size 1920x1080 -c:v h264 out.mp4

To capture Hdmi-in with rk3588

ffmpeg -f v4l2 -i /dev/video0 -framerate 60 -video_size 1920x1080 -c:v h264 out.mp4

To scale to different resolution

ffmpeg -i input.mp4 -c:v h264 -width 1280 -height 720 out.mp4

OBS Usage:

Go to settings->output->recording->type and set it to "Custom Output", set the video encoder to "hevc/h264_rkmpp_encoder". For best performance use the Pipewire Screen capture. image

To get h264 encoder configuration options:

$ ffmpeg -h encoder=h264_rkmpp_encoder
ffmpeg version n6.0 Copyright (c) 2000-2023 the FFmpeg developers
Encoder h264_rkmpp_encoder [h264 (rkmpp encoder )]:
    General capabilities: delay avoidprobe hardware 
    Threading capabilities: none
    Supported hardware devices: 
    Supported pixel formats: nv24 yuyv422 uyvy422 nv16 yuv422p bgr24 bgra bgr0 nv12 yuv420p drm_prime
rkmpp_h264_encoder AVOptions:
  -rc_mode           <int>        E..V....... Set rate control mode (from 0 to 4) (default CBR)
     VBR             0            E..V.......
     CBR             1            E..V.......
     CQP             2            E..V.......
     AVBR            3            E..V.......
  -quality_min       <int>        E..V....... Minimum Quality (from 1 to 100) (default 50)
  -quality_max       <int>        E..V....... Maximum Quality (from 1 to 100) (default 100)
  -profile           <int>        E..V....... Set profile restrictions (from -1 to 100) (default high)
     baseline        66           E..V.......
     main            77           E..V.......
     high            100          E..V.......
  -level             <int>        E..V....... Compression Level (from -99 to 255) (default 5.1)
     1               10           E..V.......
     1.1             11           E..V.......
     1.2             12           E..V.......
     1.3             13           E..V.......
     2               20           E..V.......
     2.1             21           E..V.......
     2.2             22           E..V.......
     3               30           E..V.......
     3.1             31           E..V.......
     3.2             32           E..V.......
     4               40           E..V.......
     4.1             41           E..V.......
     4.2             42           E..V.......
     5               50           E..V.......
     5.1             51           E..V.......
     5.2             52           E..V.......
     6               60           E..V.......
     6.1             61           E..V.......
     6.2             62           E..V.......
  -coder             <int>        E..V....... Entropy coder type (from 0 to 1) (default cabac) (from 0 to 1) (default cabac)
     cavlc           0            E..V.......
     cabac           1            E..V.......
  -8x8dct            <boolean>    E..V....... High profile 8x8 transform. (default true)

To get Hevc encoder options:

[alarm@alarm testfiles]$ ffmpeg -h encoder=hevc_rkmpp_encoder
ffmpeg version n6.0 Copyright (c) 2000-2023 the FFmpeg developers
Encoder hevc_rkmpp_encoder [hevc (rkmpp encoder )]:
    General capabilities: delay avoidprobe hardware 
    Threading capabilities: none
    Supported hardware devices: 
    Supported pixel formats: nv24 yuyv422 uyvy422 nv16 yuv422p bgr24 bgra bgr0 nv12 yuv420p drm_prime
rkmpp_hevc_encoder AVOptions:
  -rc_mode           <int>        E..V....... Set rate control mode (from 0 to 4) (default CBR)
     VBR             0            E..V.......
     CBR             1            E..V.......
     CQP             2            E..V.......
     AVBR            3            E..V.......
  -quality_min       <int>        E..V....... Minimum Quality (from 1 to 100) (default 50)
  -quality_max       <int>        E..V....... Maximum Quality (from 1 to 100) (default 100)
  -profile           <int>        E..V....... Set profile restrictions (from -1 to 2) (default main)
     main            1            E..V.......
     main10          2            E..V.......
  -level             <int>        E..V....... Compression Level (from -99 to 255) (default 8.5)
     1               30           E..V.......
     2               60           E..V.......
     2.1             63           E..V.......
     3               90           E..V.......
     3.1             93           E..V.......
     4               120          E..V.......
     4.1             123          E..V.......
     5               150          E..V.......
     5.1             153          E..V.......
     5.2             156          E..V.......
     6               180          E..V.......
     6.1             183          E..V.......
     6.2             186          E..V.......
     8.5             255          E..V.......

To get vp8 encoder configuration options

[alarm@alarm testfiles]$ ffmpeg -h encoder=vp8_rkmpp_encoder
Encoder vp8_rkmpp_encoder [vp8 (rkmpp encoder )]:
    General capabilities: delay avoidprobe hardware 
    Threading capabilities: none
    Supported hardware devices: 
    Supported pixel formats: nv16 yuv422p yuyv422 uyvy422 bgra bgr0 nv12 yuv420p drm_prime
rkmpp_vp8_encoder AVOptions:
  -rc_mode           <int>        E..V....... Set rate control mode (from 0 to 4) (default CBR)
     VBR             0            E..V.......
     CBR             1            E..V.......
     CQP             2            E..V.......
     AVBR            3            E..V.......
  -quality_min       <int>        E..V....... Minimum Quality (from 1 to 100) (default 50)
  -quality_max       <int>        E..V....... Maximum Quality (from 1 to 100) (default 100)
  -width             <int>        E..V....... scale to Width (from 0 to 4096) (default 0)
  -height            <int>        E..V....... scale to Height (from 0 to 4096) (default 0)

Clone this wiki locally