blob: e65f80d64b1b7933d7638112203db9b885a105fb [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
Andrew Geissler8f840682023-07-21 09:09:43 -050025SRC_URI = "https://www.ffmpeg.org/releases/${BP}.tar.xz \
Patrick Williams2a254922023-08-11 09:48:11 -050026 file://0001-avcodec-x86-mathops-clip-constants-used-with-shift-i.patch \
Andrew Geissler8f840682023-07-21 09:09:43 -050027 file://0001-libswscale-riscv-Fix-syntax-of-vsetvli.patch"
Andrew Geissler517393d2023-01-13 08:55:19 -060028
Patrick Williams8e7b46e2023-05-01 14:19:06 -050029SRC_URI[sha256sum] = "57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082"
Patrick Williams92b42cb2022-09-03 06:53:57 -050030
Andrew Geissler5082cc72023-09-11 08:41:39 -040031# https://nvd.nist.gov/vuln/detail/CVE-2023-39018
32# https://github.com/bramp/ffmpeg-cli-wrapper/issues/291
33# https://security-tracker.debian.org/tracker/CVE-2023-39018
34# https://bugzilla.suse.com/show_bug.cgi?id=CVE-2023-39018
35CVE_STATUS[CVE-2023-39018] = "cpe-incorrect: This issue belongs to ffmpeg-cli-wrapper \
36(Java wrapper around the FFmpeg CLI) and not ffmepg itself."
37
Patrick Williams92b42cb2022-09-03 06:53:57 -050038# Build fails when thumb is enabled: https://bugzilla.yoctoproject.org/show_bug.cgi?id=7717
39ARM_INSTRUCTION_SET:armv4 = "arm"
40ARM_INSTRUCTION_SET:armv5 = "arm"
41ARM_INSTRUCTION_SET:armv6 = "arm"
42
43# Should be API compatible with libav (which was a fork of ffmpeg)
44# libpostproc was previously packaged from a separate recipe
45PROVIDES = "libav libpostproc"
46
47DEPENDS = "nasm-native"
48
49inherit autotools pkgconfig
50
51PACKAGECONFIG ??= "avdevice avfilter avcodec avformat swresample swscale postproc \
Andrew Geissler3eeda902023-05-19 10:14:02 -050052 alsa bzlib lzma theora zlib \
Patrick Williams92b42cb2022-09-03 06:53:57 -050053 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'xv xcb', '', d)}"
54
55# libraries to build in addition to avutil
56PACKAGECONFIG[avdevice] = "--enable-avdevice,--disable-avdevice"
57PACKAGECONFIG[avfilter] = "--enable-avfilter,--disable-avfilter"
58PACKAGECONFIG[avcodec] = "--enable-avcodec,--disable-avcodec"
59PACKAGECONFIG[avformat] = "--enable-avformat,--disable-avformat"
60PACKAGECONFIG[swresample] = "--enable-swresample,--disable-swresample"
61PACKAGECONFIG[swscale] = "--enable-swscale,--disable-swscale"
62PACKAGECONFIG[postproc] = "--enable-postproc,--disable-postproc"
63
64# features to support
65PACKAGECONFIG[alsa] = "--enable-alsa,--disable-alsa,alsa-lib"
66PACKAGECONFIG[altivec] = "--enable-altivec,--disable-altivec,"
67PACKAGECONFIG[bzlib] = "--enable-bzlib,--disable-bzlib,bzip2"
68PACKAGECONFIG[fdk-aac] = "--enable-libfdk-aac --enable-nonfree,--disable-libfdk-aac,fdk-aac"
69PACKAGECONFIG[gpl] = "--enable-gpl,--disable-gpl"
70PACKAGECONFIG[gsm] = "--enable-libgsm,--disable-libgsm,libgsm"
71PACKAGECONFIG[jack] = "--enable-indev=jack,--disable-indev=jack,jack"
72PACKAGECONFIG[libopus] = "--enable-libopus,--disable-libopus,libopus"
73PACKAGECONFIG[libvorbis] = "--enable-libvorbis,--disable-libvorbis,libvorbis"
74PACKAGECONFIG[lzma] = "--enable-lzma,--disable-lzma,xz"
75PACKAGECONFIG[mfx] = "--enable-libmfx,--disable-libmfx,intel-mediasdk"
76PACKAGECONFIG[mp3lame] = "--enable-libmp3lame,--disable-libmp3lame,lame"
77PACKAGECONFIG[openssl] = "--enable-openssl,--disable-openssl,openssl"
78PACKAGECONFIG[sdl2] = "--enable-sdl2,--disable-sdl2,virtual/libsdl2"
79PACKAGECONFIG[speex] = "--enable-libspeex,--disable-libspeex,speex"
80PACKAGECONFIG[srt] = "--enable-libsrt,--disable-libsrt,srt"
81PACKAGECONFIG[theora] = "--enable-libtheora,--disable-libtheora,libtheora libogg"
Andrew Geissler3eeda902023-05-19 10:14:02 -050082PACKAGECONFIG[v4l2] = "--enable-libv4l2,--disable-libv4l2,v4l-utils"
Patrick Williams92b42cb2022-09-03 06:53:57 -050083PACKAGECONFIG[vaapi] = "--enable-vaapi,--disable-vaapi,libva"
84PACKAGECONFIG[vdpau] = "--enable-vdpau,--disable-vdpau,libvdpau"
85PACKAGECONFIG[vpx] = "--enable-libvpx,--disable-libvpx,libvpx"
86PACKAGECONFIG[x264] = "--enable-libx264,--disable-libx264,x264"
87PACKAGECONFIG[x265] = "--enable-libx265,--disable-libx265,x265"
88PACKAGECONFIG[xcb] = "--enable-libxcb,--disable-libxcb,libxcb"
89PACKAGECONFIG[xv] = "--enable-outdev=xv,--disable-outdev=xv,libxv"
90PACKAGECONFIG[zlib] = "--enable-zlib,--disable-zlib,zlib"
91
Patrick Williams92b42cb2022-09-03 06:53:57 -050092# Check codecs that require --enable-nonfree
93USE_NONFREE = "${@bb.utils.contains_any('PACKAGECONFIG', [ 'openssl' ], 'yes', '', d)}"
94
95def cpu(d):
96 for arg in (d.getVar('TUNE_CCARGS') or '').split():
97 if arg.startswith('-mcpu='):
98 return arg[6:]
99 return 'generic'
100
101EXTRA_OECONF = " \
Andrew Geissler3eeda902023-05-19 10:14:02 -0500102 --disable-stripping \
103 --enable-pic \
104 --enable-shared \
105 --enable-pthreads \
Patrick Williams92b42cb2022-09-03 06:53:57 -0500106 ${@bb.utils.contains('USE_NONFREE', 'yes', '--enable-nonfree', '', d)} \
107 \
108 --cross-prefix=${TARGET_PREFIX} \
109 \
110 --ld='${CCLD}' \
111 --cc='${CC}' \
112 --cxx='${CXX}' \
113 --arch=${TARGET_ARCH} \
114 --target-os='linux' \
115 --enable-cross-compile \
116 --extra-cflags='${CFLAGS} ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}' \
117 --extra-ldflags='${LDFLAGS}' \
118 --sysroot='${STAGING_DIR_TARGET}' \
119 ${EXTRA_FFCONF} \
120 --libdir=${libdir} \
121 --shlibdir=${libdir} \
122 --datadir=${datadir}/ffmpeg \
Andrew Geissler3eeda902023-05-19 10:14:02 -0500123 ${@bb.utils.contains('AVAILTUNES', 'mips32r2', '', '--disable-mipsdsp --disable-mipsdspr2', d)} \
Patrick Williams92b42cb2022-09-03 06:53:57 -0500124 --cpu=${@cpu(d)} \
125 --pkg-config=pkg-config \
126"
127
128EXTRA_OECONF:append:linux-gnux32 = " --disable-asm"
129
130EXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mipsisa64r6', '--disable-mips64r2 --disable-mips32r2', '', d)}"
131EXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mipsisa64r2', '--disable-mips64r6 --disable-mips32r6', '', d)}"
132EXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mips32r2', '--disable-mips64r6 --disable-mips32r6', '', d)}"
133EXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mips32r6', '--disable-mips64r2 --disable-mips32r2', '', d)}"
134EXTRA_OECONF:append:mips = " --extra-libs=-latomic --disable-mips32r5 --disable-mipsdsp --disable-mipsdspr2 \
135 --disable-loongson2 --disable-loongson3 --disable-mmi --disable-msa"
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500136EXTRA_OECONF:append:riscv32 = " --extra-libs=-latomic --disable-rvv --disable-asm"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500137EXTRA_OECONF:append:armv5 = " --extra-libs=-latomic"
138EXTRA_OECONF:append:powerpc = " --extra-libs=-latomic"
Andrew Geissler5082cc72023-09-11 08:41:39 -0400139EXTRA_OECONF:append:armv7a = "${@bb.utils.contains('TUNE_FEATURES','neon','',' --disable-neon',d)}"
140EXTRA_OECONF:append:armv7ve = "${@bb.utils.contains('TUNE_FEATURES','neon','',' --disable-neon',d)}"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500141
142# gold crashes on x86, another solution is to --disable-asm but thats more hacky
143# ld.gold: internal error in relocate_section, at ../../gold/i386.cc:3684
144
145LDFLAGS:append:x86 = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd ', '', d)}"
Patrick Williams2a254922023-08-11 09:48:11 -0500146LDFLAGS:append:x86 = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', ' -fuse-ld=bfd ', '', d)}"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500147
148EXTRA_OEMAKE = "V=1"
149
150do_configure() {
Patrick Williams864cc432023-02-09 14:54:44 -0600151 export TMPDIR="${B}/tmp"
152 mkdir -p ${B}/tmp
Patrick Williams92b42cb2022-09-03 06:53:57 -0500153 ${S}/configure ${EXTRA_OECONF}
Andrew Geissler517393d2023-01-13 08:55:19 -0600154 sed -i -e "s,^X86ASMFLAGS=.*,& --debug-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} --debug-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR},g" ${B}/ffbuild/config.mak
Patrick Williams92b42cb2022-09-03 06:53:57 -0500155}
156
157# patch out build host paths for reproducibility
158do_compile:prepend:class-target() {
159 sed -i -e "s,${WORKDIR},,g" ${B}/config.h
160}
161
162PACKAGES =+ "libavcodec \
163 libavdevice \
164 libavfilter \
165 libavformat \
166 libavutil \
167 libpostproc \
168 libswresample \
169 libswscale"
170
171FILES:libavcodec = "${libdir}/libavcodec${SOLIBS}"
172FILES:libavdevice = "${libdir}/libavdevice${SOLIBS}"
173FILES:libavfilter = "${libdir}/libavfilter${SOLIBS}"
174FILES:libavformat = "${libdir}/libavformat${SOLIBS}"
175FILES:libavutil = "${libdir}/libavutil${SOLIBS}"
176FILES:libpostproc = "${libdir}/libpostproc${SOLIBS}"
177FILES:libswresample = "${libdir}/libswresample${SOLIBS}"
178FILES:libswscale = "${libdir}/libswscale${SOLIBS}"
179
180# 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"
186INSANE_SKIP:${MLPREFIX}libswscale = "textrel"
187INSANE_SKIP:${MLPREFIX}libswresample = "textrel"
188INSANE_SKIP:${MLPREFIX}libpostproc = "textrel"