1*4882a593SmuzhiyunSUMMARY = "A complete, cross-platform solution to record, convert and stream audio and video." 2*4882a593SmuzhiyunDESCRIPTION = "FFmpeg is the leading multimedia framework, able to decode, encode, transcode, \ 3*4882a593Smuzhiyun mux, demux, stream, filter and play pretty much anything that humans and machines \ 4*4882a593Smuzhiyun have created. It supports the most obscure ancient formats up to the cutting edge." 5*4882a593SmuzhiyunHOMEPAGE = "https://www.ffmpeg.org/" 6*4882a593SmuzhiyunSECTION = "libs" 7*4882a593Smuzhiyun 8*4882a593SmuzhiyunLICENSE = "GPL-2.0-or-later & LGPL-2.1-or-later & ISC & MIT & BSD-2-Clause & BSD-3-Clause & IJG" 9*4882a593SmuzhiyunLICENSE:${PN} = "GPL-2.0-or-later" 10*4882a593SmuzhiyunLICENSE:libavcodec = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}" 11*4882a593SmuzhiyunLICENSE:libavdevice = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}" 12*4882a593SmuzhiyunLICENSE:libavfilter = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}" 13*4882a593SmuzhiyunLICENSE:libavformat = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}" 14*4882a593SmuzhiyunLICENSE:libavutil = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}" 15*4882a593SmuzhiyunLICENSE:libpostproc = "GPL-2.0-or-later" 16*4882a593SmuzhiyunLICENSE:libswresample = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}" 17*4882a593SmuzhiyunLICENSE:libswscale = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}" 18*4882a593SmuzhiyunLICENSE_FLAGS = "commercial" 19*4882a593Smuzhiyun 20*4882a593SmuzhiyunLIC_FILES_CHKSUM = "file://COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ 21*4882a593Smuzhiyun file://COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \ 22*4882a593Smuzhiyun file://COPYING.LGPLv2.1;md5=bd7a443320af8c812e4c18d1b79df004 \ 23*4882a593Smuzhiyun file://COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02" 24*4882a593Smuzhiyun 25*4882a593SmuzhiyunSRC_URI = "https://www.ffmpeg.org/releases/${BP}.tar.xz \ 26*4882a593Smuzhiyun file://0001-libavutil-include-assembly-with-full-path-from-sourc.patch \ 27*4882a593Smuzhiyun file://0001-avcodec-rpzaenc-stop-accessing-out-of-bounds-frame.patch \ 28*4882a593Smuzhiyun file://0001-avcodec-smcenc-stop-accessing-out-of-bounds-frame.patch \ 29*4882a593Smuzhiyun file://0001-avcodec-vp3-Add-missing-check-for-av_malloc.patch \ 30*4882a593Smuzhiyun file://0001-avformat-nutdec-Add-check-for-avformat_new_stream.patch \ 31*4882a593Smuzhiyun " 32*4882a593Smuzhiyun 33*4882a593SmuzhiyunSRC_URI[sha256sum] = "ef2efae259ce80a240de48ec85ecb062cecca26e4352ffb3fda562c21a93007b" 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun# Build fails when thumb is enabled: https://bugzilla.yoctoproject.org/show_bug.cgi?id=7717 36*4882a593SmuzhiyunARM_INSTRUCTION_SET:armv4 = "arm" 37*4882a593SmuzhiyunARM_INSTRUCTION_SET:armv5 = "arm" 38*4882a593SmuzhiyunARM_INSTRUCTION_SET:armv6 = "arm" 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun# Should be API compatible with libav (which was a fork of ffmpeg) 41*4882a593Smuzhiyun# libpostproc was previously packaged from a separate recipe 42*4882a593SmuzhiyunPROVIDES = "libav libpostproc" 43*4882a593Smuzhiyun 44*4882a593SmuzhiyunDEPENDS = "nasm-native" 45*4882a593Smuzhiyun 46*4882a593Smuzhiyuninherit autotools pkgconfig 47*4882a593Smuzhiyun 48*4882a593SmuzhiyunPACKAGECONFIG ??= "avdevice avfilter avcodec avformat swresample swscale postproc \ 49*4882a593Smuzhiyun alsa bzlib lzma pic pthreads shared theora zlib \ 50*4882a593Smuzhiyun ${@bb.utils.contains('AVAILTUNES', 'mips32r2', 'mips32r2', '', d)} \ 51*4882a593Smuzhiyun ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'xv xcb', '', d)}" 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun# libraries to build in addition to avutil 54*4882a593SmuzhiyunPACKAGECONFIG[avdevice] = "--enable-avdevice,--disable-avdevice" 55*4882a593SmuzhiyunPACKAGECONFIG[avfilter] = "--enable-avfilter,--disable-avfilter" 56*4882a593SmuzhiyunPACKAGECONFIG[avcodec] = "--enable-avcodec,--disable-avcodec" 57*4882a593SmuzhiyunPACKAGECONFIG[avformat] = "--enable-avformat,--disable-avformat" 58*4882a593SmuzhiyunPACKAGECONFIG[swresample] = "--enable-swresample,--disable-swresample" 59*4882a593SmuzhiyunPACKAGECONFIG[swscale] = "--enable-swscale,--disable-swscale" 60*4882a593SmuzhiyunPACKAGECONFIG[postproc] = "--enable-postproc,--disable-postproc" 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun# features to support 63*4882a593SmuzhiyunPACKAGECONFIG[alsa] = "--enable-alsa,--disable-alsa,alsa-lib" 64*4882a593SmuzhiyunPACKAGECONFIG[altivec] = "--enable-altivec,--disable-altivec," 65*4882a593SmuzhiyunPACKAGECONFIG[bzlib] = "--enable-bzlib,--disable-bzlib,bzip2" 66*4882a593SmuzhiyunPACKAGECONFIG[fdk-aac] = "--enable-libfdk-aac --enable-nonfree,--disable-libfdk-aac,fdk-aac" 67*4882a593SmuzhiyunPACKAGECONFIG[gpl] = "--enable-gpl,--disable-gpl" 68*4882a593SmuzhiyunPACKAGECONFIG[gsm] = "--enable-libgsm,--disable-libgsm,libgsm" 69*4882a593SmuzhiyunPACKAGECONFIG[jack] = "--enable-indev=jack,--disable-indev=jack,jack" 70*4882a593SmuzhiyunPACKAGECONFIG[libopus] = "--enable-libopus,--disable-libopus,libopus" 71*4882a593SmuzhiyunPACKAGECONFIG[libvorbis] = "--enable-libvorbis,--disable-libvorbis,libvorbis" 72*4882a593SmuzhiyunPACKAGECONFIG[lzma] = "--enable-lzma,--disable-lzma,xz" 73*4882a593SmuzhiyunPACKAGECONFIG[mfx] = "--enable-libmfx,--disable-libmfx,intel-mediasdk" 74*4882a593SmuzhiyunPACKAGECONFIG[mp3lame] = "--enable-libmp3lame,--disable-libmp3lame,lame" 75*4882a593SmuzhiyunPACKAGECONFIG[openssl] = "--enable-openssl,--disable-openssl,openssl" 76*4882a593SmuzhiyunPACKAGECONFIG[sdl2] = "--enable-sdl2,--disable-sdl2,virtual/libsdl2" 77*4882a593SmuzhiyunPACKAGECONFIG[speex] = "--enable-libspeex,--disable-libspeex,speex" 78*4882a593SmuzhiyunPACKAGECONFIG[srt] = "--enable-libsrt,--disable-libsrt,srt" 79*4882a593SmuzhiyunPACKAGECONFIG[theora] = "--enable-libtheora,--disable-libtheora,libtheora libogg" 80*4882a593SmuzhiyunPACKAGECONFIG[vaapi] = "--enable-vaapi,--disable-vaapi,libva" 81*4882a593SmuzhiyunPACKAGECONFIG[vdpau] = "--enable-vdpau,--disable-vdpau,libvdpau" 82*4882a593SmuzhiyunPACKAGECONFIG[vpx] = "--enable-libvpx,--disable-libvpx,libvpx" 83*4882a593SmuzhiyunPACKAGECONFIG[x264] = "--enable-libx264,--disable-libx264,x264" 84*4882a593SmuzhiyunPACKAGECONFIG[x265] = "--enable-libx265,--disable-libx265,x265" 85*4882a593SmuzhiyunPACKAGECONFIG[xcb] = "--enable-libxcb,--disable-libxcb,libxcb" 86*4882a593SmuzhiyunPACKAGECONFIG[xv] = "--enable-outdev=xv,--disable-outdev=xv,libxv" 87*4882a593SmuzhiyunPACKAGECONFIG[zlib] = "--enable-zlib,--disable-zlib,zlib" 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun# other configuration options 90*4882a593SmuzhiyunPACKAGECONFIG[mips32r2] = ",--disable-mipsdsp --disable-mipsdspr2" 91*4882a593SmuzhiyunPACKAGECONFIG[pic] = "--enable-pic" 92*4882a593SmuzhiyunPACKAGECONFIG[pthreads] = "--enable-pthreads,--disable-pthreads" 93*4882a593SmuzhiyunPACKAGECONFIG[shared] = "--enable-shared" 94*4882a593SmuzhiyunPACKAGECONFIG[strip] = ",--disable-stripping" 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun# Check codecs that require --enable-nonfree 97*4882a593SmuzhiyunUSE_NONFREE = "${@bb.utils.contains_any('PACKAGECONFIG', [ 'openssl' ], 'yes', '', d)}" 98*4882a593Smuzhiyun 99*4882a593Smuzhiyundef cpu(d): 100*4882a593Smuzhiyun for arg in (d.getVar('TUNE_CCARGS') or '').split(): 101*4882a593Smuzhiyun if arg.startswith('-mcpu='): 102*4882a593Smuzhiyun return arg[6:] 103*4882a593Smuzhiyun return 'generic' 104*4882a593Smuzhiyun 105*4882a593SmuzhiyunEXTRA_OECONF = " \ 106*4882a593Smuzhiyun ${@bb.utils.contains('USE_NONFREE', 'yes', '--enable-nonfree', '', d)} \ 107*4882a593Smuzhiyun \ 108*4882a593Smuzhiyun --cross-prefix=${TARGET_PREFIX} \ 109*4882a593Smuzhiyun \ 110*4882a593Smuzhiyun --ld='${CCLD}' \ 111*4882a593Smuzhiyun --cc='${CC}' \ 112*4882a593Smuzhiyun --cxx='${CXX}' \ 113*4882a593Smuzhiyun --arch=${TARGET_ARCH} \ 114*4882a593Smuzhiyun --target-os='linux' \ 115*4882a593Smuzhiyun --enable-cross-compile \ 116*4882a593Smuzhiyun --extra-cflags='${CFLAGS} ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}' \ 117*4882a593Smuzhiyun --extra-ldflags='${LDFLAGS}' \ 118*4882a593Smuzhiyun --sysroot='${STAGING_DIR_TARGET}' \ 119*4882a593Smuzhiyun ${EXTRA_FFCONF} \ 120*4882a593Smuzhiyun --libdir=${libdir} \ 121*4882a593Smuzhiyun --shlibdir=${libdir} \ 122*4882a593Smuzhiyun --datadir=${datadir}/ffmpeg \ 123*4882a593Smuzhiyun --cpu=${@cpu(d)} \ 124*4882a593Smuzhiyun --pkg-config=pkg-config \ 125*4882a593Smuzhiyun" 126*4882a593Smuzhiyun 127*4882a593SmuzhiyunEXTRA_OECONF:append:linux-gnux32 = " --disable-asm" 128*4882a593Smuzhiyun 129*4882a593SmuzhiyunEXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mipsisa64r6', '--disable-mips64r2 --disable-mips32r2', '', d)}" 130*4882a593SmuzhiyunEXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mipsisa64r2', '--disable-mips64r6 --disable-mips32r6', '', d)}" 131*4882a593SmuzhiyunEXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mips32r2', '--disable-mips64r6 --disable-mips32r6', '', d)}" 132*4882a593SmuzhiyunEXTRA_OECONF += "${@bb.utils.contains('TUNE_FEATURES', 'mips32r6', '--disable-mips64r2 --disable-mips32r2', '', d)}" 133*4882a593SmuzhiyunEXTRA_OECONF:append:mips = " --extra-libs=-latomic --disable-mips32r5 --disable-mipsdsp --disable-mipsdspr2 \ 134*4882a593Smuzhiyun --disable-loongson2 --disable-loongson3 --disable-mmi --disable-msa" 135*4882a593SmuzhiyunEXTRA_OECONF:append:riscv32 = " --extra-libs=-latomic" 136*4882a593SmuzhiyunEXTRA_OECONF:append:armv5 = " --extra-libs=-latomic" 137*4882a593SmuzhiyunEXTRA_OECONF:append:powerpc = " --extra-libs=-latomic" 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun# gold crashes on x86, another solution is to --disable-asm but thats more hacky 140*4882a593Smuzhiyun# ld.gold: internal error in relocate_section, at ../../gold/i386.cc:3684 141*4882a593Smuzhiyun 142*4882a593SmuzhiyunLDFLAGS:append:x86 = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd ', '', d)}" 143*4882a593Smuzhiyun 144*4882a593SmuzhiyunEXTRA_OEMAKE = "V=1" 145*4882a593Smuzhiyun 146*4882a593Smuzhiyundo_configure() { 147*4882a593Smuzhiyun ${S}/configure ${EXTRA_OECONF} 148*4882a593Smuzhiyun} 149*4882a593Smuzhiyun 150*4882a593Smuzhiyun# patch out build host paths for reproducibility 151*4882a593Smuzhiyundo_compile:prepend:class-target() { 152*4882a593Smuzhiyun sed -i -e "s,${WORKDIR},,g" ${B}/config.h 153*4882a593Smuzhiyun} 154*4882a593Smuzhiyun 155*4882a593SmuzhiyunPACKAGES =+ "libavcodec \ 156*4882a593Smuzhiyun libavdevice \ 157*4882a593Smuzhiyun libavfilter \ 158*4882a593Smuzhiyun libavformat \ 159*4882a593Smuzhiyun libavutil \ 160*4882a593Smuzhiyun libpostproc \ 161*4882a593Smuzhiyun libswresample \ 162*4882a593Smuzhiyun libswscale" 163*4882a593Smuzhiyun 164*4882a593SmuzhiyunFILES:libavcodec = "${libdir}/libavcodec${SOLIBS}" 165*4882a593SmuzhiyunFILES:libavdevice = "${libdir}/libavdevice${SOLIBS}" 166*4882a593SmuzhiyunFILES:libavfilter = "${libdir}/libavfilter${SOLIBS}" 167*4882a593SmuzhiyunFILES:libavformat = "${libdir}/libavformat${SOLIBS}" 168*4882a593SmuzhiyunFILES:libavutil = "${libdir}/libavutil${SOLIBS}" 169*4882a593SmuzhiyunFILES:libpostproc = "${libdir}/libpostproc${SOLIBS}" 170*4882a593SmuzhiyunFILES:libswresample = "${libdir}/libswresample${SOLIBS}" 171*4882a593SmuzhiyunFILES:libswscale = "${libdir}/libswscale${SOLIBS}" 172*4882a593Smuzhiyun 173*4882a593Smuzhiyun# ffmpeg disables PIC on some platforms (e.g. x86-32) 174*4882a593SmuzhiyunINSANE_SKIP:${MLPREFIX}libavcodec = "textrel" 175*4882a593SmuzhiyunINSANE_SKIP:${MLPREFIX}libavdevice = "textrel" 176*4882a593SmuzhiyunINSANE_SKIP:${MLPREFIX}libavfilter = "textrel" 177*4882a593SmuzhiyunINSANE_SKIP:${MLPREFIX}libavformat = "textrel" 178*4882a593SmuzhiyunINSANE_SKIP:${MLPREFIX}libavutil = "textrel" 179*4882a593SmuzhiyunINSANE_SKIP:${MLPREFIX}libswscale = "textrel" 180*4882a593SmuzhiyunINSANE_SKIP:${MLPREFIX}libswresample = "textrel" 181*4882a593SmuzhiyunINSANE_SKIP:${MLPREFIX}libpostproc = "textrel" 182