Hardware decoding on Raspberry Pi 5 via ffmpeg

Hi, I’m new to snapcraft and the linux graphics stack.

I’m aiming to create a snap of my app which uses hardware video decoding on a Raspberry Pi 5. Performance running outside the snap is great (settles around 1.0x speed), but within the snap it’s not great (settles around 0.3x speed). The ffmpeg output below suggests the snap is not using hardware decoding.

The snap is a script which runs this command: ffmpeg -hide_banner -hwaccel drm -hwaccel_device /dev/dri/renderD128 -i /home/openup/source.h265 -f rawvideo -y /dev/null

To check if the snap can see the GPU and use DRI/DRM I added mesa-utils and used glxinfo | grep "direct rendering" which outputs direct rendering: Yes.

Edit: Here is the contents /dev/dri

$ ls -la /dev/dri
total 0
drwxr-xr-x   3 root root       120 Dec 24 01:00 .
drwxr-xr-x  16 root root      4520 Dec 25 20:08 ..
drwxr-xr-x   2 root root       100 Dec 25 21:30 by-path
crw-rw----+  1 root video 226,   0 Dec 25 20:08 card0
crw-rw----+  1 root video 226,   1 Dec 25 21:30 card1
crw-rw----+  1 root video 226, 128 Dec 25 20:08 renderD128

Here is my snapcraft.yaml file:

name: hello-snap
version: '1.0'
summary: A simple hello world snap
description: A simple hello world snap
base: core24
confinement: devmode
grade: stable

apps:
  hello:
    command-chain:
      - bin/gpu-2404-wrapper
    command: bin/hello.sh
    environment:
        LD_LIBRARY_PATH: $SNAP/ffmpeg-platform/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:$LD_LIBRARY_PATH
        PATH: $SNAP/ffmpeg-platform/usr/bin:$PATH
    extensions: [gnome]
    plugs:
      - opengl
      - vcio
      - hardware-observe

plugs:
  gpu-2404:
    interface: content
    target: $SNAP/gpu-2404
    default-provider: mesa-2404
  ffmpeg-2404:
    interface: content
    target: ffmpeg-platform
    default-provider: ffmpeg-2404
  drm:
    interface: opengl
    allow-drm: true

parts:
  hello:
    plugin: dump
    source: .
    build-environment:
      - PKG_CONFIG_PATH: /snap/ffmpeg-2404-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}
      - LD_LIBRARY_PATH: /snap/ffmpeg-2404-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
      - PATH: /snap/ffmpeg-2404-sdk/current/usr/bin${PATH:+:$PATH}
    build-snaps:
      - ffmpeg-2404-sdk
    stage-snaps:
      - ffmpeg-2404
    organize:
      hello.sh: bin/hello.sh
  
  gpu-2404:
    after: [hello]
    source: https://github.com/canonical/gpu-snap.git
    plugin: dump
    override-prime: |
      craftctl default
      ${CRAFT_PART_SRC}/bin/gpu-2404-cleanup mesa-2404
    prime:
    - bin/gpu-2404-wrapper

I’ve connected the plugs. I used the instructions from gpu-2404 and ffmpeg-2404-sdk.

