blob: 4ba5ff45377293263a7a1c8ae7509aa6b81ec9ae [file] [log] [blame]
Andrew Geissler595f6302022-01-24 19:11:47 +00001SUMMARY = "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 = "GPLv2+ & LGPLv2.1+ & ISC & MIT & BSD-2-Clause & BSD-3-Clause & IJG"
9LICENSE:${PN} = "GPLv2+"
10LICENSE:libavcodec = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPLv2+', 'LGPLv2.1+', d)}"
11LICENSE:libavdevice = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPLv2+', 'LGPLv2.1+', d)}"
12LICENSE:libavfilter = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPLv2+', 'LGPLv2.1+', d)}"
13LICENSE:libavformat = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPLv2+', 'LGPLv2.1+', d)}"
14LICENSE:libavutil = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPLv2+', 'LGPLv2.1+', d)}"
15LICENSE:libpostproc = "GPLv2+"
16LICENSE:libswresample = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPLv2+', 'LGPLv2.1+', d)}"
17LICENSE:libswscale = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPLv2+', 'LGPLv2.1+', 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
25SRC_URI = "https://www.ffmpeg.org/releases/${BP}.tar.xz \
26 file://0001-libavutil-include-assembly-with-full-path-from-sourc.patch \
27 "
28SRC_URI[sha256sum] = "51e919f7d205062c0fd4fae6243a84850391115104ccf1efc451733bc0ac7298"
29
30# Build fails when thumb is enabled: https://bugzilla.yoctoproject.org/show_bug.cgi?id=7717
31ARM_INSTRUCTION_SET:armv4 = "arm"
32ARM_INSTRUCTION_SET:armv5 = "arm"
33ARM_INSTRUCTION_SET:armv6 = "arm"
34
35# Should be API compatible with libav (which was a fork of ffmpeg)
36# libpostproc was previously packaged from a separate recipe
37PROVIDES = "libav libpostproc"
38
39DEPENDS = "nasm-native"
40
41inherit autotools pkgconfig
42
43PACKAGECONFIG ??= "avdevice avfilter avcodec avformat swresample swscale postproc \
44 alsa bzlib lzma pic pthreads shared theora zlib \
45 ${@bb.utils.contains('AVAILTUNES', 'mips32r2', 'mips32r2', '', d)} \
46 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'xv xcb', '', d)}"
47
48# libraries to build in addition to avutil
49PACKAGECONFIG[avdevice] = "--enable-avdevice,--disable-avdevice"
50PACKAGECONFIG[avfilter] = "--enable-avfilter,--disable-avfilter"
51PACKAGECONFIG[avcodec] = "--enable-avcodec,--disable-avcodec"
52PACKAGECONFIG[avformat] = "--enable-avformat,--disable-avformat"
53PACKAGECONFIG[swresample] = "--enable-swresample,--disable-swresample"
54PACKAGECONFIG[swscale] = "--enable-swscale,--disable-swscale"
55PACKAGECONFIG[postproc] = "--enable-postproc,--disable-postproc"
56
57# features to support
58PACKAGECONFIG[alsa] = "--enable-alsa,--disable-alsa,alsa-lib"
59PACKAGECONFIG[altivec] = "--enable-altivec,--disable-altivec,"
60PACKAGECONFIG[bzlib] = "--enable-bzlib,--disable-bzlib,bzip2"
61PACKAGECONFIG[fdk-aac] = "--enable-libfdk-aac --enable-nonfree,--disable-libfdk-aac,fdk-aac"
62PACKAGECONFIG[gpl] = "--enable-gpl,--disable-gpl"
63PACKAGECONFIG[gsm] = "--enable-libgsm,--disable-libgsm,libgsm"
64PACKAGECONFIG[jack] = "--enable-indev=jack,--disable-indev=jack,jack"
65PACKAGECONFIG[libopus] = "--enable-libopus,--disable-libopus,libopus"
66PACKAGECONFIG[libvorbis] = "--enable-libvorbis,--disable-libvorbis,libvorbis"
67PACKAGECONFIG[lzma] = "--enable-lzma,--disable-lzma,xz"
68PACKAGECONFIG[mfx] = "--enable-libmfx,--disable-libmfx,intel-mediasdk"
69PACKAGECONFIG[mp3lame] = "--enable-libmp3lame,--disable-libmp3lame,lame"
70PACKAGECONFIG[openssl] = "--enable-openssl,--disable-openssl,openssl"
71PACKAGECONFIG[sdl2] = "--enable-sdl2,--disable-sdl2,virtual/libsdl2"
72PACKAGECONFIG[speex] = "--enable-libspeex,--disable-libspeex,speex"
73PACKAGECONFIG[srt] = "--enable-libsrt,--disable-libsrt,srt"
74PACKAGECONFIG[theora] = "--enable-libtheora,--disable-libtheora,libtheora libogg"
75PACKAGECONFIG[vaapi] = "--enable-vaapi,--disable-vaapi,libva"
76PACKAGECONFIG[vdpau] = "--enable-vdpau,--disable-vdpau,libvdpau"
77PACKAGECONFIG[vpx] = "--enable-libvpx,--disable-libvpx,libvpx"
78PACKAGECONFIG[x264] = "--enable-libx264,--disable-libx264,x264"
79PACKAGECONFIG[x265] = "--enable-libx265,--disable-libx265,x265"
80PACKAGECONFIG[xcb] = "--enable-libxcb,--disable-libxcb,libxcb"
81PACKAGECONFIG[xv] = "--enable-outdev=xv,--disable-outdev=xv,libxv"
82PACKAGECONFIG[zlib] = "--enable-zlib,--disable-zlib,zlib"
83
84# other configuration options
85PACKAGECONFIG[mips32r2] = ",--disable-mipsdsp --disable-mipsdspr2"
86PACKAGECONFIG[pic] = "--enable-pic"
87PACKAGECONFIG[pthreads] = "--enable-pthreads,--disable-pthreads"
88PACKAGECONFIG[shared] = "--enable-shared"
89PACKAGECONFIG[strip] = ",--disable-stripping"
90
91# Check codecs that require --enable-nonfree
92USE_NONFREE = "${@bb.utils.contains_any('PACKAGECONFIG', [ 'openssl' ], 'yes', '', d)}"
93
94def cpu(d):
95 for arg in (d.getVar('TUNE_CCARGS') or '').split():
96 if arg.startswith('-mcpu='):
97 return arg[6:]
98 return 'generic'
99
100EXTRA_OECONF = " \
101 ${@bb.utils.contains('USE_NONFREE', 'yes', '--enable-nonfree', '', d)} \
102 \
103 --cross-prefix=${TARGET_PREFIX} \
104 \
105 --ld='${CCLD}' \
106 --cc='${CC}' \
107 --cxx='${CXX}' \
108 --arch=${TARGET_ARCH} \
109 --target-os='linux' \
110 --enable-cross-compile \
111 --extra-cflags='${CFLAGS} ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}' \
112 --extra-ldflags='${LDFLAGS}' \
113 --sysroot='${STAGING_DIR_TARGET}' \
114 ${EXTRA_FFCONF} \
115 --libdir=${libdir} \
116 --shlibdir=${libdir} \
117 --datadir=${datadir}/ffmpeg \
118 --cpu=${@cpu(d)} \
119 --pkg-config=pkg-config \
120"
121
122EXTRA_OECONF:append:linux-gnux32 = " --disable-asm"
123
124EXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mipsisa64r6', '--disable-mips64r2 --disable-mips32r2', '', d)}"
125EXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mipsisa64r2', '--disable-mips64r6 --disable-mips32r6', '', d)}"
126EXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mips32r2', '--disable-mips64r6 --disable-mips32r6', '', d)}"
127EXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mips32r6', '--disable-mips64r2 --disable-mips32r2', '', d)}"
128EXTRA_OECONF:append:mips = " --extra-libs=-latomic --disable-mips32r5 --disable-mipsdsp --disable-mipsdspr2 \
129 --disable-loongson2 --disable-loongson3 --disable-mmi --disable-msa --disable-msa2"
130EXTRA_OECONF:append:riscv32 = " --extra-libs=-latomic"
131EXTRA_OECONF:append:armv5 = " --extra-libs=-latomic"
132EXTRA_OECONF:append:powerpc = " --extra-libs=-latomic"
133
134# gold crashes on x86, another solution is to --disable-asm but thats more hacky
135# ld.gold: internal error in relocate_section, at ../../gold/i386.cc:3684
136
137LDFLAGS:append:x86 = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd ', '', d)}"
138
139EXTRA_OEMAKE = "V=1"
140
141do_configure() {
142 ${S}/configure ${EXTRA_OECONF}
143}
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"