MSD Paul
MSD Paul

Reputation: 1678

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

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?

Upvotes: 7

Views: 29771

Answers (3)

Pierz
Pierz

Reputation: 8118

The version of ffmpeg available from apt now has hardware codecs so you can just install that using:

apt install ffmpeg

You can verify their presence like this:

ffmpeg -codecs | grep 'h264_omx\|h264_v4l2m2m'

There are two ways to use the hardware codec - either by using the newer h264_v4l2m2m or the h264_omx OMX based one.

Note: The gpu_mem setting in /boot/config.txt needs to be greater than 16 - otherwise you will get an error with both codecs.

Upvotes: 2

maxlinux2000
maxlinux2000

Reputation: 39

Please try the ARMv6 NEON capability of raspberrypi4 with this simple command

ffmpeg -i 4k-input.mp4  -vf scale=-1:360  360p-output.mp4

don't add nothing!

Upvotes: -1

Markus Schumann
Markus Schumann

Reputation: 8254

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.

Upvotes: 7

Related Questions