blob: f84d9bb6d0362df8edeab1b2e1f85ac2be4f0ab4 [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 Williams8e7b46e2023-05-01 14:19:06 -050025SRC_URI = "https://www.ffmpeg.org/releases/${BP}.tar.xz"
Andrew Geissler517393d2023-01-13 08:55:19 -060026
Patrick Williams8e7b46e2023-05-01 14:19:06 -050027SRC_URI[sha256sum] = "57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082"
Patrick Williams92b42cb2022-09-03 06:53:57 -050028
29# Build fails when thumb is enabled: https://bugzilla.yoctoproject.org/show_bug.cgi?id=7717
30ARM_INSTRUCTION_SET:armv4 = "arm"
31ARM_INSTRUCTION_SET:armv5 = "arm"
32ARM_INSTRUCTION_SET:armv6 = "arm"
33
34# Should be API compatible with libav (which was a fork of ffmpeg)
35# libpostproc was previously packaged from a separate recipe
36PROVIDES = "libav libpostproc"
37
38DEPENDS = "nasm-native"
39
40inherit autotools pkgconfig
41
42PACKAGECONFIG ??= "avdevice avfilter avcodec avformat swresample swscale postproc \
Andrew Geissler3eeda902023-05-19 10:14:02 -050043 alsa bzlib lzma theora zlib \
Patrick Williams92b42cb2022-09-03 06:53:57 -050044 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'xv xcb', '', d)}"
45
46# libraries to build in addition to avutil
47PACKAGECONFIG[avdevice] = "--enable-avdevice,--disable-avdevice"
48PACKAGECONFIG[avfilter] = "--enable-avfilter,--disable-avfilter"
49PACKAGECONFIG[avcodec] = "--enable-avcodec,--disable-avcodec"
50PACKAGECONFIG[avformat] = "--enable-avformat,--disable-avformat"
51PACKAGECONFIG[swresample] = "--enable-swresample,--disable-swresample"
52PACKAGECONFIG[swscale] = "--enable-swscale,--disable-swscale"
53PACKAGECONFIG[postproc] = "--enable-postproc,--disable-postproc"
54
55# features to support
56PACKAGECONFIG[alsa] = "--enable-alsa,--disable-alsa,alsa-lib"
57PACKAGECONFIG[altivec] = "--enable-altivec,--disable-altivec,"
58PACKAGECONFIG[bzlib] = "--enable-bzlib,--disable-bzlib,bzip2"
59PACKAGECONFIG[fdk-aac] = "--enable-libfdk-aac --enable-nonfree,--disable-libfdk-aac,fdk-aac"
60PACKAGECONFIG[gpl] = "--enable-gpl,--disable-gpl"
61PACKAGECONFIG[gsm] = "--enable-libgsm,--disable-libgsm,libgsm"
62PACKAGECONFIG[jack] = "--enable-indev=jack,--disable-indev=jack,jack"
63PACKAGECONFIG[libopus] = "--enable-libopus,--disable-libopus,libopus"
64PACKAGECONFIG[libvorbis] = "--enable-libvorbis,--disable-libvorbis,libvorbis"
65PACKAGECONFIG[lzma] = "--enable-lzma,--disable-lzma,xz"
66PACKAGECONFIG[mfx] = "--enable-libmfx,--disable-libmfx,intel-mediasdk"
67PACKAGECONFIG[mp3lame] = "--enable-libmp3lame,--disable-libmp3lame,lame"
68PACKAGECONFIG[openssl] = "--enable-openssl,--disable-openssl,openssl"
69PACKAGECONFIG[sdl2] = "--enable-sdl2,--disable-sdl2,virtual/libsdl2"
70PACKAGECONFIG[speex] = "--enable-libspeex,--disable-libspeex,speex"
71PACKAGECONFIG[srt] = "--enable-libsrt,--disable-libsrt,srt"
72PACKAGECONFIG[theora] = "--enable-libtheora,--disable-libtheora,libtheora libogg"
Andrew Geissler3eeda902023-05-19 10:14:02 -050073PACKAGECONFIG[v4l2] = "--enable-libv4l2,--disable-libv4l2,v4l-utils"
Patrick Williams92b42cb2022-09-03 06:53:57 -050074PACKAGECONFIG[vaapi] = "--enable-vaapi,--disable-vaapi,libva"
75PACKAGECONFIG[vdpau] = "--enable-vdpau,--disable-vdpau,libvdpau"
76PACKAGECONFIG[vpx] = "--enable-libvpx,--disable-libvpx,libvpx"
77PACKAGECONFIG[x264] = "--enable-libx264,--disable-libx264,x264"
78PACKAGECONFIG[x265] = "--enable-libx265,--disable-libx265,x265"
79PACKAGECONFIG[xcb] = "--enable-libxcb,--disable-libxcb,libxcb"
80PACKAGECONFIG[xv] = "--enable-outdev=xv,--disable-outdev=xv,libxv"
81PACKAGECONFIG[zlib] = "--enable-zlib,--disable-zlib,zlib"
82
Patrick Williams92b42cb2022-09-03 06:53:57 -050083# Check codecs that require --enable-nonfree
84USE_NONFREE = "${@bb.utils.contains_any('PACKAGECONFIG', [ 'openssl' ], 'yes', '', d)}"
85
86def cpu(d):
87 for arg in (d.getVar('TUNE_CCARGS') or '').split():
88 if arg.startswith('-mcpu='):
89 return arg[6:]
90 return 'generic'
91
92EXTRA_OECONF = " \
Andrew Geissler3eeda902023-05-19 10:14:02 -050093 --disable-stripping \
94 --enable-pic \
95 --enable-shared \
96 --enable-pthreads \
Patrick Williams92b42cb2022-09-03 06:53:57 -050097 ${@bb.utils.contains('USE_NONFREE', 'yes', '--enable-nonfree', '', d)} \
98 \
99 --cross-prefix=${TARGET_PREFIX} \
100 \
101 --ld='${CCLD}' \
102 --cc='${CC}' \
103 --cxx='${CXX}' \
104 --arch=${TARGET_ARCH} \
105 --target-os='linux' \
106 --enable-cross-compile \
107 --extra-cflags='${CFLAGS} ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}' \
108 --extra-ldflags='${LDFLAGS}' \
109 --sysroot='${STAGING_DIR_TARGET}' \
110 ${EXTRA_FFCONF} \
111 --libdir=${libdir} \
112 --shlibdir=${libdir} \
113 --datadir=${datadir}/ffmpeg \
Andrew Geissler3eeda902023-05-19 10:14:02 -0500114 ${@bb.utils.contains('AVAILTUNES', 'mips32r2', '', '--disable-mipsdsp --disable-mipsdspr2', d)} \
Patrick Williams92b42cb2022-09-03 06:53:57 -0500115 --cpu=${@cpu(d)} \
116 --pkg-config=pkg-config \
117"
118
119EXTRA_OECONF:append:linux-gnux32 = " --disable-asm"
120
121EXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mipsisa64r6', '--disable-mips64r2 --disable-mips32r2', '', d)}"
122EXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mipsisa64r2', '--disable-mips64r6 --disable-mips32r6', '', d)}"
123EXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mips32r2', '--disable-mips64r6 --disable-mips32r6', '', d)}"
124EXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mips32r6', '--disable-mips64r2 --disable-mips32r2', '', d)}"
125EXTRA_OECONF:append:mips = " --extra-libs=-latomic --disable-mips32r5 --disable-mipsdsp --disable-mipsdspr2 \
126 --disable-loongson2 --disable-loongson3 --disable-mmi --disable-msa"
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500127EXTRA_OECONF:append:riscv32 = " --extra-libs=-latomic --disable-rvv --disable-asm"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500128EXTRA_OECONF:append:armv5 = " --extra-libs=-latomic"
129EXTRA_OECONF:append:powerpc = " --extra-libs=-latomic"
130
131# gold crashes on x86, another solution is to --disable-asm but thats more hacky
132# ld.gold: internal error in relocate_section, at ../../gold/i386.cc:3684
133
134LDFLAGS:append:x86 = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd ', '', d)}"
135
136EXTRA_OEMAKE = "V=1"
137
138do_configure() {
Patrick Williams864cc432023-02-09 14:54:44 -0600139 export TMPDIR="${B}/tmp"
140 mkdir -p ${B}/tmp
Patrick Williams92b42cb2022-09-03 06:53:57 -0500141 ${S}/configure ${EXTRA_OECONF}
Andrew Geissler517393d2023-01-13 08:55:19 -0600142 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 -0500143}
144
145# patch out build host paths for reproducibility
146do_compile:prepend:class-target() {
147 sed -i -e "s,${WORKDIR},,g" ${B}/config.h
148}
149
150PACKAGES =+ "libavcodec \
151 libavdevice \
152 libavfilter \
153 libavformat \
154 libavutil \
155 libpostproc \
156 libswresample \
157 libswscale"
158
159FILES:libavcodec = "${libdir}/libavcodec${SOLIBS}"
160FILES:libavdevice = "${libdir}/libavdevice${SOLIBS}"
161FILES:libavfilter = "${libdir}/libavfilter${SOLIBS}"
162FILES:libavformat = "${libdir}/libavformat${SOLIBS}"
163FILES:libavutil = "${libdir}/libavutil${SOLIBS}"
164FILES:libpostproc = "${libdir}/libpostproc${SOLIBS}"
165FILES:libswresample = "${libdir}/libswresample${SOLIBS}"
166FILES:libswscale = "${libdir}/libswscale${SOLIBS}"
167
168# ffmpeg disables PIC on some platforms (e.g. x86-32)
169INSANE_SKIP:${MLPREFIX}libavcodec = "textrel"
170INSANE_SKIP:${MLPREFIX}libavdevice = "textrel"
171INSANE_SKIP:${MLPREFIX}libavfilter = "textrel"
172INSANE_SKIP:${MLPREFIX}libavformat = "textrel"
173INSANE_SKIP:${MLPREFIX}libavutil = "textrel"
174INSANE_SKIP:${MLPREFIX}libswscale = "textrel"
175INSANE_SKIP:${MLPREFIX}libswresample = "textrel"
176INSANE_SKIP:${MLPREFIX}libpostproc = "textrel"