Beginning of ffmpeg log inside the snap:
$ ffmpeg -loglevel debug -hide_banner -hwaccel drm -hwaccel_device /dev/dri/renderD128 -i /home/openup/source.h265 -f rawvideo -y /dev/null
Splitting the commandline.
Reading option '-hide_banner' ... matched as option 'hide_banner' (do not show program banner) with argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-hwaccel' ... matched as option 'hwaccel' (use HW accelerated decoding) with argument 'drm'.
Reading option '-hwaccel_device' ... matched as option 'hwaccel_device' (select a device for HW acceleration) with argument '/dev/dri/renderD128'.
Reading option '-i' ... matched as input url with argument '/home/openup/source.h265'.
Reading option '-f' ... matched as option 'f' (force container format (auto-detected otherwise)) with argument 'rawvideo'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '/dev/null' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option hide_banner (do not show program banner) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url /home/openup/source.h265.
Applying option hwaccel (use HW accelerated decoding) with argument drm.
Applying option hwaccel_device (select a device for HW acceleration) with argument /dev/dri/renderD128.
Successfully parsed a group of options.
Opening an input file: /home/openup/source.h265.
[AVFormatContext @ 0x5555cc772e90] Opening '/home/openup/source.h265' for reading
[file @ 0x5555cc74b550] Setting default whitelist 'file,crypto,data'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555cc772e90] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555cc772e90] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555cc772e90] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555cc772e90] Processing st: 0, edit list 0 - media time: 0, duration: 972270
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555cc772e90] rfps: 60.000000 0.000495
    Last message repeated 1 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555cc772e90] rfps: 120.000000 0.001979
    Last message repeated 1 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555cc772e90] rfps: 240.000000 0.007915
    Last message repeated 1 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555cc772e90] rfps: 59.940060 0.000634
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555cc772e90] Before avformat_find_stream_info() pos: 86909468 bytes read:40915 seeks:1 nb_streams:1
[hevc @ 0x5555cc773910] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc773910] Decoding VPS
[hevc @ 0x5555cc773910] Main profile bitstream
[hevc @ 0x5555cc773910] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc773910] Decoding SPS
[hevc @ 0x5555cc773910] Main profile bitstream
[hevc @ 0x5555cc773910] Decoding VUI
[hevc @ 0x5555cc773910] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc773910] Decoding PPS
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555cc772e90] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555cc772e90] After avformat_find_stream_info() pos: 133670 bytes read:174541 seeks:2 frames:1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/openup/source.h265':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.76.100
    location-eng    : +30.1732-097.7968/
    location        : +30.1732-097.7968/
  Duration: 00:00:10.80, start: 0.000000, bitrate: 64362 kb/s
  Stream #0:0[0x1](eng), 1, 1/90000: Video: hevc (Main), 1 reference frame (hvc1 / 0x31637668), yuvj420p(pc, bt709, left), 3840x2160, 0/1, 64356 kb/s, SAR 1:1 DAR 16:9, 59.89 fps, 60 tbr, 90k tbn (default)
      Metadata:
        handler_name    : VideoHandle
        vendor_id       : [0][0][0][0]
