Skip to content

Instantly share code, notes, and snippets.

@HeyMeco
Last active June 13, 2024 10:26
Show Gist options
  • Save HeyMeco/d016493a72baf94e9c69d072eaadf943 to your computer and use it in GitHub Desktop.
Save HeyMeco/d016493a72baf94e9c69d072eaadf943 to your computer and use it in GitHub Desktop.
Results for Hardware Accelerated Video Encoding on Rockchip RK3568 with MPP & FFMPEG

RK3568 Video Encoder

Thanks to @nyanmisaka and his https://github.com/nyanmisaka/jellyfin-ffmpeg/tree/next-rockchip-hwa

Options in FFMPEG

  • HEVC

    Encoder hevc_rkmpp [Rockchip MPP (Media Process Platform) HEVC encoder]:
        General capabilities: delay hardware 
        Threading capabilities: none
        Supported hardware devices: rkmpp rkmpp drm 
        Supported pixel formats: yuv420p yuv422p yuv444p nv12 nv21 nv16 nv24 yuyv422 yvyu422 uyvy422 rgb24 bgr24 rgba rgb0 bgra bgr0 argb 0rgb abgr 0bgr drm_prime
    hevc_rkmpp_encoder AVOptions:
      -rc_mode           <int>        E..V....... Set the encoding rate control mode (from 0 to 4) (default 4)
         VBR             0            E..V.......
         CBR             1            E..V.......
         CQP             2            E..V.......
         AVBR            3            E..V.......
      -qp_init           <int>        E..V....... Set the initial QP value (from -1 to 51) (default -1)
      -qp_max            <int>        E..V....... Set the max QP value for P and B frame (from -1 to 51) (default -1)
      -qp_min            <int>        E..V....... Set the min QP value for P and B frame (from -1 to 51) (default -1)
      -qp_max_i          <int>        E..V....... Set the max QP value for I frame (from -1 to 51) (default -1)
      -qp_min_i          <int>        E..V....... Set the min QP value for I frame (from -1 to 51) (default -1)
      -surfaces          <int>        E..V....... Set the maximum surfaces to be used for encoding (from 1 to 16) (default 4)
      -profile           <int>        E..V....... Set the encoding profile restriction (from -1 to 1) (default main)
         main            1            E..V.......
      -level             <int>        E..V....... Set the encoding level restriction (from -99 to 186) (default 0)
         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.......
  • H264

    Encoder h264_rkmpp [Rockchip MPP (Media Process Platform) H264 encoder]:
        General capabilities: delay hardware 
        Threading capabilities: none
        Supported hardware devices: rkmpp rkmpp drm 
        Supported pixel formats: yuv420p yuv422p yuv444p nv12 nv21 nv16 nv24 yuyv422 yvyu422 uyvy422 rgb24 bgr24 rgba rgb0 bgra bgr0 argb 0rgb abgr 0bgr drm_prime
    h264_rkmpp_encoder AVOptions:
      -rc_mode           <int>        E..V....... Set the encoding rate control mode (from 0 to 4) (default 4)
         VBR             0            E..V.......
         CBR             1            E..V.......
         CQP             2            E..V.......
         AVBR            3            E..V.......
      -qp_init           <int>        E..V....... Set the initial QP value (from -1 to 51) (default -1)
      -qp_max            <int>        E..V....... Set the max QP value for P and B frame (from -1 to 51) (default -1)
      -qp_min            <int>        E..V....... Set the min QP value for P and B frame (from -1 to 51) (default -1)
      -qp_max_i          <int>        E..V....... Set the max QP value for I frame (from -1 to 51) (default -1)
      -qp_min_i          <int>        E..V....... Set the min QP value for I frame (from -1 to 51) (default -1)
      -surfaces          <int>        E..V....... Set the maximum surfaces to be used for encoding (from 1 to 16) (default 4)
      -profile           <int>        E..V....... Set the encoding profile restriction (from -1 to 100) (default high)
         baseline        66           E..V.......
         main            77           E..V.......
         high            100          E..V.......
      -level             <int>        E..V....... Set the encoding level restriction (from -99 to 62) (default 0)
         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....... Set the 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....... Set the high profile 8x8 transform (default true)

