Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | SUMMARY = "A complete, cross-platform solution to record, convert and stream audio and video." |
| 2 | DESCRIPTION = "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." |
| 5 | HOMEPAGE = "https://www.ffmpeg.org/" |
| 6 | SECTION = "libs" |
| 7 | |
| 8 | LICENSE = "GPL-2.0-or-later & LGPL-2.1-or-later & ISC & MIT & BSD-2-Clause & BSD-3-Clause & IJG" |
| 9 | LICENSE:${PN} = "GPL-2.0-or-later" |
| 10 | LICENSE:libavcodec = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}" |
| 11 | LICENSE:libavdevice = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}" |
| 12 | LICENSE:libavfilter = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}" |
| 13 | LICENSE:libavformat = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}" |
| 14 | LICENSE:libavutil = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}" |
| 15 | LICENSE:libpostproc = "GPL-2.0-or-later" |
| 16 | LICENSE:libswresample = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}" |
| 17 | LICENSE:libswscale = "${@bb.utils.contains('PACKAGECONFIG', 'gpl', 'GPL-2.0-or-later', 'LGPL-2.1-or-later', d)}" |
| 18 | LICENSE_FLAGS = "commercial" |
| 19 | |
| 20 | LIC_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 Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 25 | # Build fails when thumb is enabled: https://bugzilla.yoctoproject.org/show_bug.cgi?id=7717 |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 26 | ARM_INSTRUCTION_SET_armv4 = "arm" |
| 27 | ARM_INSTRUCTION_SET_armv5 = "arm" |
| 28 | ARM_INSTRUCTION_SET_armv6 = "arm" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 29 | # Should be API compatible with libav (which was a fork of ffmpeg) |
| 30 | # libpostproc was previously packaged from a separate recipe |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 31 | PROVIDES = "ffmpeg libav libpostproc" |
| 32 | RPROVIDES:${PN} = "${PROVIDES}" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 33 | DEPENDS = "nasm-native" |
| 34 | |
| 35 | inherit autotools pkgconfig |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 36 | PACKAGECONFIG ??= "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 Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 40 | ${@bb.utils.contains('AVAILTUNES', 'mips32r2', 'mips32r2', '', d)} \ |
| 41 | ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'xv xcb', '', d)}" |
| 42 | |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 43 | SRC_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 | |
| 52 | SRCREV = "ea72093f350f38edcd39c480b331c3219c377642" |
| 53 | |
| 54 | S = "${WORKDIR}/git" |
| 55 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 56 | # libraries to build in addition to avutil |
| 57 | PACKAGECONFIG[avdevice] = "--enable-avdevice,--disable-avdevice" |
| 58 | PACKAGECONFIG[avfilter] = "--enable-avfilter,--disable-avfilter" |
| 59 | PACKAGECONFIG[avcodec] = "--enable-avcodec,--disable-avcodec" |
| 60 | PACKAGECONFIG[avformat] = "--enable-avformat,--disable-avformat" |
| 61 | PACKAGECONFIG[swresample] = "--enable-swresample,--disable-swresample" |
| 62 | PACKAGECONFIG[swscale] = "--enable-swscale,--disable-swscale" |
| 63 | PACKAGECONFIG[postproc] = "--enable-postproc,--disable-postproc" |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 64 | PACKAGECONFIG[avresample] = "--enable-avresample,--disable-avresample" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 65 | |
| 66 | # features to support |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 67 | PACKAGECONFIG[ffplay] = "--enable-ffplay,--disable-ffplay" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 68 | PACKAGECONFIG[alsa] = "--enable-alsa,--disable-alsa,alsa-lib" |
| 69 | PACKAGECONFIG[altivec] = "--enable-altivec,--disable-altivec," |
| 70 | PACKAGECONFIG[bzlib] = "--enable-bzlib,--disable-bzlib,bzip2" |
| 71 | PACKAGECONFIG[fdk-aac] = "--enable-libfdk-aac --enable-nonfree,--disable-libfdk-aac,fdk-aac" |
| 72 | PACKAGECONFIG[gpl] = "--enable-gpl,--disable-gpl" |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 73 | PACKAGECONFIG[opengl] = "--enable-opengl,--disable-opengl,virtual/libgl" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 74 | PACKAGECONFIG[gsm] = "--enable-libgsm,--disable-libgsm,libgsm" |
| 75 | PACKAGECONFIG[jack] = "--enable-indev=jack,--disable-indev=jack,jack" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 76 | PACKAGECONFIG[libvorbis] = "--enable-libvorbis,--disable-libvorbis,libvorbis" |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 77 | PACKAGECONFIG[libopus] = "--enable-libopus,--disable-libopus,libopus" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 78 | PACKAGECONFIG[lzma] = "--enable-lzma,--disable-lzma,xz" |
| 79 | PACKAGECONFIG[mfx] = "--enable-libmfx,--disable-libmfx,intel-mediasdk" |
| 80 | PACKAGECONFIG[mp3lame] = "--enable-libmp3lame,--disable-libmp3lame,lame" |
| 81 | PACKAGECONFIG[openssl] = "--enable-openssl,--disable-openssl,openssl" |
| 82 | PACKAGECONFIG[sdl2] = "--enable-sdl2,--disable-sdl2,virtual/libsdl2" |
| 83 | PACKAGECONFIG[speex] = "--enable-libspeex,--disable-libspeex,speex" |
| 84 | PACKAGECONFIG[srt] = "--enable-libsrt,--disable-libsrt,srt" |
| 85 | PACKAGECONFIG[theora] = "--enable-libtheora,--disable-libtheora,libtheora libogg" |
| 86 | PACKAGECONFIG[vaapi] = "--enable-vaapi,--disable-vaapi,libva" |
| 87 | PACKAGECONFIG[vdpau] = "--enable-vdpau,--disable-vdpau,libvdpau" |
| 88 | PACKAGECONFIG[vpx] = "--enable-libvpx,--disable-libvpx,libvpx" |
| 89 | PACKAGECONFIG[x264] = "--enable-libx264,--disable-libx264,x264" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 90 | PACKAGECONFIG[xcb] = "--enable-libxcb,--disable-libxcb,libxcb" |
| 91 | PACKAGECONFIG[xv] = "--enable-outdev=xv,--disable-outdev=xv,libxv" |
| 92 | PACKAGECONFIG[zlib] = "--enable-zlib,--disable-zlib,zlib" |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 93 | #PACKAGECONFIG[snappy] = "--enable-libsnappy,--enable-libsnappy,snappy" |
| 94 | PACKAGECONFIG[udev] = "--enable-libudev,--disable-libudev,udev" |
| 95 | PACKAGECONFIG[v4l2] = "--enable-libv4l2 --enable-v4l2-request --enable-libdrm,,v4l-utils" |
| 96 | PACKAGECONFIG[mmal] = "--enable-omx --enable-omx-rpi --enable-mmal,,userland" |
| 97 | PACKAGECONFIG[sand] = "--enable-sand,," |
| 98 | PACKAGECONFIG[rpi] = "--enable-rpi,," |
| 99 | PACKAGECONFIG[vout-drm] = "--enable-vout-drm,,libdrm" |
| 100 | PACKAGECONFIG[vout-egl] = "--enable-vout-egl,,virtual/egl" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 101 | |
| 102 | # other configuration options |
| 103 | PACKAGECONFIG[mips32r2] = ",--disable-mipsdsp --disable-mipsdspr2" |
| 104 | PACKAGECONFIG[pic] = "--enable-pic" |
| 105 | PACKAGECONFIG[pthreads] = "--enable-pthreads,--disable-pthreads" |
| 106 | PACKAGECONFIG[shared] = "--enable-shared" |
| 107 | PACKAGECONFIG[strip] = ",--disable-stripping" |
| 108 | |
| 109 | # Check codecs that require --enable-nonfree |
| 110 | USE_NONFREE = "${@bb.utils.contains_any('PACKAGECONFIG', [ 'openssl' ], 'yes', '', d)}" |
| 111 | |
| 112 | def 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 | |
| 118 | EXTRA_OECONF = " \ |
| 119 | ${@bb.utils.contains('USE_NONFREE', 'yes', '--enable-nonfree', '', d)} \ |
| 120 | \ |
| 121 | --cross-prefix=${TARGET_PREFIX} \ |
| 122 | \ |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 123 | --ld="${CCLD}" \ |
| 124 | --cc="${CC}" \ |
| 125 | --cxx="${CXX}" \ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 126 | --arch=${TARGET_ARCH} \ |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 127 | --target-os="linux" \ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 128 | --enable-cross-compile \ |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 129 | --extra-cflags="${CFLAGS} ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" \ |
| 130 | --extra-ldflags="${LDFLAGS}" \ |
| 131 | --sysroot="${STAGING_DIR_TARGET}" \ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 132 | ${EXTRA_FFCONF} \ |
| 133 | --libdir=${libdir} \ |
| 134 | --shlibdir=${libdir} \ |
| 135 | --datadir=${datadir}/ffmpeg \ |
| 136 | --cpu=${@cpu(d)} \ |
| 137 | --pkg-config=pkg-config \ |
| 138 | " |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 139 | EXTRA_OECONF:append:linux-gnux32 = " --disable-asm" |
| 140 | |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 141 | # Directly specify the include directories the contain headers for |
| 142 | # libdrm |
| 143 | # openmaxil |
| 144 | TARGET_CFLAGS:append = " -I${STAGING_INCDIR}/IL -I${STAGING_INCDIR}/drm" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 145 | |
| 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 Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 148 | LDFLAGS:append:x86 = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd ', '', d)}" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 149 | EXTRA_OEMAKE = "V=1" |
| 150 | |
| 151 | do_configure() { |
| 152 | ${S}/configure ${EXTRA_OECONF} |
| 153 | } |
| 154 | |
| 155 | # patch out build host paths for reproducibility |
| 156 | do_compile:prepend:class-target() { |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 157 | sed -i -e "s,${WORKDIR},,g" ${B}/config.h |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | PACKAGES =+ "libavcodec \ |
| 161 | libavdevice \ |
| 162 | libavfilter \ |
| 163 | libavformat \ |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 164 | libavresample \ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 165 | libavutil \ |
| 166 | libpostproc \ |
| 167 | libswresample \ |
| 168 | libswscale" |
| 169 | |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 170 | FILES:${PN}:append = " /usr/share/ffmpeg" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 171 | FILES:libavcodec = "${libdir}/libavcodec${SOLIBS}" |
| 172 | FILES:libavdevice = "${libdir}/libavdevice${SOLIBS}" |
| 173 | FILES:libavfilter = "${libdir}/libavfilter${SOLIBS}" |
| 174 | FILES:libavformat = "${libdir}/libavformat${SOLIBS}" |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 175 | FILES:libavresample = "${libdir}/libavresample${SOLIBS}" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 176 | FILES:libavutil = "${libdir}/libavutil${SOLIBS}" |
| 177 | FILES:libpostproc = "${libdir}/libpostproc${SOLIBS}" |
| 178 | FILES:libswresample = "${libdir}/libswresample${SOLIBS}" |
| 179 | FILES:libswscale = "${libdir}/libswscale${SOLIBS}" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 180 | # ffmpeg disables PIC on some platforms (e.g. x86-32) |
| 181 | INSANE_SKIP:${MLPREFIX}libavcodec = "textrel" |
| 182 | INSANE_SKIP:${MLPREFIX}libavdevice = "textrel" |
| 183 | INSANE_SKIP:${MLPREFIX}libavfilter = "textrel" |
| 184 | INSANE_SKIP:${MLPREFIX}libavformat = "textrel" |
| 185 | INSANE_SKIP:${MLPREFIX}libavutil = "textrel" |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 186 | INSANE_SKIP:${MLPREFIX}libavresample = "textrel" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 187 | INSANE_SKIP:${MLPREFIX}libswscale = "textrel" |
| 188 | INSANE_SKIP:${MLPREFIX}libswresample = "textrel" |
| 189 | INSANE_SKIP:${MLPREFIX}libpostproc = "textrel" |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 190 | |
| 191 | # Only enable it for rpi class of machines |
| 192 | COMPATIBLE_HOST = "null" |
| 193 | COMPATIBLE_HOST:rpi = "'(.*)'" |
| 194 | |