Successfully opened the file.
Parsing a group of options: output url /dev/null.
Applying option f (force container format (auto-detected otherwise)) with argument rawvideo.
Successfully parsed a group of options.
Opening an output file: /dev/null.
[out#0/rawvideo @ 0x5555cc7861b0] No explicit maps, mapping streams automatically...
[vost#0:0/rawvideo @ 0x5555cc786870] Created video stream from input stream 0:0
[AVHWDeviceContext @ 0x5555cc7855b0] Opened DRM device /dev/dri/renderD128: driver v3d version 1.0.0.
detected 4 logical cores
[hevc @ 0x5555cc7a4fb0] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc7a4fb0] Decoding VPS
[hevc @ 0x5555cc7a4fb0] Main profile bitstream
[hevc @ 0x5555cc7a4fb0] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc7a4fb0] Decoding SPS
[hevc @ 0x5555cc7a4fb0] Main profile bitstream
[hevc @ 0x5555cc7a4fb0] Decoding VUI
[hevc @ 0x5555cc7a4fb0] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc7a4fb0] Decoding PPS
[file @ 0x5555cc7a8c10] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> rawvideo (native))
[vost#0:0/rawvideo @ 0x5555cc786870] Starting thread...
[vf#0:0 @ 0x5555cc786c50] Starting thread...
[vist#0:0/hevc @ 0x5555cc785430] [dec:hevc @ 0x5555cc787370] Starting thread...
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555cc770930] Starting thread...
Press [q] to stop, [?] for help
[hevc @ 0x5555cc7a4fb0] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc7a4fb0] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc7a4fb0] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc7a4fb0] nal_unit_type: 20(IDR_N_LP), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc7a4fb0] Decoding SPS
[hevc @ 0x5555cc7a4fb0] Main profile bitstream
[hevc @ 0x5555cc7a4fb0] Decoding VUI
[hevc @ 0x5555cc7a4fb0] Decoding PPS
[hevc @ 0x5555cc7a4fb0] Format yuvj420p chosen by get_format().
[hevc @ 0x5555cc7a4fb0] Output frame with POC 0/0.
[hevc @ 0x5555cc7adf00] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc7adf00] Output frame with POC 0/1.
[hevc @ 0x5555cca4f8c0] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cca4f8c0] Output frame with POC 0/2.
[hevc @ 0x5555ccb25880] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555ccb25880] Output frame with POC 0/3.
[hevc @ 0x5555ccbfb930] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555ccbfb930] Output frame with POC 0/4.
[hevc @ 0x5555cc7a4fb0] Decoded frame with POC 0/0.
[hevc @ 0x5555cc7a4fb0] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[graph -1 input from stream 0:0 @ 0x7fff44002050] Setting 'video_size' to value '3840x2160'
[graph -1 input from stream 0:0 @ 0x7fff44002050] Setting 'pix_fmt' to value '12'
[graph -1 input from stream 0:0 @ 0x7fff44002050] Setting 'time_base' to value '1/90000'
[graph -1 input from stream 0:0 @ 0x7fff44002050] Setting 'pixel_aspect' to value '1/1'
[graph -1 input from stream 0:0 @ 0x7fff44002050] Setting 'colorspace' to value '1'
[graph -1 input from stream 0:0 @ 0x7fff44002050] Setting 'range' to value '2'
[graph -1 input from stream 0:0 @ 0x7fff44002050] Setting 'frame_rate' to value '60/1'
[graph -1 input from stream 0:0 @ 0x7fff44002050] w:3840 h:2160 pixfmt:yuvj420p tb:1/90000 fr:60/1 sar:1/1 csp:bt709 range:pc
[AVFilterGraph @ 0x7fff44000f90] query_formats: 3 queried, 6 merged, 0 already done, 0 delayed
[graph -1 input from stream 0:0 @ 0x7fff44002050] video frame properties congruent with link at pts_time: 0
Output #0, rawvideo, to '/dev/null':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    location        : +30.1732-097.7968/
    location-eng    : +30.1732-097.7968/
    encoder         : Lavf61.7.100
  Stream #0:0(eng), 0, 1/60: Video: rawvideo, 1 reference frame (I420 / 0x30323449), yuvj420p(pc, bt709, progressive, left), 3840x2160 [SAR 1:1 DAR 16:9], 0/1, q=2-31, 5971968 kb/s, 60 fps, 60 tbn (default)
      Metadata:
        handler_name    : VideoHandle
        vendor_id       : [0][0][0][0]
        encoder         : Lavc61.19.100 rawvideo
