Hardware accelerated video Encoding / Decoding on Brainypi

BrainyPi’s SoC Rockchip RK3399 has built-in hardware encoders for H.264/MVC/VP8 and a hardware decoder. But this has only been implemented in GStreamer. This topic is created to consolidate all the information related to it to help with the development of FFmpeg support.

Relevant Links:
https://opensource.rock-chips.com/wiki_Mpp
Big Buck Bunny

To check if GStreamer plugins are installed on your board run:

gst-inspect-1.0 | grep -i mpp

The output should be something like this:

typefindfunctions: audio/x-musepack: mpc, mpp, mp+
rockchipmpp:  mppvideodec: Rockchip's MPP video decoder
rockchipmpp:  mpph264enc: Rockchip Mpp H264 Encoder
rockchipmpp:  mpph265enc: Rockchip Mpp H265 Encoder
rockchipmpp:  mppvp8enc: Rockchip Mpp VP8 Encoder
rockchipmpp:  mppjpegenc: Rockchip Mpp JPEG Encoder
rockchipmpp:  mppjpegdec: Rockchip's MPP JPEG image decoder

To Decode h264 and again Encode to h264:

gst-launch-1.0 filesrc location=./bbb_sunflower_1080p_60fps_normal.mp4  num-buffers=3000 ! qtdemux name=d d.video_0 ! h264parse ! mppvideodec ! video/x-raw,format=NV12 ! mpph264enc ! h264parse ! qtmux ! filesink location=./h264dec-h264.mp4

To Decode h264 and again Encode to vp8:

gst-launch-1.0 filesrc location=./bbb_sunflower_1080p_60fps_normal.mp4  num-buffers=3000 ! qtdemux name=d d.video_0 ! h264parse ! mppvideodec ! video/x-raw,format=NV12 ! mppvp8enc ! qtmux ! filesink location=./h264dec-vp8.mp4

Original File:

ffprobe bbb_sunflower_1080p_60fps_normal.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'bbb_sunflower_1080p_60fps_normal.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
    creation_time   : 2013-12-16T17:59:32.000000Z
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
    composer        : Sacha Goedegebure
  Duration: 00:10:34.53, start: 0.000000, bitrate: 4486 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4001 kb/s, 60 fps, 60 tbr, 60k tbn, 120 tbc (default)
    Metadata:
      creation_time   : 2013-12-16T17:59:32.000000Z
      handler_name    : GPAC ISO Video Handler
    Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)
    Metadata:
      creation_time   : 2013-12-16T17:59:37.000000Z
      handler_name    : GPAC ISO Audio Handler
    Stream #0:2(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 320 kb/s (default)
    Metadata:
      creation_time   : 2013-12-16T17:59:37.000000Z
      handler_name    : GPAC ISO Audio Handler
    Side data:
      audio service type: main

H264 Encoded File:

ffprobe h264dec-h264.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'h264dec-h264.mp4':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    creation_time   : 2022-12-15T07:06:32.000000Z
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    composer        : Sacha Goedegebure
    genre           : Animation
    title           : Big Buck Bunny, Sunflower version
  Duration: 00:00:22.53, start: 0.000000, bitrate: 15319 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(bt709, progressive), 1920x1080, 15316 kb/s, SAR 1:1 DAR 16:9, 59.96 fps, 60 tbr, 6k tbn, 60 tbc (default)
    Metadata:
      creation_time   : 2022-12-15T07:06:32.000000Z
      handler_name    : VideoHandler

VP8 Encoded File:

ffprobe h264dec-vp8.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'h264dec-vp8.mp4':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    creation_time   : 2022-12-15T09:15:40.000000Z
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    composer        : Sacha Goedegebure
    genre           : Animation
    title           : Big Buck Bunny, Sunflower version
  Duration: 00:00:22.52, start: 0.000000, bitrate: 14275 kb/s
    Stream #0:0(und): Video: vp8 (vp08 / 0x38307076), yuv420p(bt709, progressive), 1920x1080, 14272 kb/s, SAR 1:1 DAR 16:9, 60 fps, 60 tbr, 6k tbn, 6k tbc (default)
    Metadata:
      creation_time   : 2022-12-15T09:15:40.000000Z
      handler_name    : VideoHandler