Example Command

/usr/lib/jellyfin-ffmpeg/ffmpeg -hwaccel rkmpp -hwaccel_output_format drm_prime -afbc rga -s 1920x1080 -pix_fmt yuv420p -i BirdsInCage_30fps.yuv -c:v hevc_rkmpp -level 153 -g:v 120 -c:a copy -sn -y -b:v 50M -maxrate 50M -r 30 rk3568_50mbps_hevc.mp4

Results HEVC - 1080P

  • Birds In Cage @ 30fps - Netflix

    3mbps: 2494kB

    frame= 216 fps= 62 q=-0.0 Lsize= 2495kB time=00:00:07.16 bitrate=2852.4kbits/s dup=36 drop=0 speed=2.06x

    6mbps: 6580kB

    frame= 216 fps= 60 q=-0.0 Lsize= 6582kB time=00:00:07.16 bitrate=7523.6kbits/s dup=36 drop=0 speed=1.98x

    10mbps: 8214kB

    frame=  216 fps= 59 q=-0.0 Lsize=    8216kB time=00:00:07.16 bitrate=9391.3kbits/s dup=36 drop=0 speed=1.97x

    20mbps: 16420kB

    frame=  216 fps= 59 q=-0.0 Lsize=   16422kB time=00:00:07.16 bitrate=18771.2kbits/s dup=36 drop=0 speed=1.97x
  • Crowd Run @ 25fps - Netflix

    3mbps:

    frame=  150 fps= 64 q=-0.0 Lsize=    9795kB time=00:00:05.96 bitrate=13462.6kbits/s speed=2.52x    
    video:9793kB

    6mbps:

    frame=  150 fps= 62 q=-0.0 Lsize=    9844kB time=00:00:05.96 bitrate=13530.3kbits/s speed=2.46x    
    video:9842kB

    10mbps:

    frame=  150 fps= 60 q=-0.0 Lsize=    9945kB time=00:00:05.96 bitrate=13668.8kbits/s speed= 2.4x    
    video:9943kB

    20mbps:

    frame=  150 fps= 61 q=-0.0 Lsize=   14235kB time=00:00:05.96 bitrate=19566.4kbits/s speed=2.44x    
    video:14234kB

Results HEVC - 4K (Out of Spec)

  • Big Buck Bunny - bbb_sunflower_2160p_30fps_normal.mp4

    /usr/lib/jellyfin-ffmpeg/ffmpeg -hwaccel rkmpp -hwaccel_output_format drm_prime -afbc rga -i /srv/dev-disk-by-uuid-xyz/Software/bbb_sunflower_2160p_30fps_normal.mp4 -c:v hevc_rkmpp -b:v 6M -maxrate 6M -g:v 120 -c:a copy -sn -y -level 153 /srv/dev-disk-by-uuid-XYZ/Plex/Testfiles/RK3568/BBB/BBB-rk3568_6mbps_hevc_4k_lvl153.mp4

    6mbps:

    frame=19038 fps= 18 q=-0.0 Lsize=  492858kB time=00:10:34.56 bitrate=6362.6kbits/s dup=2 drop=0 speed=0.615x    
    video:467843kB

    Has small visual artifacts in the intro then is flawless.

@redcapital
Copy link

@HeyMeco may I ask what linux kernel and hardware did you use for your experiments? I'm trying to find a suitable kernel / OS for odroid M1

@HeyMeco
Copy link
Author

HeyMeco commented Jan 7, 2024

@redcapital may I ask what linux kernel and hardware did you use for your experiments? I'm trying to find a suitable kernel / OS for odroid M1

I was using the Rockchip Vendor Kernel (in this case from Friendlyarm's Fork) with Version 5.10.160 and DietPi as OS but any other Rockchip BSP Kernel should work fine.
So for the Odroid M1 any image as long as it has MPP support will work. I assume Hard kernels fork should work: https://github.com/hardkernel/linux/tree/odroidm1-5.10.y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment