How to enable hardware support for H.264 encoding on raspberry Pi 4B

MSD Paul picture MSD Paul · Mar 4, 2020 · Viewed 9.4k times · Source

I am trying to enable the hardware support for H264 encoding on raspberry pi 4B model. Compiling FFmpeg source enabling the configurations

sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree

following the link, https://github.com/legotheboss/YouTube-files/wiki/(RPi)-Compile-FFmpeg-with-the-OpenMAX-H.264-GPU-acceleration

but while executing the encoding command after building and installing the ffmpeg with those configuration properly, I am getting the following error

[h264_omx @ 0x156b6e0] Using OMX.broadcom.video_encode
[h264_omx @ 0x156b6e0] OMX error 80001000
[h264_omx @ 0x156b6e0] err 80001018 (-2147479528) on line 561
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!

command used:

ffmpeg -i /media/pi/pic_1_org.png -c:v h264_omx -c:a copy -b:v 1500k outputfile.mp4

I just want to encode a single 4K image into a .mp4 file using H.264 encoder. Please let me know how to resolve this issue?

Answer

Markus Schumann picture Markus Schumann · Mar 5, 2020

The hardware H.264 encoder on the Raspberry Pi 4 supports only resolutions of 1920x1080 or lower. So there is no hardware support for 4k encoding.