1SUMMARY="Audio and video recording, conversion, and streaming library" 2DESCRIPTION="FFmpeg is a complete, cross-platform solution to record, convert \ 3and stream audio and video. It includes libavcodec - the leading audio/video \ 4codec library." 5HOMEPAGE="https://ffmpeg.org/" 6COPYRIGHT="2000-2003 Fabrice Bellard 7 2003-2023 the FFmpeg developers" 8LICENSE="GNU LGPL v3" 9REVISION="3" 10SOURCE_URI="https://ffmpeg.org/releases/ffmpeg-$portVersion.tar.xz" 11CHECKSUM_SHA256="4974d62e7507ba3b26fa5f30af8ee36825917ddb4a1ad4118277698c1c8818cf" 12PATCHES="ffmpeg-$portVersion.patchset" 13ADDITIONAL_FILES="gcc_runtime.c" 14 15ARCHITECTURES="all" 16SECONDARY_ARCHITECTURES="x86_gcc2 x86" 17 18ffmpegLibs="\ 19 libavcodec \ 20 libavdevice \ 21 libavfilter \ 22 libavformat \ 23 libavutil \ 24 libswresample \ 25 libswscale \ 26 " 27# Do not sort alphabetically 28libavutilVersion="56.31.100" 29libavcodecVersion="58.54.100" 30libavformatVersion="58.29.100" 31libavdeviceVersion="58.8.100" 32libavfilterVersion="7.57.100" 33libswscaleVersion="5.5.100" 34libswresampleVersion="3.5.100" 35portVersionCompat="$portVersion compat >= 4" 36for i in $ffmpegLibs; do 37 eval "${i}VersionCompat=\"\$${i}Version compat >= \${${i}Version%%.*}\"" 38done 39 40PROVIDES=" 41 ffmpeg$secondaryArchSuffix = $portVersionCompat 42 lib:libavcodec$secondaryArchSuffix = $libavcodecVersionCompat 43 lib:libavfilter$secondaryArchSuffix = $libavfilterVersionCompat 44 lib:libavformat$secondaryArchSuffix = $libavformatVersionCompat 45 lib:libavutil$secondaryArchSuffix = $libavutilVersionCompat 46 lib:libswresample$secondaryArchSuffix = $libswresampleVersionCompat 47 lib:libswscale$secondaryArchSuffix = $libswscaleVersionCompat 48 " 49REQUIRES=" 50 haiku$secondaryArchSuffix 51 lib:libbz2$secondaryArchSuffix 52 lib:libiconv$secondaryArchSuffix 53 lib:libmp3lame$secondaryArchSuffix 54 lib:libogg$secondaryArchSuffix 55 lib:libopus$secondaryArchSuffix 56 lib:libspeex$secondaryArchSuffix 57 lib:libssl$secondaryArchSuffix 58 lib:libtheoradec$secondaryArchSuffix 59 lib:libtheoraenc$secondaryArchSuffix 60 lib:libvorbis$secondaryArchSuffix 61 lib:libvorbisenc$secondaryArchSuffix 62 lib:libz$secondaryArchSuffix 63 " 64if [ "$effectiveTargetArchitecture" != x86_gcc2 ]; then 65 REQUIRES+=" 66 lib:libass$secondaryArchSuffix 67 lib:libfdk_aac$secondaryArchSuffix 68 lib:libfontconfig$secondaryArchSuffix 69 lib:libfreetype$secondaryArchSuffix 70 lib:libfribidi$secondaryArchSuffix 71 lib:libgme$secondaryArchSuffix 72 lib:libgmp$secondaryArchSuffix 73 lib:libopenjp2$secondaryArchSuffix 74 lib:libopenmpt$secondaryArchSuffix 75 lib:libsnappy$secondaryArchSuffix 76 lib:libsoxr$secondaryArchSuffix 77 lib:libvpx$secondaryArchSuffix 78 lib:libwavpack$secondaryArchSuffix 79 lib:libwebp$secondaryArchSuffix 80# lib:libx264$secondaryArchSuffix 81# lib:libx265$secondaryArchSuffix 82 lib:libxml2$secondaryArchSuffix 83 lib:liblzma$secondaryArchSuffix 84 " 85fi 86CONFLICTS=" 87 ffmpeg_legacy$secondaryArchSuffix 88 ffmpeg${secondaryArchSuffix}_bin 89 ffmpeg2${secondaryArchSuffix}_bin 90 " 91 92PROVIDES_avdevice=" 93 ffmpeg${secondaryArchSuffix}_avdevice = $portVersionCompat 94 lib:libavdevice$secondaryArchSuffix = $libavdeviceVersionCompat 95 " 96REQUIRES_avdevice=" 97 haiku$secondaryArchSuffix 98 lib:libavcodec$secondaryArchSuffix == $libavcodecVersion 99 lib:libavfilter$secondaryArchSuffix == $libavfilterVersion 100 lib:libavformat$secondaryArchSuffix == $libavformatVersion 101 lib:libavutil$secondaryArchSuffix == $libavutilVersion 102 lib:libSDL2_2.0$secondaryArchSuffix 103 " 104 105PROVIDES_tools=" 106 ffmpeg${secondaryArchSuffix}_tools = $portVersion 107 cmd:ffmpeg$secondaryArchSuffix = $portVersionCompat 108 cmd:ffplay$secondaryArchSuffix = $portVersionCompat 109 cmd:ffprobe$secondaryArchSuffix = $portVersionCompat 110 " 111REQUIRES_tools=" 112 haiku$secondaryArchSuffix 113 lib:libavcodec$secondaryArchSuffix == $libavcodecVersion 114 lib:libavdevice$secondaryArchSuffix == $libavdeviceVersion 115 lib:libavfilter$secondaryArchSuffix == $libavfilterVersion 116 lib:libavformat$secondaryArchSuffix == $libavformatVersion 117 lib:libavutil$secondaryArchSuffix == $libavutilVersion 118 lib:libSDL2_2.0$secondaryArchSuffix 119 " 120 121PROVIDES_devel=" 122 ffmpeg${secondaryArchSuffix}_devel = $portVersionCompat 123 devel:libavcodec$secondaryArchSuffix = $libavcodecVersionCompat 124 devel:libavdevice$secondaryArchSuffix = $libavdeviceVersionCompat 125 devel:libavfilter$secondaryArchSuffix = $libavfilterVersionCompat 126 devel:libavformat$secondaryArchSuffix = $libavformatVersionCompat 127 devel:libavutil$secondaryArchSuffix = $libavutilVersionCompat 128 devel:libswresample$secondaryArchSuffix = $libswresampleVersionCompat 129 devel:libswscale$secondaryArchSuffix = $libswscaleVersionCompat 130 " 131REQUIRES_devel=" 132 ffmpeg$secondaryArchSuffix == $portVersion base 133 ffmpeg${secondaryArchSuffix}_avdevice == $portVersion 134 devel:libspeex$secondaryArchSuffix 135 " 136CONFLICTS_devel=" 137 ffmpeg_legacy${secondaryArchSuffix}_devel 138 ffmpeg${secondaryArchSuffix}_devel 139 ffmpeg2${secondaryArchSuffix}_devel 140 " 141 142# -- HACK! -- 143# ffmpeg ~0.10 has perpetually had & caused problems when compiled with GCC 2. 144# (Later versions do not compile with GCC 2 at all.) So instead, we now compile 145# FFmpeg for x86_gcc2 with a modern GCC. 146# 147# This works because GCC's C ABI has not changed between 2 and 7; only the C++ 148# ABI has, and no BeOS applications expect a system FFmpeg at all, so we can 149# break its ABI all we like. 150if [ "$effectiveTargetArchitecture" = x86_gcc2 ] && \ 151 [ "$targetArchitecture" = x86_gcc2 ]; then 152 gccSuffix="_x86" 153elif [ "$effectiveTargetArchitecture" = x86_gcc2 ] && \ 154 [ "$targetArchitecture" = x86 ]; then 155 gccSuffix="" 156else 157 gccSuffix="$secondaryArchSuffix" 158fi 159 160BUILD_REQUIRES=" 161 haiku${secondaryArchSuffix}_devel 162 devel:libbz2$secondaryArchSuffix 163 devel:libiconv$secondaryArchSuffix 164 devel:libmp3lame$secondaryArchSuffix 165 devel:libogg$secondaryArchSuffix 166 devel:libopus$secondaryArchSuffix 167 devel:libsdl2$secondaryArchSuffix 168 devel:libspeex$secondaryArchSuffix 169 devel:libssl$secondaryArchSuffix 170 devel:libtheora$secondaryArchSuffix 171 devel:libvorbis$secondaryArchSuffix 172 devel:libz$secondaryArchSuffix 173 " 174if [ "$effectiveTargetArchitecture" != x86_gcc2 ]; then 175 BUILD_REQUIRES+=" 176 devel:libass$secondaryArchSuffix 177 devel:libfdk_aac$secondaryArchSuffix 178 devel:libfontconfig$secondaryArchSuffix 179 devel:libfreetype$secondaryArchSuffix 180 devel:libfribidi$secondaryArchSuffix 181 devel:libgme$secondaryArchSuffix 182 devel:libgmp$secondaryArchSuffix 183 devel:libopenjp2$secondaryArchSuffix 184 devel:libopenmpt$secondaryArchSuffix 185 devel:libsnappy$secondaryArchSuffix 186 devel:libsoxr$secondaryArchSuffix 187 devel:libvpx$secondaryArchSuffix 188 devel:libwavpack$secondaryArchSuffix 189 devel:libwebp$secondaryArchSuffix 190# devel:libx264$secondaryArchSuffix 191# devel:libx265$secondaryArchSuffix 192 devel:libxml2$secondaryArchSuffix 193 devel:liblzma$secondaryArchSuffix 194 " 195fi 196BUILD_PREREQUIRES=" 197 cmd:awk 198 cmd:cmp 199 cmd:gcc$gccSuffix >= 7 200 cmd:g++$secondaryArchSuffix 201 cmd:ld$gccSuffix 202 cmd:grep 203 cmd:make 204 cmd:perl 205 cmd:pkg_config$secondaryArchSuffix 206 cmd:sed 207 cmd:texi2html 208 cmd:yasm 209 " 210 211PATCH() 212{ 213 # patch hard-coded paths to perl 214 sed -i "s,/usr/bin/perl,$portPackageLinksDir/cmd~perl/bin/perl," \ 215 doc/Doxyfile \ 216 doc/texi2pod.pl 217 # force no-undefined-symbols 218 if [ "$effectiveTargetArchitecture" = x86_gcc2 ]; then 219 sed -i "s/SHFLAGS='-shared/SHFLAGS='-shared -Wl,--no-undefined/g" \ 220 configure 221 fi 222} 223 224defineDebugInfoPackage ffmpeg$secondaryArchSuffix \ 225 $libDir/libavcodec.so.$libavcodecVersion \ 226 $libDir/libavfilter.so.$libavfilterVersion \ 227 $libDir/libavformat.so.$libavformatVersion \ 228 $libDir/libavutil.so.$libavutilVersion \ 229 $libDir/libswresample.so.$libswresampleVersion \ 230 $libDir/libswscale.so.$libswscaleVersion \ 231 "$(getPackagePrefix avdevice)/$relativeLibDir"/libavdevice.so.$libavdeviceVersion \ 232 "$(getPackagePrefix tools)/$relativeBinDir"/ffmpeg \ 233 "$(getPackagePrefix tools)/$relativeBinDir"/ffplay \ 234 "$(getPackagePrefix tools)/$relativeBinDir"/ffprobe 235 236BUILD() 237{ 238 ccArgs="" 239 extraArgs="" 240 if [ "$effectiveTargetArchitecture" = x86_gcc2 ]; then 241 cc="gcc${gccSuffix/_/-}" 242 ccArgs="--cc=$cc --cxx=g++${secondaryArchSuffix/_/-} 243 --ld=gcc${secondaryArchSuffix/_/-} 244 --host-ld=gcc${secondaryArchSuffix/_/-}" 245 246 # Hack up base headers to make them think we're on GCC2 ABI 247 mkdir -p include_hacks include_hacks/os include_hacks/config 248 pushd include_hacks 249 rm -f os/BeBuild.h config/HaikuConfig.h 250 cp /system/develop/headers/os/BeBuild.h os 251 cp /system/develop/headers/config/HaikuConfig.h config 252 sed -i 's/__GNUC__ == 2/1/g' os/BeBuild.h config/HaikuConfig.h 253 popd 254 255 # Compile gcc_runtime.c (subset of libgcc that GCC 7 utilizes here) 256 $cc -fvisibility=hidden -c $portDir/additional-files/gcc_runtime.c \ 257 -o gcc_runtime.o 258 259 baseLDFLAGS="-B/system/bin/${gccSuffix/_/}" 260 ccArgs="$ccArgs --host-ldflags=\"${baseLDFLAGS}\"" 261 export CFLAGS="-isystem$(pwd) -isystem$(pwd)/os -isystem$(pwd)/config" 262 export LDFLAGS="$baseLDFLAGS $(pwd)/gcc_runtime.o" 263 else 264 extraArgs="--enable-libass \ 265 --enable-libfdk-aac \ 266 --enable-fontconfig \ 267 --enable-libfreetype \ 268 --enable-libfribidi \ 269 --enable-libgme \ 270 --enable-gmp \ 271 --enable-libopenjpeg \ 272 --enable-libopenmpt \ 273 --enable-libsnappy \ 274 --enable-libsoxr \ 275 --enable-libvpx \ 276 --enable-libwavpack \ 277 --enable-libwebp \ 278 --enable-libxml2 \ 279 --enable-lzma" 280 fi 281 282 # not an autotools configure 283 ./configure \ 284 $ccArgs \ 285 --prefix=$prefix \ 286 --bindir=$binDir \ 287 --datadir=$dataDir/$portName \ 288 --incdir=$includeDir \ 289 --libdir=$libDir \ 290 --shlibdir=$libDir \ 291 --mandir=$manDir \ 292 --disable-debug \ 293 --disable-stripping \ 294 --disable-static \ 295 --enable-shared \ 296 --enable-version3 \ 297 --enable-openssl \ 298 --enable-libvorbis \ 299 --enable-libspeex \ 300 --enable-libtheora \ 301 --enable-libmp3lame \ 302 --enable-libopus \ 303 $extraArgs 304 305 make $jobArgs 306} 307 308INSTALL() 309{ 310 make install 311 312 prepareInstalledDevelLibs $ffmpegLibs 313 fixPkgconfig 314 315 # The pkgconfig file reference other libraries using the wrong paths, which 316 # creates a lot of confusion. Fix them so correct paths are used. 317 local develPackageName="${portName}_devel-$portFullVersion" 318 local packageLinksDir=$(dirname $portPackageLinksDir) 319 local linksDir="$packageLinksDir/${develPackageName}/devel~libspeex$secondaryArchSuffix/$relativeDevelopLibDir" 320 sed -i -e "s,^\(Libs.private.*\)-L.*speex.* \(-lspeex.*\),\1-L$linksDir \2," \ 321 $developLibDir/pkgconfig/libavcodec.pc \ 322 $developLibDir/pkgconfig/libavdevice.pc \ 323 $developLibDir/pkgconfig/libavfilter.pc \ 324 $developLibDir/pkgconfig/libavformat.pc 325 326 # Move html docs to the right place. 327 mkdir -p $docDir 328 mv $prefix/share/doc/ffmpeg $docDir 329 rm -r $prefix/share 330 331 # Split out libs and executables which need libSDL 332 packageEntries tools $binDir 333 packageEntries avdevice $libDir/libavdevice* 334 335 # devel package 336 packageEntries devel \ 337 $dataDir/ffmpeg$secondaryArchSuffix/examples \ 338 $manDir/man3 \ 339 $docDir \ 340 $developDir 341} 342 343TEST() 344{ 345 make check 346} 347