Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 653386

Summary: media-video/ffmpeg - add USE="omx omx-rpi"
Product: Gentoo Linux Reporter: aeriksson2
Component: Current packagesAssignee: Gentoo Media-video project <media-video>
Status: UNCONFIRMED ---    
Severity: normal CC: crabbedhaloablution, gentoo, neddyseagoon, sam
Priority: Normal    
Version: unspecified   
Hardware: ARM   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description aeriksson2 2018-04-17 15:03:30 UTC
FFMpeg now has support for omx (hw encoding of h264) on raspberryPis. This patch exposes it.

--- /var/cache/portage/media-video/ffmpeg/ffmpeg-3.3.6.ebuild   2018-03-12 09:09:01.000000000 +0100
+++ media-video/ffmpeg/ffmpeg-3.3.6.ebuild      2018-02-24 13:22:35.793849271 +0100
@@ -54,7 +54,7 @@
        samba? ( GPL-3 )
 "
 if [ "${PV#9999}" = "${PV}" ] ; then
-       KEYWORDS="amd64 arm ~arm64 ~hppa ia64 ~mips ppc ppc64 x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris"
+       KEYWORDS="amd64 arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris"
 fi
 
 # Options to use as use_enable in the foo[:bar] form.
@@ -74,7 +74,7 @@
                # decoders
                amr:libopencore-amrwb amr:libopencore-amrnb fdk:libfdk-aac
                jpeg2k:libopenjpeg bluray:libbluray celt:libcelt gme:libgme gsm:libgsm
-               mmal modplug:libmodplug opus:libopus libilbc librtmp ssh:libssh
+               mmal omx omx-rpi modplug:libmodplug opus:libopus libilbc librtmp ssh:libssh
                schroedinger:libschroedinger speex:libspeex vorbis:libvorbis vpx:libvpx
                zvbi:libzvbi
                # libavfilter options
@@ -225,6 +225,8 @@
        libv4l? ( >=media-libs/libv4l-0.9.5[${MULTILIB_USEDEP}] )
        lzma? ( >=app-arch/xz-utils-5.0.5-r1[${MULTILIB_USEDEP}] )
        mmal? ( media-libs/raspberrypi-userland )
+       omx? ( media-libs/raspberrypi-userland )
+       omx-rpi? ( media-libs/raspberrypi-userland )
        modplug? ( >=media-libs/libmodplug-0.8.8.4-r1[${MULTILIB_USEDEP}] )
        openal? ( >=media-libs/openal-1.15.1[${MULTILIB_USEDEP}] )
        opengl? ( >=virtual/opengl-7.0-r1[${MULTILIB_USEDEP}] )
Comment 1 aeriksson2 2019-07-02 19:35:21 UTC
Bump
Comment 2 Daniel Kenzelmann 2019-12-06 11:29:06 UTC
The patched ebuild only works if you add the raspberrypi-userland include files by adding the following to make.conf:

EXTRA_FFMPEG_CONF='--extra-cflags="-I/opt/vc/include/IL"'

It might be better to add the extra include directory within the ebuild conditional on the omx/omx-rpi flags
Comment 3 Daniel Kenzelmann 2019-12-11 10:05:56 UTC
Did some further investigation, it looks like we only need to have the omx-rpi useflag for raspberry pi.
The "omx" feature is internally selected when specifying omx-rpi, when ONLY omx-rpi use flag is specified, the include directory is correctly automatically selected and added without the need of specifying anything BUT if you enabled "omx" as well in addition to omx-rpi, then it requires the OMX_Core.h to be directly accessible.

See the following excerpt from the configure script for the reason why:

enabled omx_rpi           && { test_code cc OMX_Core.h OMX_IndexConfigBrcmVideoRequestIFrame ||
                               { ! enabled cross_compile &&
                                 add_cflags -isystem/opt/vc/include/IL &&
                                 test_code cc OMX_Core.h OMX_IndexConfigBrcmVideoRequestIFrame; } ||
                               die "ERROR: OpenMAX IL headers from raspberrypi/firmware not found"; } &&
                             enable omx
enabled omx               && require_headers OMX_Core.h

We might want to make them exclusive (either omx OR omx-rpi) to avoid the situation of the compile failing due to missing OMX_Core.h headers due to "omx" being enabled in addition to "omx-rpi"
I don't see a situation where it would make sense to specify both.
Comment 4 myoung008 2021-02-17 00:40:40 UTC
This method worked for me on RPi4 (userspace is 32-bit armv6-musleabi), but with a few necessary changes:

raspberrypi-userland package no longer uses /opt/ for packages, so my modification to make.conf is:
EXTRA_FFMPEG_CONF='--extra-cflags="-I/usr/include/IL"'

Also, at runtime, ffmpeg-4.3.1 looks directly in /opt for libs. As an ugly hack, I made symlinks to /usr/lib/libbcm_host.so and /usr/lib/libopenmaxil.so.  The symlinks are needed in /opt/vc/lib.


Applicable lines in config.txt are:

gpu_mem=128
[pi4]
dtoverlay=vc4-fkms-v3d,cma-128
max_framebuffers=2