[out#0/rawvideo @ 0x5555cc7861b0] Starting thread...
[hevc @ 0x5555cc7a4fb0] Output frame with POC 0/5.
[hevc @ 0x5555cc7adf00] Decoded frame with POC 0/1.
[hevc @ 0x5555cc7adf00] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc7adf00] Output frame with POC 0/6.
[hevc @ 0x5555cca4f8c0] Decoded frame with POC 0/2.
[hevc @ 0x5555cca4f8c0] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cca4f8c0] Output frame with POC 0/7.
[hevc @ 0x5555ccb25880] Decoded frame with POC 0/3.
[hevc @ 0x5555ccb25880] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555ccb25880] Output frame with POC 0/8.
[hevc @ 0x5555ccbfb930] Decoded frame with POC 0/4.
[hevc @ 0x5555ccbfb930] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc7a4fb0] Decoded frame with POC 0/5.
[hevc @ 0x5555ccbfb930] Output frame with POC 0/9.
[hevc @ 0x5555cc7a4fb0] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc7a4fb0] Output frame with POC 0/10.
[hevc @ 0x5555cc7adf00] Decoded frame with POC 0/6.
[hevc @ 0x5555cc7adf00] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cc7adf00] Output frame with POC 0/11.
[hevc @ 0x5555cca4f8c0] Decoded frame with POC 0/7.
[hevc @ 0x5555cca4f8c0] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x5555cca4f8c0] Output frame with POC 0/12.
[hevc @ 0x5555ccb25880] Decoded frame with POC 0/8.
[hevc @ 0x5555ccb25880] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0s/s speed= 0.2x    
Beginning of ffmpeg log outside the snap (there's some mention of V4L2):
$ ffmpeg -loglevel debug -hide_banner -hwaccel drm -hwaccel_device /dev/dri/renderD128 -i /home/openup/source.h265 -f rawvideo -y /dev/null
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-hide_banner' ... matched as option 'hide_banner' (do not show program banner) with argument '1'.
Reading option '-hwaccel' ... matched as option 'hwaccel' (use HW accelerated decoding) with argument 'drm'.
Reading option '-hwaccel_device' ... matched as option 'hwaccel_device' (select a device for HW acceleration) with argument '/dev/dri/renderD128'.
Reading option '-i' ... matched as input url with argument '/home/openup/source.h265'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rawvideo'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '/dev/null' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Applying option hide_banner (do not show program banner) with argument 1.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url /home/openup/source.h265.
Applying option hwaccel (use HW accelerated decoding) with argument drm.
Applying option hwaccel_device (select a device for HW acceleration) with argument /dev/dri/renderD128.
Successfully parsed a group of options.
Opening an input file: /home/openup/source.h265.
[NULL @ 0x55558be612e0] Opening '/home/openup/source.h265' for reading
[file @ 0x55558be25080] Setting default whitelist 'file,crypto,data'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55558be612e0] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55558be612e0] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55558be612e0] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55558be612e0] Processing st: 0, edit list 0 - media time: 0, duration: 972270
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55558be612e0] rfps: 60.000000 0.000495
    Last message repeated 1 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55558be612e0] rfps: 120.000000 0.001979
    Last message repeated 1 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55558be612e0] rfps: 240.000000 0.007915
    Last message repeated 1 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55558be612e0] rfps: 59.940060 0.000634
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55558be612e0] Before avformat_find_stream_info() pos: 86909468 bytes read:40915 seeks:1 nb_streams:1
[hevc @ 0x55558be61ca0] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be61ca0] Decoding VPS
[hevc @ 0x55558be61ca0] Main profile bitstream
[hevc @ 0x55558be61ca0] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be61ca0] Decoding SPS
[hevc @ 0x55558be61ca0] Main profile bitstream
[hevc @ 0x55558be61ca0] Decoding VUI
[hevc @ 0x55558be61ca0] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be61ca0] Decoding PPS
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55558be612e0] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55558be612e0] After avformat_find_stream_info() pos: 133670 bytes read:174541 seeks:2 frames:1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/openup/source.h265':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.76.100
    location-eng    : +30.1732-097.7968/
    location        : +30.1732-097.7968/
  Duration: 00:00:10.80, start: 0.000000, bitrate: 64359 kb/s
  Stream #0:0[0x1](eng), 1, 1/90000: Video: hevc (Main), 1 reference frame (hvc1 / 0x31637668), yuvj420p(pc, bt709, left), 3840x2160, 0/1, 64356 kb/s, SAR 1:1 DAR 16:9, 59.89 fps, 60 tbr, 90k tbn (default)
    Metadata:
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
Successfully opened the file.
Parsing a group of options: output url /dev/null.
Applying option f (force format) with argument rawvideo.
Successfully parsed a group of options.
Opening an output file: /dev/null.
[file @ 0x55558be64e30] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
[AVHWDeviceContext @ 0x55558be611d0] Opened DRM device /dev/dri/renderD128: driver v3d version 1.0.0.
detected 4 logical cores
[hevc @ 0x55558be65c40] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be65c40] Decoding VPS
[hevc @ 0x55558be65c40] Main profile bitstream
[hevc @ 0x55558be65c40] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be65c40] Decoding SPS
[hevc @ 0x55558be65c40] Main profile bitstream
[hevc @ 0x55558be65c40] Decoding VUI
[hevc @ 0x55558be65c40] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be65c40] Decoding PPS
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> rawvideo (native))
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 1 times
[hevc @ 0x55558be65c40] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be65c40] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be65c40] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be65c40] nal_unit_type: 20(IDR_N_LP), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be65c40] Decoding VPS
[hevc @ 0x55558be65c40] Main profile bitstream
[hevc @ 0x55558be65c40] Decoding SPS
[hevc @ 0x55558be65c40] Main profile bitstream
[hevc @ 0x55558be65c40] Decoding VUI
[hevc @ 0x55558be65c40] Decoding PPS
[hevc @ 0x55558be65c40] Format drm_prime chosen by get_format().
[hevc @ 0x55558be65c40] Format drm_prime requires hwaccel initialisation.
[hevc @ 0x55558be65c40] <<< v4l2_request_hevc_init
[hevc @ 0x55558be65c40] probe_video_device: path=/dev/video19 capabilities=0x4204000
[hevc @ 0x55558be65c40] Adding: /dev/media2,/dev/video19 pix=0x35363253, type=10
[hevc @ 0x55558be65c40] probe_video_device: path=/dev/video20 capabilities=0x4202000
[hevc @ 0x55558be65c40] probe_video_device: missing required mem2mem capability
[hevc @ 0x55558be65c40] probe_video_device: path=/dev/video28 capabilities=0x4202000
[hevc @ 0x55558be65c40] probe_video_device: missing required mem2mem capability
[hevc @ 0x55558be65c40] Trying V4L2 devices: /dev/media2,/dev/video19
Dmabufs using Vidbuf
ctl_cma_new2: Using dma_heap device /dev/dma_heap/vidbuf_cached
[hevc @ 0x55558be65c40] Dmabufs opened - try dmabuf buffers
[hevc @ 0x55558be65c40] V4L2 HEVC stateless V4 probed successfully: driver v 0x6063e
[hevc @ 0x55558be65c40] Slots=13: Reordering=2, threads=5, hw+=-1
[hevc @ 0x55558be65c40] frame_params: avctx=0x55558be65c40 ctx=0x7fff24025090 hw_frames_ctx=0x7fff244413f0 hwfc=0x7fff24453370 pool=(nil) width=3840 height=2160 initial_pool_size=0
[hevc @ 0x55558be65c40] Failed to query ext id=0xa40a97, err=22
[hevc @ 0x55558be65c40] set_controls: Max slices 4096
[hevc @ 0x55558be65c40] set_controls: Entry point offsets 0
[hevc @ 0x55558be65c40] Hwaccel V4L2 HEVC stateless V4; devices: /dev/media2,/dev/video19; buffers: src DMABuf, dst DMABuf; swfmt=rpi4_8
[hevc @ 0x55558be65c40] v4l2_req_frame_alloc: avctx=0x55558be65c40 size=968 data=0x7fff24443890
[hevc @ 0x55558be65c40] Output frame with POC 0.
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[hevc @ 0x55558be87430] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be87430] v4l2_req_frame_alloc: avctx=0x55558be87430 size=968 data=0x7fff20017c20
[hevc @ 0x55558be87430] Output frame with POC 1.
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[hevc @ 0x55558c105be0] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c105be0] v4l2_req_frame_alloc: avctx=0x55558c105be0 size=968 data=0x7fff140270a0
[hevc @ 0x55558c105be0] Output frame with POC 2.
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[hevc @ 0x55558c1c6460] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c1c6460] v4l2_req_frame_alloc: avctx=0x55558c1c6460 size=968 data=0x7fff1801ed20
[hevc @ 0x55558c1c6460] Output frame with POC 3.
[hevc @ 0x55558c286e20] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c286e20] v4l2_req_frame_alloc: avctx=0x55558c286e20 size=968 data=0x7fff0c0295f0
[hevc @ 0x55558c286e20] Output frame with POC 4.
[graph 0 input from stream 0:0 @ 0x55558c041fb0] Setting 'video_size' to value '3840x2160'
[graph 0 input from stream 0:0 @ 0x55558c041fb0] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:0 @ 0x55558c041fb0] Setting 'time_base' to value '1/90000'
[graph 0 input from stream 0:0 @ 0x55558c041fb0] Setting 'pixel_aspect' to value '1/1'
[graph 0 input from stream 0:0 @ 0x55558c041fb0] Setting 'frame_rate' to value '60/1'
[graph 0 input from stream 0:0 @ 0x55558c041fb0] w:3840 h:2160 pixfmt:yuv420p tb:1/90000 fr:60/1 sar:1/1
[AVFilterGraph @ 0x55558be86150] query_formats: 3 queried, 2 merged, 0 already done, 0 delayed
Output #0, rawvideo, to '/dev/null':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    location        : +30.1732-097.7968/
    location-eng    : +30.1732-097.7968/
    encoder         : Lavf59.27.100
  Stream #0:0(eng), 0, 1/60: Video: rawvideo, 1 reference frame (I420 / 0x30323449), yuv420p(pc, bt709, progressive, left), 3840x2160 (0x0) [SAR 1:1 DAR 16:9], 0/1, q=2-31, 5971968 kb/s, 60 fps, 60 tbn (default)
    Metadata:
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
      encoder         : Lavc59.37.100 rawvideo
