HEVC accelerator on RB3 using ffmpeg

Hello,
I am trying to decode HEVC-encoded content on RB3. I successfully compiled ffmpeg. However, I am still not able to leverage the HEVC accelerator available on RB3, which is v4l2.
Bellow are the command and the output.

root@linaro-developer:~# ffmpeg -c:v hevc_v4l2m2m -i blue_sky_fps_25.mp4 -f null /dev/null
ffmpeg version 4.3 Copyright © 2000-2020 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-gpl --enable-nonfree --enable-static --disable-shared --enable-pthreads --enable-neon --enable-thumb --enable-optimizations --enable-hwaccel=hevc_v4l2m2m
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘blue_sky_fps_25.mp4’:
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf58.29.100
Duration: 00:00:08.68, start: 0.000000, bitrate: 2834 kb/s
Stream #0:0(und): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv), 1920x1080, 2832 kb/s, 25 fps, 25 tbr, 1200k tbn, 25 tbc (default)
Metadata:
handler_name : VideoHandler
[hevc_v4l2m2m @ 0xaaaad0d20d60] Using device /dev/video1
[hevc_v4l2m2m @ 0xaaaad0d20d60] driver ‘qcom-venus’ on card ‘Qualcomm Venus video decoder’ in mplane mode
[hevc_v4l2m2m @ 0xaaaad0d20d60] requesting formats: output=HEVC capture=NV12
Stream mapping:
Stream #0:0 -> #0:0 (hevc (hevc_v4l2m2m) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
[hevc_v4l2m2m @ 0xaaaad0d20d60] VIDIOC_G_FMT ioctl
free(): double free detected in tcache 2
Aborted

Could you help me to solve the issue?

Thank you in advance.
Best regards

Did you try with a gstreamer pipeline? Maybe @svarbanov knows what’s going wrong with ffmpeg. Please also indicate the release you’re running on your board.

Yes, I already tried Gstreamer. It does not support HEVC acceleration.
I am running ffmpeg 4.3 (stable version: https://ffmpeg.org/releases/ffmpeg-4.3.tar.bz2)

Below is the environment I am running on:
root@linaro-developer:~# uname -a
Linux linaro-developer 5.4.0-qcomlt-arm64 #90 SMP PREEMPT Wed Feb 12 19:09:17 UTC 2020 aarch64 GNU/Linux

Hi again,
I tried an old version of ffmpeg (3.4.7). Now, I am able to do decoding. However, when I try to decode a video sequence at 4K, ffmpeg is not able to decode in real-time, i.e., at the frame-rate at which the video is encoded.
I tried a video sequence encoded at 25 Hz. So, I am expecting that ffmpeg can decode it at 25 fps using the HEVC accelerator.
Am I missing something in the command line or in the environment?

Below are the command and the output:

root@linaro-developer:~/vary_resolution/kimono# ffmpeg -i AMP_D_Hisilicon_3_2160p_fps_25.265 -c:v hevc_v4l2m2m -f null out.null
ffmpeg version 3.4.7 Copyright © 2000-2019 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-gpl --enable-nonfree --enable-static --disable-shared --enable-pthreads --enable-neon --enable-thumb --enable-optimizations --enable-hwaccel=v4l2
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[hevc @ 0xaaaade035390] missing picture in access unit
Input #0, hevc, from ‘AMP_D_Hisilicon_3_2160p_fps_25.265’:
Duration: N/A, bitrate: N/A
Stream #0:0: Video: hevc (Main), yuv420p(tv), 3840x2160, 25 fps, 25 tbr, 1200k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (hevc (native) -> hevc (hevc_v4l2m2m))
Press [q] to stop, [?] for help
[hevc_v4l2m2m @ 0xaaaade08fa70] driver ‘qcom-venus’ on card ‘Qualcomm Venus video decoder’
[hevc_v4l2m2m @ 0xaaaade08fa70] driver ‘qcom-venus’ on card ‘Qualcomm Venus video encoder’
[hevc_v4l2m2m @ 0xaaaade08fa70] Using device /dev/video1
[hevc_v4l2m2m @ 0xaaaade08fa70] driver ‘qcom-venus’ on card ‘Qualcomm Venus video encoder’
Output #0, null, to ‘out.null’:
Metadata:
encoder : Lavf57.83.100
Stream #0:0: Video: hevc (hevc_v4l2m2m), yuv420p, 3840x2160, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc57.107.100 hevc_v4l2m2m
[hevc_v4l2m2m @ 0xaaaade08fa70] output POLLERR
frame= 100 fps=8.5 q=-0.0 Lsize=N/A time=00:00:03.96 bitrate=N/A speed=0.335x
video:434kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Hello again,
The problem is resolved. Below is the procedure:

1- install v4l2 library
apt-get install libv4l-dev

2- dowload ffmpeg (4.3 stable version)
tar -xvjf ffmpeg-4.3.tar.bz2

3- download the patch that fixes an issue existing on ffmpeg project:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200509173541.7667-1-andriy.gelman@gmail.com/

4- apply the patch:
git apply -v <file.patch>

5- add “–enable-libv4l2” option to “./configure”

6- make && make install

Best regards

1 Like