blob: bf8d4b824ceb4708e3040c896266488fdc69b7f6 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001SUMMARY = "A complete, cross-platform solution to record, convert and stream audio and video."
2DESCRIPTION = "FFmpeg is the leading multimedia framework, able to decode, encode, transcode, \
3 mux, demux, stream, filter and play pretty much anything that humans and machines \
4 have created. It supports the most obscure ancient formats up to the cutting edge."
5HOMEPAGE = "https://www.ffmpeg.org/"
6SECTION = "libs"
7
8LICENSE = "GPL-2.0-or-later & LGPL-2.1-or-later & ISC & MIT & BSD-2-Clause & BSD-3-Clause & IJG"
9LICENSE:${PN} = "GPL-2.0-or-later"
10LICENSE:libavcodec = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}"
11LICENSE:libavdevice = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}"
12LICENSE:libavfilter = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}"
13LICENSE:libavformat = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}"
14LICENSE:libavutil = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}"
15LICENSE:libpostproc = "GPL-2.0-or-later"
16LICENSE:libswresample = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}"
17LICENSE:libswscale = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}"
18LICENSE_FLAGS = "commercial"
19
20LIC_FILES_CHKSUM = "file://COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
21 file://COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \
22 file://COPYING.LGPLv2.1;md5=bd7a443320af8c812e4c18d1b79df004 \
23 file://COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02"
24
Patrick Williams92b42cb2022-09-03 06:53:57 -050025# Build fails when thumb is enabled: https://bugzilla.yoctoproject.org/show_bug.cgi?id=7717
Andrew Geissler87f5cff2022-09-30 13:13:31 -050026ARM_INSTRUCTION_SET_armv4 = "arm"
27ARM_INSTRUCTION_SET_armv5 = "arm"
28ARM_INSTRUCTION_SET_armv6 = "arm"
Patrick Williams92b42cb2022-09-03 06:53:57 -050029# Should be API compatible with libav (which was a fork of ffmpeg)
30# libpostproc was previously packaged from a separate recipe
Andrew Geissler87f5cff2022-09-30 13:13:31 -050031PROVIDES = "ffmpeg libav libpostproc"
32RPROVIDES:${PN} = "${PROVIDES}"
Patrick Williams92b42cb2022-09-03 06:53:57 -050033DEPENDS = "nasm-native"
34
35inherit autotools pkgconfig
Andrew Geissler87f5cff2022-09-30 13:13:31 -050036PACKAGECONFIG ??= "avdevice avfilter avcodec avformat swresample swscale postproc avresample \
37 opengl udev sdl2 ffplay alsa bzlib lzma pic pthreads shared theora zlib \
38 libvorbis x264 gpl sand rpi vout-drm vout-egl \
39 ${@bb.utils.contains('MACHINE_FEATURES', 'vc4graphics', '', 'mmal', d)} \
Patrick Williams92b42cb2022-09-03 06:53:57 -050040 ${@bb.utils.contains('AVAILTUNES', 'mips32r2', 'mips32r2', '', d)} \
41 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'xv xcb', '', d)}"
42
Andrew Geissler87f5cff2022-09-30 13:13:31 -050043SRC_URI = "\
44 git://git@github.com/RPi-Distro/ffmpeg;protocol=https;branch=pios/bullseye \
45 file://0001-avcodec-arm-sbcenc-avoid-callee-preserved-vfp-regist.patch \
46 file://0002-Fix-build-on-powerpc-and-ppc64.patch \
47 file://0003-avcodec-pngenc-remove-monowhite-from-apng-formats.patch \
48 file://0004-ffmpeg-4.3.2-rpi_10.patch \
49 file://0005-fix_flags.diff \
50"
51
52SRCREV = "ea72093f350f38edcd39c480b331c3219c377642"
53
54S = "${WORKDIR}/git"
55
Patrick Williams92b42cb2022-09-03 06:53:57 -050056# libraries to build in addition to avutil
57PACKAGECONFIG[avdevice] = "--enable-avdevice,--disable-avdevice"
58PACKAGECONFIG[avfilter] = "--enable-avfilter,--disable-avfilter"
59PACKAGECONFIG[avcodec] = "--enable-avcodec,--disable-avcodec"
60PACKAGECONFIG[avformat] = "--enable-avformat,--disable-avformat"
61PACKAGECONFIG[swresample] = "--enable-swresample,--disable-swresample"
62PACKAGECONFIG[swscale] = "--enable-swscale,--disable-swscale"
63PACKAGECONFIG[postproc] = "--enable-postproc,--disable-postproc"
Andrew Geissler87f5cff2022-09-30 13:13:31 -050064PACKAGECONFIG[avresample] = "--enable-avresample,--disable-avresample"
Patrick Williams92b42cb2022-09-03 06:53:57 -050065
66# features to support
Andrew Geissler87f5cff2022-09-30 13:13:31 -050067PACKAGECONFIG[ffplay] = "--enable-ffplay,--disable-ffplay"
Patrick Williams92b42cb2022-09-03 06:53:57 -050068PACKAGECONFIG[alsa] = "--enable-alsa,--disable-alsa,alsa-lib"
69PACKAGECONFIG[altivec] = "--enable-altivec,--disable-altivec,"
70PACKAGECONFIG[bzlib] = "--enable-bzlib,--disable-bzlib,bzip2"
71PACKAGECONFIG[fdk-aac] = "--enable-libfdk-aac --enable-nonfree,--disable-libfdk-aac,fdk-aac"
72PACKAGECONFIG[gpl] = "--enable-gpl,--disable-gpl"
Andrew Geissler87f5cff2022-09-30 13:13:31 -050073PACKAGECONFIG[opengl] = "--enable-opengl,--disable-opengl,virtual/libgl"
Patrick Williams92b42cb2022-09-03 06:53:57 -050074PACKAGECONFIG[gsm] = "--enable-libgsm,--disable-libgsm,libgsm"
75PACKAGECONFIG[jack] = "--enable-indev=jack,--disable-indev=jack,jack"
Patrick Williams92b42cb2022-09-03 06:53:57 -050076PACKAGECONFIG[libvorbis] = "--enable-libvorbis,--disable-libvorbis,libvorbis"
Andrew Geissler87f5cff2022-09-30 13:13:31 -050077PACKAGECONFIG[libopus] = "--enable-libopus,--disable-libopus,libopus"
Patrick Williams92b42cb2022-09-03 06:53:57 -050078PACKAGECONFIG[lzma] = "--enable-lzma,--disable-lzma,xz"
79PACKAGECONFIG[mfx] = "--enable-libmfx,--disable-libmfx,intel-mediasdk"
80PACKAGECONFIG[mp3lame] = "--enable-libmp3lame,--disable-libmp3lame,lame"
81PACKAGECONFIG[openssl] = "--enable-openssl,--disable-openssl,openssl"
82PACKAGECONFIG[sdl2] = "--enable-sdl2,--disable-sdl2,virtual/libsdl2"
83PACKAGECONFIG[speex] = "--enable-libspeex,--disable-libspeex,speex"
84PACKAGECONFIG[srt] = "--enable-libsrt,--disable-libsrt,srt"
85PACKAGECONFIG[theora] = "--enable-libtheora,--disable-libtheora,libtheora libogg"
86PACKAGECONFIG[vaapi] = "--enable-vaapi,--disable-vaapi,libva"
87PACKAGECONFIG[vdpau] = "--enable-vdpau,--disable-vdpau,libvdpau"
88PACKAGECONFIG[vpx] = "--enable-libvpx,--disable-libvpx,libvpx"
89PACKAGECONFIG[x264] = "--enable-libx264,--disable-libx264,x264"
Patrick Williams92b42cb2022-09-03 06:53:57 -050090PACKAGECONFIG[xcb] = "--enable-libxcb,--disable-libxcb,libxcb"
91PACKAGECONFIG[xv] = "--enable-outdev=xv,--disable-outdev=xv,libxv"
92PACKAGECONFIG[zlib] = "--enable-zlib,--disable-zlib,zlib"
Andrew Geissler87f5cff2022-09-30 13:13:31 -050093#PACKAGECONFIG[snappy] = "--enable-libsnappy,--enable-libsnappy,snappy"
94PACKAGECONFIG[udev] = "--enable-libudev,--disable-libudev,udev"
95PACKAGECONFIG[v4l2] = "--enable-libv4l2 --enable-v4l2-request --enable-libdrm,,v4l-utils"
96PACKAGECONFIG[mmal] = "--enable-omx --enable-omx-rpi --enable-mmal,,userland"
97PACKAGECONFIG[sand] = "--enable-sand,,"
98PACKAGECONFIG[rpi] = "--enable-rpi,,"
99PACKAGECONFIG[vout-drm] = "--enable-vout-drm,,libdrm"
100PACKAGECONFIG[vout-egl] = "--enable-vout-egl,,virtual/egl"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500101
102# other configuration options
103PACKAGECONFIG[mips32r2] = ",--disable-mipsdsp --disable-mipsdspr2"
104PACKAGECONFIG[pic] = "--enable-pic"
105PACKAGECONFIG[pthreads] = "--enable-pthreads,--disable-pthreads"
106PACKAGECONFIG[shared] = "--enable-shared"
107PACKAGECONFIG[strip] = ",--disable-stripping"
108
109# Check codecs that require --enable-nonfree
110USE_NONFREE = "${@bb.utils.contains_any('PACKAGECONFIG', [ 'openssl' ], 'yes', '', d)}"
111
112def cpu(d):
113 for arg in (d.getVar('TUNE_CCARGS') or '').split():
114 if arg.startswith('-mcpu='):
115 return arg[6:]
116 return 'generic'
117
118EXTRA_OECONF = " \
119 ${@bb.utils.contains('USE_NONFREE', 'yes', '--enable-nonfree', '', d)} \
120 \
121 --cross-prefix=${TARGET_PREFIX} \
122 \
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500123 --ld="${CCLD}" \
124 --cc="${CC}" \
125 --cxx="${CXX}" \
Patrick Williams92b42cb2022-09-03 06:53:57 -0500126 --arch=${TARGET_ARCH} \
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500127 --target-os="linux" \
Patrick Williams92b42cb2022-09-03 06:53:57 -0500128 --enable-cross-compile \
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500129 --extra-cflags="${CFLAGS} ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" \
130 --extra-ldflags="${LDFLAGS}" \
131 --sysroot="${STAGING_DIR_TARGET}" \
Patrick Williams92b42cb2022-09-03 06:53:57 -0500132 ${EXTRA_FFCONF} \
133 --libdir=${libdir} \
134 --shlibdir=${libdir} \
135 --datadir=${datadir}/ffmpeg \
136 --cpu=${@cpu(d)} \
137 --pkg-config=pkg-config \
138"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500139EXTRA_OECONF:append:linux-gnux32 = " --disable-asm"
140
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500141# Directly specify the include directories the contain headers for
142# libdrm
143# openmaxil
144TARGET_CFLAGS:append = " -I${STAGING_INCDIR}/IL -I${STAGING_INCDIR}/drm"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500145
146# gold crashes on x86, another solution is to --disable-asm but thats more hacky
147# ld.gold: internal error in relocate_section, at ../../gold/i386.cc:3684
Patrick Williams92b42cb2022-09-03 06:53:57 -0500148LDFLAGS:append:x86 = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd ', '', d)}"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500149EXTRA_OEMAKE = "V=1"
150
151do_configure() {
152 ${S}/configure ${EXTRA_OECONF}
153}
154
155# patch out build host paths for reproducibility
156do_compile:prepend:class-target() {
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500157 sed -i -e "s,${WORKDIR},,g" ${B}/config.h
Patrick Williams92b42cb2022-09-03 06:53:57 -0500158}
159
160PACKAGES =+ "libavcodec \
161 libavdevice \
162 libavfilter \
163 libavformat \
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500164 libavresample \
Patrick Williams92b42cb2022-09-03 06:53:57 -0500165 libavutil \
166 libpostproc \
167 libswresample \
168 libswscale"
169
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500170FILES:${PN}:append = " /usr/share/ffmpeg"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500171FILES:libavcodec = "${libdir}/libavcodec${SOLIBS}"
172FILES:libavdevice = "${libdir}/libavdevice${SOLIBS}"
173FILES:libavfilter = "${libdir}/libavfilter${SOLIBS}"
174FILES:libavformat = "${libdir}/libavformat${SOLIBS}"
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500175FILES:libavresample = "${libdir}/libavresample${SOLIBS}"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500176FILES:libavutil = "${libdir}/libavutil${SOLIBS}"
177FILES:libpostproc = "${libdir}/libpostproc${SOLIBS}"
178FILES:libswresample = "${libdir}/libswresample${SOLIBS}"
179FILES:libswscale = "${libdir}/libswscale${SOLIBS}"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500180# ffmpeg disables PIC on some platforms (e.g. x86-32)
181INSANE_SKIP:${MLPREFIX}libavcodec = "textrel"
182INSANE_SKIP:${MLPREFIX}libavdevice = "textrel"
183INSANE_SKIP:${MLPREFIX}libavfilter = "textrel"
184INSANE_SKIP:${MLPREFIX}libavformat = "textrel"
185INSANE_SKIP:${MLPREFIX}libavutil = "textrel"
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500186INSANE_SKIP:${MLPREFIX}libavresample = "textrel"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500187INSANE_SKIP:${MLPREFIX}libswscale = "textrel"
188INSANE_SKIP:${MLPREFIX}libswresample = "textrel"
189INSANE_SKIP:${MLPREFIX}libpostproc = "textrel"
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500190
191# Only enable it for rpi class of machines
192COMPATIBLE_HOST = "null"
193COMPATIBLE_HOST:rpi = "'(.*)'"
194