Clipping frame in rate conversion by 0.000008
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[hevc @ 0x55558be65c40] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be65c40] v4l2_req_frame_alloc: avctx=0x55558be65c40 size=968 data=0x7fff24452000
[hevc @ 0x55558be65c40] Output frame with POC 5.
v4l2_req_frame_free: avctx=0x55558be65c40 data=0x7fff24443890
[hevc @ 0x55558be87430] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be87430] v4l2_req_frame_alloc: avctx=0x55558be87430 size=968 data=0x7fff20000b70
[hevc @ 0x55558be87430] Output frame with POC 6.
v4l2_req_frame_free: avctx=0x55558be87430 data=0x7fff20017c20
[hevc @ 0x55558c105be0] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c105be0] v4l2_req_frame_alloc: avctx=0x55558c105be0 size=968 data=0x7fff14028220
[hevc @ 0x55558c105be0] Output frame with POC 7.
v4l2_req_frame_free: avctx=0x55558c105be0 data=0x7fff140270a0
[hevc @ 0x55558c1c6460] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c1c6460] v4l2_req_frame_alloc: avctx=0x55558c1c6460 size=968 data=0x7fff18000bb0
[hevc @ 0x55558c1c6460] Output frame with POC 8.
v4l2_req_frame_free: avctx=0x55558c1c6460 data=0x7fff1801ed20
[hevc @ 0x55558c286e20] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c286e20] v4l2_req_frame_alloc: avctx=0x55558c286e20 size=968 data=0x7fff0c02a770
[hevc @ 0x55558c286e20] Output frame with POC 9.
v4l2_req_frame_free: avctx=0x55558c286e20 data=0x7fff0c0295f0
[hevc @ 0x55558be65c40] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be65c40] v4l2_req_frame_alloc: avctx=0x55558be65c40 size=968 data=0x7fff24451930
[hevc @ 0x55558be65c40] Output frame with POC 10.
v4l2_req_frame_free: avctx=0x55558be65c40 data=0x7fff24452000
[hevc @ 0x55558be87430] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be87430] v4l2_req_frame_alloc: avctx=0x55558be87430 size=968 data=0x7fff20018420
[hevc @ 0x55558be87430] Output frame with POC 11.
v4l2_req_frame_free: avctx=0x55558be87430 data=0x7fff20000b70
[hevc @ 0x55558c105be0] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c105be0] v4l2_req_frame_alloc: avctx=0x55558c105be0 size=968 data=0x7fff14027840
[hevc @ 0x55558c105be0] Output frame with POC 12.
v4l2_req_frame_free: avctx=0x55558c105be0 data=0x7fff14028220
[hevc @ 0x55558c1c6460] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c1c6460] v4l2_req_frame_alloc: avctx=0x55558c1c6460 size=968 data=0x7fff1801f4c0
[hevc @ 0x55558c1c6460] Output frame with POC 13.
v4l2_req_frame_free: avctx=0x55558c1c6460 data=0x7fff18000bb0
[hevc @ 0x55558c286e20] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c286e20] v4l2_req_frame_alloc: avctx=0x55558c286e20 size=968 data=0x7fff0c029d90
[hevc @ 0x55558c286e20] Output frame with POC 14.
v4l2_req_frame_free: avctx=0x55558c286e20 data=0x7fff0c02a770
[hevc @ 0x55558be65c40] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be65c40] v4l2_req_frame_alloc: avctx=0x55558be65c40 size=968 data=0x7fff24452d20
[hevc @ 0x55558be65c40] Output frame with POC 15.
v4l2_req_frame_free: avctx=0x55558be65c40 data=0x7fff24451930
[hevc @ 0x55558be87430] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be87430] v4l2_req_frame_alloc: avctx=0x55558be87430 size=968 data=0x7fff200012d0
[hevc @ 0x55558be87430] Output frame with POC 16.
v4l2_req_frame_free: avctx=0x55558be87430 data=0x7fff20018420
[hevc @ 0x55558c105be0] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c105be0] v4l2_req_frame_alloc: avctx=0x55558c105be0 size=968 data=0x7fff14028220
[hevc @ 0x55558c105be0] Output frame with POC 17.
v4l2_req_frame_free: avctx=0x55558c105be0 data=0x7fff14027840
[hevc @ 0x55558c1c6460] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c1c6460] v4l2_req_frame_alloc: avctx=0x55558c1c6460 size=968 data=0x7fff18000b70
[hevc @ 0x55558c1c6460] Output frame with POC 18.
v4l2_req_frame_free: avctx=0x55558c1c6460 data=0x7fff1801f4c0
[hevc @ 0x55558c286e20] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c286e20] v4l2_req_frame_alloc: avctx=0x55558c286e20 size=968 data=0x7fff0c02a770
[hevc @ 0x55558c286e20] Output frame with POC 19.
v4l2_req_frame_free: avctx=0x55558c286e20 data=0x7fff0c029d90
[hevc @ 0x55558be65c40] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be65c40] v4l2_req_frame_alloc: avctx=0x55558be65c40 size=968 data=0x7fff24451930
[hevc @ 0x55558be65c40] Output frame with POC 20.
v4l2_req_frame_free: avctx=0x55558be65c40 data=0x7fff24452d20
[hevc @ 0x55558be87430] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be87430] v4l2_req_frame_alloc: avctx=0x55558be87430 size=968 data=0x7fff20018420
[hevc @ 0x55558be87430] Output frame with POC 21.
v4l2_req_frame_free: avctx=0x55558be87430 data=0x7fff200012d0
[hevc @ 0x55558c105be0] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c105be0] v4l2_req_frame_alloc: avctx=0x55558c105be0 size=968 data=0x7fff14027840
[hevc @ 0x55558c105be0] Output frame with POC 22.
v4l2_req_frame_free: avctx=0x55558c105be0 data=0x7fff14028220
[hevc @ 0x55558c1c6460] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c1c6460] v4l2_req_frame_alloc: avctx=0x55558c1c6460 size=968 data=0x7fff1801f4c0
[hevc @ 0x55558c1c6460] Output frame with POC 23.
v4l2_req_frame_free: avctx=0x55558c1c6460 data=0x7fff18000b70
[hevc @ 0x55558c286e20] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c286e20] v4l2_req_frame_alloc: avctx=0x55558c286e20 size=968 data=0x7fff0c029d90
[hevc @ 0x55558c286e20] Output frame with POC 24.
v4l2_req_frame_free: avctx=0x55558c286e20 data=0x7fff0c02a770
[hevc @ 0x55558be65c40] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be65c40] v4l2_req_frame_alloc: avctx=0x55558be65c40 size=968 data=0x7fff24452d20
[hevc @ 0x55558be65c40] Output frame with POC 25.
v4l2_req_frame_free: avctx=0x55558be65c40 data=0x7fff24451930
[hevc @ 0x55558be87430] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be87430] v4l2_req_frame_alloc: avctx=0x55558be87430 size=968 data=0x7fff200012d0
[hevc @ 0x55558be87430] Output frame with POC 26.
v4l2_req_frame_free: avctx=0x55558be87430 data=0x7fff20018420
[hevc @ 0x55558c105be0] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c105be0] v4l2_req_frame_alloc: avctx=0x55558c105be0 size=968 data=0x7fff14028220
[hevc @ 0x55558c105be0] Output frame with POC 27.
v4l2_req_frame_free: avctx=0x55558c105be0 data=0x7fff14027840
[hevc @ 0x55558c1c6460] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c1c6460] v4l2_req_frame_alloc: avctx=0x55558c1c6460 size=968 data=0x7fff18000b70
[hevc @ 0x55558c1c6460] Output frame with POC 28.
v4l2_req_frame_free: avctx=0x55558c1c6460 data=0x7fff1801f4c0
[hevc @ 0x55558c286e20] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558c286e20] v4l2_req_frame_alloc: avctx=0x55558c286e20 size=968 data=0x7fff0c02a770
[hevc @ 0x55558c286e20] Output frame with POC 29.
v4l2_req_frame_free: avctx=0x55558c286e20 data=0x7fff0c029d90
[hevc @ 0x55558be65c40] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55558be65c40] v4l2_req_frame_alloc: avctx=0x55558be65c40 size=968 data=0x7fff24451930
[hevc @ 0x55558be65c40] Output frame with POC 30.
v4l2_req_frame_free: avctx=0x55558be65c40 data=0x7fff24452d20itrate=5967208.6kbits/s speed=0.821x

Does the snap not have some necessary permission perhaps?

Edit: Inside the snap

I tested with a file both inside and outside the snap. And I got the same output at both places. I tested it with a sample 4k hvec file. Can you kindly share the file with us, that you’re trying to use?

Thanks for your reply. Here’s the sample video I’m using: https://drive.google.com/file/d/1UZ1VLQyb3gQPdp9142ZWBoLpryFArX7h/view?usp=sharing

Yep, same output from both inside and outside the snap.

Perhaps the issue is due to the build of ffmpeg outside of the snap having some Pi specific changes https://github.com/jc-kynesim/rpi-ffmpeg (more details is this thread https://github.com/jc-kynesim/rpi-ffmpeg/issues/80)?

If I need to use that build inside my snap, it wouldn’t play nicely with gpu-2404 right? And so I’d need to bundle mesa? Would my best bet be to deploy my software without using snap? Edit: Or rather, less drastically, video decoding with something like V4L2 directly rather than through ffmpeg?

We can incorporate rpi-ffmpeg inside our snap itself. Can you help us to understand things on the rpi side? What are the patches made, are they binary compatible or source compatible?

I’m sorry I don’t know the answers to those questions :frowning: I’m not familiar with their project

1 Like