nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
fork

Configure Feed

Select the types of activity you want to include in your feed.

at fix-function-merge 916 lines 37 kB view raw
1{ lib, stdenv, buildPackages, removeReferencesTo, addDriverRunpath, pkg-config, perl, texinfo, texinfo6, yasm 2 3 # You can fetch any upstream version using this derivation by specifying version and hash 4 # NOTICE: Always use this argument to override the version. Do not use overrideAttrs. 5, version # ffmpeg ABI version. Also declare this if you're overriding the source. 6, hash ? "" # hash of the upstream source for the given ABI version 7, source ? fetchgit { 8 url = "https://git.ffmpeg.org/ffmpeg.git"; 9 rev = "n${version}"; 10 inherit hash; 11 } 12 13, ffmpegVariant ? "small" # Decides which dependencies are enabled by default 14 15 # Build with headless deps; excludes dependencies that are only necessary for 16 # GUI applications. To be used for purposes that don't generally need such 17 # components and i.e. only depend on libav 18, withHeadlessDeps ? ffmpegVariant == "headless" || withSmallDeps 19 20 # Dependencies a user might customarily expect from a regular ffmpeg build. 21 # /All/ packages that depend on ffmpeg and some of its feaures should depend 22 # on the small variant. Small means the minimal set of features that satisfies 23 # all dependants in Nixpkgs 24, withSmallDeps ? ffmpegVariant == "small" || withFullDeps 25 26 # Everything enabled; only guarded behind platform exclusivity or brokeness. 27 # If you need to depend on ffmpeg-full because ffmpeg is missing some feature 28 # your package needs, you should enable that feature in regular ffmpeg 29 # instead. 30, withFullDeps ? ffmpegVariant == "full" 31 32, fetchgit 33, fetchpatch2 34 35 # Feature flags 36, withAlsa ? withHeadlessDeps && stdenv.isLinux # Alsa in/output supporT 37, withAom ? withFullDeps # AV1 reference encoder 38, withAppKit ? withHeadlessDeps && stdenv.isDarwin # Apple AppKit framework 39, withAribcaption ? withFullDeps && lib.versionAtLeast version "6.1" # ARIB STD-B24 Caption Decoder/Renderer 40, withAss ? withHeadlessDeps && stdenv.hostPlatform == stdenv.buildPlatform # (Advanced) SubStation Alpha subtitle rendering 41, withAudioToolbox ? withHeadlessDeps && stdenv.isDarwin # Apple AudioToolbox 42, withAvFoundation ? withHeadlessDeps && stdenv.isDarwin # Apple AVFoundation framework 43, withAvisynth ? withFullDeps # AviSynth script files reading 44, withBluray ? withFullDeps # BluRay reading 45, withBs2b ? withFullDeps # bs2b DSP library 46, withBzlib ? withHeadlessDeps 47, withCaca ? withFullDeps # Textual display (ASCII art) 48, withCelt ? withFullDeps # CELT decoder 49, withChromaprint ? withFullDeps # Audio fingerprinting 50, withCodec2 ? withFullDeps # codec2 en/decoding 51, withCoreImage ? withHeadlessDeps && stdenv.isDarwin # Apple CoreImage framework 52, withCuda ? withFullDeps && withNvcodec 53, withCudaLLVM ? withFullDeps 54, withCuvid ? withHeadlessDeps && withNvcodec 55, withDav1d ? withHeadlessDeps # AV1 decoder (focused on speed and correctness) 56, withDc1394 ? withFullDeps && !stdenv.isDarwin # IIDC-1394 grabbing (ieee 1394) 57, withDrm ? withHeadlessDeps && (with stdenv; isLinux || isFreeBSD) # libdrm support 58, withDvdnav ? withFullDeps && withGPL && lib.versionAtLeast version "7" # needed for DVD demuxing 59, withDvdread ? withFullDeps && withGPL && lib.versionAtLeast version "7" # needed for DVD demuxing 60, withFdkAac ? withFullDeps && (!withGPL || withUnfree) # Fraunhofer FDK AAC de/encoder 61, withNvcodec ? withHeadlessDeps && (with stdenv; !isDarwin && !isAarch32 && !hostPlatform.isRiscV && hostPlatform == buildPlatform) # dynamically linked Nvidia code 62, withFlite ? withFullDeps # Voice Synthesis 63, withFontconfig ? withHeadlessDeps # Needed for drawtext filter 64, withFreetype ? withHeadlessDeps # Needed for drawtext filter 65, withFrei0r ? withFullDeps && withGPL # frei0r video filtering 66, withFribidi ? withFullDeps # Needed for drawtext filter 67, withGme ? withFullDeps # Game Music Emulator 68, withGnutls ? withHeadlessDeps 69, withGsm ? withFullDeps # GSM de/encoder 70, withHarfbuzz ? withHeadlessDeps && lib.versionAtLeast version "6.1" # Needed for drawtext filter 71, withIconv ? withHeadlessDeps 72, withJack ? withFullDeps && !stdenv.isDarwin # Jack audio 73, withJxl ? withFullDeps && lib.versionAtLeast version "5" # JPEG XL de/encoding 74, withLadspa ? withFullDeps # LADSPA audio filtering 75, withLcms2 ? withFullDeps # ICC profile support via lcms2 76, withLzma ? withHeadlessDeps # xz-utils 77, withMetal ? false # Unfree and requires manual downloading of files 78, withMfx ? withFullDeps && (with stdenv.hostPlatform; isLinux && !isAarch) # Hardware acceleration via intel-media-sdk/libmfx 79, withModplug ? withFullDeps && !stdenv.isDarwin # ModPlug support 80, withMp3lame ? withHeadlessDeps # LAME MP3 encoder 81, withMysofa ? withFullDeps # HRTF support via SOFAlizer 82, withNvdec ? withHeadlessDeps && withNvcodec 83, withNvenc ? withHeadlessDeps && withNvcodec 84, withOgg ? withHeadlessDeps # Ogg container used by vorbis & theora 85, withOpenal ? withFullDeps # OpenAL 1.1 capture support 86, withOpencl ? withFullDeps 87, withOpencoreAmrnb ? withFullDeps && withVersion3 # AMR-NB de/encoder 88, withOpencoreAmrwb ? withFullDeps && withVersion3 # AMR-WB decoder 89, withOpengl ? withFullDeps && !stdenv.isDarwin # OpenGL rendering 90, withOpenh264 ? withFullDeps # H.264/AVC encoder 91, withOpenjpeg ? withFullDeps # JPEG 2000 de/encoder 92, withOpenmpt ? withFullDeps # Tracked music files decoder 93, withOpus ? withHeadlessDeps # Opus de/encoder 94, withPlacebo ? withFullDeps && !stdenv.isDarwin # libplacebo video processing library 95, withPulse ? withSmallDeps && stdenv.isLinux # Pulseaudio input support 96, withQrencode ? withFullDeps && lib.versionAtLeast version "7" # QR encode generation 97, withQuirc ? withFullDeps && lib.versionAtLeast version "7" # QR decoding 98, withRav1e ? withFullDeps # AV1 encoder (focused on speed and safety) 99, withRtmp ? withFullDeps # RTMP[E] support 100, withSamba ? withFullDeps && !stdenv.isDarwin && withGPLv3 # Samba protocol 101, withSdl2 ? withSmallDeps 102, withShaderc ? withFullDeps && !stdenv.isDarwin && lib.versionAtLeast version "5.0" 103, withSoxr ? withHeadlessDeps # Resampling via soxr 104, withSpeex ? withHeadlessDeps # Speex de/encoder 105, withSrt ? withHeadlessDeps # Secure Reliable Transport (SRT) protocol 106, withSsh ? withHeadlessDeps # SFTP protocol 107, withSvg ? withFullDeps # SVG protocol 108, withSvtav1 ? withHeadlessDeps && !stdenv.isAarch64 && !stdenv.hostPlatform.isMinGW # AV1 encoder/decoder (focused on speed and correctness) 109, withTensorflow ? false # Tensorflow dnn backend support (Increases closure size by ~390 MiB) 110, withTheora ? withHeadlessDeps # Theora encoder 111, withTwolame ? withFullDeps # MP2 encoding 112, withV4l2 ? withHeadlessDeps && stdenv.isLinux # Video 4 Linux support 113, withV4l2M2m ? withV4l2 114, withVaapi ? withHeadlessDeps && (with stdenv; isLinux || isFreeBSD) # Vaapi hardware acceleration 115, withVdpau ? withSmallDeps && !stdenv.hostPlatform.isMinGW # Vdpau hardware acceleration 116, withVideoToolbox ? withHeadlessDeps && stdenv.isDarwin # Apple VideoToolbox 117, withVidStab ? withFullDeps && withGPL # Video stabilization 118, withVmaf ? withFullDeps && !stdenv.isAarch64 && lib.versionAtLeast version "5" # Netflix's VMAF (Video Multi-Method Assessment Fusion) 119, withVoAmrwbenc ? withFullDeps && withVersion3 # AMR-WB encoder 120, withVorbis ? withHeadlessDeps # Vorbis de/encoding, native encoder exists 121, withVpl ? false # Hardware acceleration via intel libvpl 122, withVpx ? withHeadlessDeps && stdenv.buildPlatform == stdenv.hostPlatform # VP8 & VP9 de/encoding 123, withVulkan ? withSmallDeps && !stdenv.isDarwin 124, withWebp ? withFullDeps # WebP encoder 125, withX264 ? withHeadlessDeps && withGPL # H.264/AVC encoder 126, withX265 ? withHeadlessDeps && withGPL # H.265/HEVC encoder 127, withXavs ? withFullDeps && withGPL # AVS encoder 128, withXcb ? withXcbShm || withXcbxfixes || withXcbShape # X11 grabbing using XCB 129, withXcbShape ? withFullDeps # X11 grabbing shape rendering 130, withXcbShm ? withFullDeps # X11 grabbing shm communication 131, withXcbxfixes ? withFullDeps # X11 grabbing mouse rendering 132# Currently only supports gcc and msvc as compiler, the limitation for clang get removed in the next release, but that does not fix building on darwin. 133, withXevd ? withFullDeps && lib.versionAtLeast version "7" && stdenv.hostPlatform.isx86 && stdenv.cc.isGNU # MPEG-5 EVC decoding 134, withXeve ? withFullDeps && lib.versionAtLeast version "7" && stdenv.hostPlatform.isx86 && stdenv.cc.isGNU # MPEG-5 EVC encoding 135, withXlib ? withFullDeps # Xlib support 136, withXml2 ? withFullDeps # libxml2 support, for IMF and DASH demuxers 137, withXvid ? withHeadlessDeps && withGPL # Xvid encoder, native encoder exists 138, withZimg ? withHeadlessDeps 139, withZlib ? withHeadlessDeps 140, withZmq ? withFullDeps # Message passing 141 142/* 143 * Licensing options (yes some are listed twice, filters and such are not listed) 144 */ 145, withGPL ? true 146, withVersion3 ? true # When withGPL is set this implies GPLv3 otherwise it is LGPLv3 147, withGPLv3 ? withGPL && withVersion3 148, withUnfree ? false 149 150/* 151 * Build options 152 */ 153, withSmallBuild ? false # Optimize for size instead of speed 154, withRuntimeCPUDetection ? true # Detect CPU capabilities at runtime (disable to compile natively) 155, withGrayscale ? withFullDeps # Full grayscale support 156, withSwscaleAlpha ? buildSwscale # Alpha channel support in swscale. You probably want this when buildSwscale. 157, withHardcodedTables ? withHeadlessDeps # Hardcode decode tables instead of runtime generation 158, withSafeBitstreamReader ? withHeadlessDeps # Buffer boundary checking in bitreaders 159, withMultithread ? true # Multithreading via pthreads/win32 threads 160, withNetwork ? withHeadlessDeps # Network support 161, withPixelutils ? withHeadlessDeps # Pixel utils in libavutil 162, withStatic ? stdenv.hostPlatform.isStatic 163, withShared ? !stdenv.hostPlatform.isStatic 164, withPic ? true 165, withThumb ? false # On some ARM platforms 166 167/* 168 * Program options 169 */ 170, buildFfmpeg ? withHeadlessDeps # Build ffmpeg executable 171, buildFfplay ? withSmallDeps # Build ffplay executable 172, buildFfprobe ? withHeadlessDeps # Build ffprobe executable 173, buildQtFaststart ? withFullDeps # Build qt-faststart executable 174, withBin ? buildFfmpeg || buildFfplay || buildFfprobe || buildQtFaststart 175/* 176 * Library options 177 */ 178, buildAvcodec ? withHeadlessDeps # Build avcodec library 179, buildAvdevice ? withHeadlessDeps # Build avdevice library 180, buildAvfilter ? withHeadlessDeps # Build avfilter library 181, buildAvformat ? withHeadlessDeps # Build avformat library 182# Deprecated but depended upon by some packages. 183# https://github.com/NixOS/nixpkgs/pull/211834#issuecomment-1417435991) 184, buildAvresample ? withHeadlessDeps && lib.versionOlder version "5" # Build avresample library 185, buildAvutil ? withHeadlessDeps # Build avutil library 186, buildPostproc ? withHeadlessDeps # Build postproc library 187, buildSwresample ? withHeadlessDeps # Build swresample library 188, buildSwscale ? withHeadlessDeps # Build swscale library 189, withLib ? buildAvcodec 190 || buildAvdevice 191 || buildAvfilter 192 || buildAvformat 193 || buildAvutil 194 || buildPostproc 195 || buildSwresample 196 || buildSwscale 197/* 198 * Documentation options 199 */ 200, withDocumentation ? withHtmlDoc || withManPages || withPodDoc || withTxtDoc 201, withHtmlDoc ? withHeadlessDeps # HTML documentation pages 202, withManPages ? withHeadlessDeps # Man documentation pages 203, withPodDoc ? withHeadlessDeps # POD documentation pages 204, withTxtDoc ? withHeadlessDeps # Text documentation pages 205# Whether a "doc" output will be produced. Note that withManPages does not produce 206# a "doc" output because its files go to "man". 207, withDoc ? withDocumentation && (withHtmlDoc || withPodDoc || withTxtDoc) 208 209/* 210 * Developer options 211 */ 212, withDebug ? false 213, withOptimisations ? true 214, withExtraWarnings ? false 215, withStripping ? false 216 217/* 218 * External libraries options 219 */ 220, alsa-lib 221, avisynthplus 222, bzip2 223, celt 224, chromaprint 225, codec2 226, clang 227, dav1d 228, fdk_aac 229, flite 230, fontconfig 231, freetype 232, frei0r 233, fribidi 234, game-music-emu 235, gnutls 236, gsm 237, harfbuzz 238, intel-media-sdk 239, ladspaH 240, lame 241, lcms2 242, libaom 243, libaribcaption 244, libass 245, libbluray 246, libbs2b 247, libcaca 248, libdc1394 249, libdrm 250, libdvdnav 251, libdvdread 252, libGL 253, libGLU 254, libiconv 255, libjack2 256, libjxl 257, libmodplug 258, libmysofa 259, libogg 260, libopenmpt 261, libopus 262, libplacebo 263, libplacebo_5 264, libpulseaudio 265, libraw1394 266, librsvg 267, libssh 268, libtensorflow 269, libtheora 270, libv4l 271, libva 272, libva-minimal 273, libvdpau 274, libvmaf 275, libvorbis 276, libvpl 277, libvpx 278, libwebp 279, libX11 280, libxcb 281, libXext 282, libxml2 283, libXv 284, nv-codec-headers 285, nv-codec-headers-12 286, ocl-icd # OpenCL ICD 287, openal 288, opencl-headers # OpenCL headers 289, opencore-amr 290, openh264 291, openjpeg 292, qrencode 293, quirc 294, rav1e 295, rtmpdump 296, twolame 297, samba 298, SDL2 299, shaderc 300, soxr 301, speex 302, srt 303, svt-av1 304, vid-stab 305, vo-amrwbenc 306, vulkan-headers 307, vulkan-loader 308, x264 309, x265 310, xavs 311, xevd 312, xeve 313, xvidcore 314, xz 315, zeromq4 316, zimg 317, zlib 318/* 319 * Darwin frameworks 320 */ 321, AppKit 322, AudioToolbox 323, AVFoundation 324, CoreImage 325, VideoToolbox 326, xcode # unfree contains metalcc and metallib 327/* 328 * Testing 329 */ 330, testers 331}: 332 333/* Maintainer notes: 334 * 335 * Version bumps: 336 * It should always be safe to bump patch releases (e.g. 2.1.x, x being a patch release) 337 * If adding a new branch, note any configure flags that were added, changed, or deprecated/removed 338 * and make the necessary changes. 339 * 340 * Known issues: 341 * Cross-compiling will disable features not present on host OS 342 * (e.g. dxva2 support [DirectX] will not be enabled unless natively compiled on Cygwin) 343 * 344 */ 345 346let 347 inherit (lib) optional optionals optionalString enableFeature versionOlder versionAtLeast; 348in 349 350 351assert lib.elem ffmpegVariant [ "headless" "small" "full" ]; 352 353/* 354 * Licensing dependencies 355 */ 356assert withGPLv3 -> withGPL && withVersion3; 357 358/* 359 * Build dependencies 360 */ 361assert withPixelutils -> buildAvutil; 362assert !(withMfx && withVpl); # incompatible features 363/* 364 * Program dependencies 365 */ 366assert buildFfmpeg -> buildAvcodec 367 && buildAvfilter 368 && buildAvformat 369 && (buildSwresample || buildAvresample); 370assert buildFfplay -> buildAvcodec 371 && buildAvformat 372 && buildSwscale 373 && (buildSwresample || buildAvresample); 374assert buildFfprobe -> buildAvcodec && buildAvformat; 375/* 376 * Library dependencies 377 */ 378assert buildAvcodec -> buildAvutil; # configure flag since 0.6 379assert buildAvdevice -> buildAvformat 380 && buildAvcodec 381 && buildAvutil; # configure flag since 0.6 382assert buildAvformat -> buildAvcodec && buildAvutil; # configure flag since 0.6 383assert buildPostproc -> buildAvutil; 384assert buildSwscale -> buildAvutil; 385 386/* 387 * External Library dependencies 388 */ 389assert (withCuda || withCuvid || withNvdec || withNvenc) -> withNvcodec; 390 391stdenv.mkDerivation (finalAttrs: { 392 pname = "ffmpeg" + (optionalString (ffmpegVariant != "small") "-${ffmpegVariant}"); 393 inherit version; 394 src = source; 395 396 postPatch = '' 397 patchShebangs . 398 '' + lib.optionalString withFrei0r '' 399 substituteInPlace libavfilter/vf_frei0r.c \ 400 --replace /usr/local/lib/frei0r-1 ${frei0r}/lib/frei0r-1 401 substituteInPlace doc/filters.texi \ 402 --replace /usr/local/lib/frei0r-1 ${frei0r}/lib/frei0r-1 403 ''; 404 405 patches = [] 406 ++ optionals (versionOlder version "5") [ 407 (fetchpatch2 { 408 name = "libsvtav1-1.5.0-compat-compressed_ten_bit_format.patch"; 409 url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/031f1561cd286596cdb374da32f8aa816ce3b135"; 410 hash = "sha256-agJgzIzrBTQBAypuCmGXXFo7vw6Iodw5Ny5O5QCKCn8="; 411 }) 412 (fetchpatch2 { 413 # Backport fix for binutils-2.41. 414 name = "binutils-2.41.patch"; 415 url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/effadce6c756247ea8bae32dc13bb3e6f464f0eb"; 416 hash = "sha256-vLSltvZVMcQ0CnkU0A29x6fJSywE8/aU+Mp9os8DZYY="; 417 }) 418 # The upstream patch isn’t for ffmpeg 4, but it will apply with a few tweaks. 419 # Fixes a crash when built with clang 16 due to UB in ff_seek_frame_binary. 420 (fetchpatch2 { 421 name = "utils-fix_crash_in_ff_seek_frame_binary.patch"; 422 url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/ab792634197e364ca1bb194f9abe36836e42f12d"; 423 hash = "sha256-vqqVACjbCcGL9Qvmg1QArSKqVmOqr8BEr+OxTBDt6mA="; 424 postFetch = '' 425 substituteInPlace "$out" \ 426 --replace libavformat/seek.c libavformat/utils.c \ 427 --replace 'const AVInputFormat *const ' 'const AVInputFormat *' 428 ''; 429 }) 430 (fetchpatch2 { 431 name = "CVE-2023-51794.patch"; 432 url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/50f0f8c53c818f73fe2d752708e2fa9d2a2d8a07"; 433 hash = "sha256-5G9lmKjMEa0+vqbA8EEiNIr6QG+PeEoIL+uZP4Hlo28="; 434 }) 435 ] 436 ++ optionals (lib.versionAtLeast version "6.1" && lib.versionOlder version "6.2") [ 437 (fetchpatch2 { # this can be removed post 6.1 438 name = "fix_build_failure_due_to_PropertyKey_EncoderID"; 439 url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/cb049d377f54f6b747667a93e4b719380c3e9475"; 440 hash = "sha256-sxRXKKgUak5vsQTiV7ge8vp+N22CdTIvuczNgVRP72c="; 441 }) 442 (fetchpatch2 { 443 name = "fix_vulkan_av1"; 444 url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/e06ce6d2b45edac4a2df04f304e18d4727417d24"; 445 hash = "sha256-73mlX1rdJrguw7OXaSItfHtI7gflDrFj+7SepVvvUIg="; 446 }) 447 (fetchpatch2 { 448 name = "CVE-2024-31582.patch"; 449 url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/99debe5f823f45a482e1dc08de35879aa9c74bd2"; 450 hash = "sha256-+CQ9FXR6Vr/AmsbXFiCUXZcxKj1s8nInEdke/Oc/kUA="; 451 }) 452 (fetchpatch2 { 453 name = "CVE-2024-31578.patch"; 454 url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/3bb00c0a420c3ce83c6fafee30270d69622ccad7"; 455 hash = "sha256-oZMZysBA+/gwaGEM1yvI+8wCadXWE7qLRL6Emap3b8Q="; 456 }) 457 (fetchpatch2 { 458 name = "CVE-2023-49501.patch"; 459 url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/4adb93dff05dd947878c67784d98c9a4e13b57a7"; 460 hash = "sha256-7cwktto3fPMDGvCZCVtB01X8Q9S/4V4bDLUICSNfGgw="; 461 }) 462 (fetchpatch2 { 463 name = "CVE-2023-49502.patch"; 464 url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/737ede405b11a37fdd61d19cf25df296a0cb0b75"; 465 hash = "sha256-mpSJwR9TX5ENjjCKvzuM/9e1Aj/AOiQW0+72oOMl9v8="; 466 }) 467 (fetchpatch2 { 468 name = "CVE-2023-50007.patch"; 469 url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/b1942734c7cbcdc9034034373abcc9ecb9644c47"; 470 hash = "sha256-v0hNcqBtm8GCGAU9UbRUCE0slodOjZCHrkS8e4TrVcQ="; 471 }) 472 (fetchpatch2 { 473 name = "CVE-2023-50008.patch"; 474 url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/5f87a68cf70dafeab2fb89b42e41a4c29053b89b"; 475 hash = "sha256-sqUUSOPTPLwu2h8GbAw4SfEf+0oWioz52BcpW1n4v3Y="; 476 }) 477 ] 478 ++ optionals (lib.versionAtLeast version "7.0" && lib.versionOlder version "7.0.1") [ 479 (fetchpatch2 { 480 # Will likely be obsolete in >7.0 481 name = "fate_avoid_dependency_on_samples"; 482 url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/7b7b7819bd21cc92ac07f6696b0e7f26fa8f9834"; 483 hash = "sha256-TKI289XqtG86Sj9s7mVYvmkjAuRXeK+2cYYEDkg6u6I="; 484 }) 485 ] 486 ++ optionals (lib.versionAtLeast version "7.0") [ 487 ./0001-avfoundation.m-macOS-SDK-10.12-compatibility.patch 488 ]; 489 490 configurePlatforms = []; 491 setOutputFlags = false; # Only accepts some of them 492 configureFlags = [ 493 #mingw64 is internally treated as mingw32, so 32 and 64 make no difference here 494 "--target_os=${if stdenv.hostPlatform.isMinGW then "mingw64" else stdenv.hostPlatform.parsed.kernel.name}" 495 "--arch=${stdenv.hostPlatform.parsed.cpu.name}" 496 "--pkg-config=${buildPackages.pkg-config.targetPrefix}pkg-config" 497 /* 498 * Licensing flags 499 */ 500 (enableFeature withGPL "gpl") 501 (enableFeature withVersion3 "version3") 502 (enableFeature withUnfree "nonfree") 503 /* 504 * Build flags 505 */ 506 (enableFeature withStatic "static") 507 (enableFeature withShared "shared") 508 (enableFeature withPic "pic") 509 (enableFeature withThumb "thumb") 510 511 (enableFeature withSmallBuild "small") 512 (enableFeature withRuntimeCPUDetection "runtime-cpudetect") 513 (enableFeature withGrayscale "gray") 514 (enableFeature withSwscaleAlpha "swscale-alpha") 515 (enableFeature withHardcodedTables "hardcoded-tables") 516 (enableFeature withSafeBitstreamReader "safe-bitstream-reader") 517 518 (enableFeature (withMultithread && stdenv.hostPlatform.isUnix) "pthreads") 519 (enableFeature (withMultithread && stdenv.hostPlatform.isWindows) "w32threads") 520 "--disable-os2threads" # We don't support OS/2 521 522 (enableFeature withNetwork "network") 523 (enableFeature withPixelutils "pixelutils") 524 525 "--datadir=${placeholder "data"}/share/ffmpeg" 526 527 /* 528 * Program flags 529 */ 530 (enableFeature buildFfmpeg "ffmpeg") 531 (enableFeature buildFfplay "ffplay") 532 (enableFeature buildFfprobe "ffprobe") 533 ] ++ optionals withBin [ 534 "--bindir=${placeholder "bin"}/bin" 535 ] ++ [ 536 /* 537 * Library flags 538 */ 539 (enableFeature buildAvcodec "avcodec") 540 (enableFeature buildAvdevice "avdevice") 541 (enableFeature buildAvfilter "avfilter") 542 (enableFeature buildAvformat "avformat") 543 ] ++ optionals (lib.versionOlder version "5") [ 544 # Ffmpeg > 4 doesn't know about the flag anymore 545 (enableFeature buildAvresample "avresample") 546 ] ++ [ 547 (enableFeature buildAvutil "avutil") 548 (enableFeature (buildPostproc && withGPL) "postproc") 549 (enableFeature buildSwresample "swresample") 550 (enableFeature buildSwscale "swscale") 551 ] ++ optionals withLib [ 552 "--libdir=${placeholder "lib"}/lib" 553 "--incdir=${placeholder "dev"}/include" 554 ] ++ [ 555 /* 556 * Documentation flags 557 */ 558 (enableFeature withDocumentation "doc") 559 (enableFeature withHtmlDoc "htmlpages") 560 (enableFeature withManPages "manpages") 561 ] ++ optionals withManPages [ 562 "--mandir=${placeholder "man"}/share/man" 563 ] ++ [ 564 (enableFeature withPodDoc "podpages") 565 (enableFeature withTxtDoc "txtpages") 566 ] ++ optionals withDoc [ 567 "--docdir=${placeholder "doc"}/share/doc/ffmpeg" 568 ] ++ [ 569 /* 570 * External libraries 571 */ 572 (enableFeature withAlsa "alsa") 573 (enableFeature withAom "libaom") 574 (enableFeature withAppKit "appkit") 575 ] ++ optionals (versionAtLeast version "6.1") [ 576 (enableFeature withAribcaption "libaribcaption") 577 ] ++ [ 578 (enableFeature withAss "libass") 579 (enableFeature withAudioToolbox "audiotoolbox") 580 (enableFeature withAvFoundation "avfoundation") 581 (enableFeature withAvisynth "avisynth") 582 (enableFeature withBluray "libbluray") 583 (enableFeature withBs2b "libbs2b") 584 (enableFeature withBzlib "bzlib") 585 (enableFeature withCaca "libcaca") 586 (enableFeature withCelt "libcelt") 587 (enableFeature withChromaprint "chromaprint") 588 (enableFeature withCodec2 "libcodec2") 589 (enableFeature withCoreImage "coreimage") 590 (enableFeature withCuda "cuda") 591 (enableFeature withCudaLLVM "cuda-llvm") 592 (enableFeature withCuvid "cuvid") 593 (enableFeature withDav1d "libdav1d") 594 (enableFeature withDc1394 "libdc1394") 595 (enableFeature withDrm "libdrm") 596 ] ++ optionals (versionAtLeast version "7") [ 597 (enableFeature withDvdnav "libdvdnav") 598 (enableFeature withDvdread "libdvdread") 599 ] ++ [ 600 (enableFeature withFdkAac "libfdk-aac") 601 (enableFeature withNvcodec "ffnvcodec") 602 (enableFeature withFlite "libflite") 603 (enableFeature withFontconfig "fontconfig") 604 (enableFeature withFontconfig "libfontconfig") 605 (enableFeature withFreetype "libfreetype") 606 (enableFeature withFrei0r "frei0r") 607 (enableFeature withFribidi "libfribidi") 608 (enableFeature withGme "libgme") 609 (enableFeature withGnutls "gnutls") 610 (enableFeature withGsm "libgsm") 611 ] ++ optionals (versionAtLeast version "6.1") [ 612 (enableFeature withHarfbuzz "libharfbuzz") 613 ] ++ [ 614 (enableFeature withIconv "iconv") 615 (enableFeature withJack "libjack") 616 ] ++ optionals (versionAtLeast finalAttrs.version "5.0") [ 617 (enableFeature withJxl "libjxl") 618 ] ++ [ 619 (enableFeature withLadspa "ladspa") 620 ] ++ optionals (versionAtLeast version "5.1") [ 621 (enableFeature withLcms2 "lcms2") 622 ] ++ [ 623 (enableFeature withLzma "lzma") 624 ] ++ optionals (versionAtLeast version "5.0") [ 625 (enableFeature withMetal "metal") 626 ] ++ [ 627 (enableFeature withMfx "libmfx") 628 (enableFeature withModplug "libmodplug") 629 (enableFeature withMp3lame "libmp3lame") 630 (enableFeature withMysofa "libmysofa") 631 (enableFeature withNvdec "nvdec") 632 (enableFeature withNvenc "nvenc") 633 (enableFeature withOpenal "openal") 634 (enableFeature withOpencl "opencl") 635 (enableFeature withOpencoreAmrnb "libopencore-amrnb") 636 (enableFeature withOpencoreAmrwb "libopencore-amrwb") 637 (enableFeature withOpengl "opengl") 638 (enableFeature withOpenh264 "libopenh264") 639 (enableFeature withOpenjpeg "libopenjpeg") 640 (enableFeature withOpenmpt "libopenmpt") 641 (enableFeature withOpus "libopus") 642 ] ++ optionals (versionAtLeast version "5.0") [ 643 (enableFeature withPlacebo "libplacebo") 644 ] ++ [ 645 (enableFeature withPulse "libpulse") 646 ] ++ optionals (versionAtLeast version "7") [ 647 (enableFeature withQrencode "libqrencode") 648 (enableFeature withQuirc "libquirc") 649 ] ++ [ 650 (enableFeature withRav1e "librav1e") 651 (enableFeature withRtmp "librtmp") 652 (enableFeature withSamba "libsmbclient") 653 (enableFeature withSdl2 "sdl2") 654 ] ++ optionals (versionAtLeast version "5.0") [ 655 (enableFeature withShaderc "libshaderc") 656 ] ++ [ 657 (enableFeature withSoxr "libsoxr") 658 (enableFeature withSpeex "libspeex") 659 (enableFeature withSrt "libsrt") 660 (enableFeature withSsh "libssh") 661 (enableFeature withSvg "librsvg") 662 (enableFeature withSvtav1 "libsvtav1") 663 (enableFeature withTensorflow "libtensorflow") 664 (enableFeature withTheora "libtheora") 665 (enableFeature withTwolame "libtwolame") 666 (enableFeature withV4l2 "libv4l2") 667 (enableFeature withV4l2M2m "v4l2-m2m") 668 (enableFeature withVaapi "vaapi") 669 (enableFeature withVdpau "vdpau") 670 ] ++ optionals (versionAtLeast version "6.0") [ 671 (enableFeature withVpl "libvpl") 672 ] ++ [ 673 (enableFeature withVideoToolbox "videotoolbox") 674 (enableFeature withVidStab "libvidstab") # Actual min. version 2.0 675 (enableFeature withVmaf "libvmaf") 676 (enableFeature withVoAmrwbenc "libvo-amrwbenc") 677 (enableFeature withVorbis "libvorbis") 678 (enableFeature withVpx "libvpx") 679 (enableFeature withVulkan "vulkan") 680 (enableFeature withWebp "libwebp") 681 (enableFeature withX264 "libx264") 682 (enableFeature withX265 "libx265") 683 (enableFeature withXavs "libxavs") 684 (enableFeature withXcb "libxcb") 685 (enableFeature withXcbShape "libxcb-shape") 686 (enableFeature withXcbShm "libxcb-shm") 687 (enableFeature withXcbxfixes "libxcb-xfixes") 688 ] ++ optionals (versionAtLeast version "7") [ 689 (enableFeature withXevd "libxevd") 690 (enableFeature withXeve "libxeve") 691 ] ++ [ 692 (enableFeature withXlib "xlib") 693 (enableFeature withXml2 "libxml2") 694 (enableFeature withXvid "libxvid") 695 (enableFeature withZimg "libzimg") 696 (enableFeature withZlib "zlib") 697 (enableFeature withZmq "libzmq") 698 /* 699 * Developer flags 700 */ 701 (enableFeature withDebug "debug") 702 (enableFeature withOptimisations "optimizations") 703 (enableFeature withExtraWarnings "extra-warnings") 704 (enableFeature withStripping "stripping") 705 ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 706 "--cross-prefix=${stdenv.cc.targetPrefix}" 707 "--enable-cross-compile" 708 "--host-cc=${buildPackages.stdenv.cc}/bin/cc" 709 ] ++ optionals stdenv.cc.isClang [ 710 "--cc=clang" 711 "--cxx=clang++" 712 ] ++ optionals withMetal [ 713 "--metalcc=${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metal" 714 "--metallib=${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metallib" 715 ]; 716 717 # ffmpeg embeds the configureFlags verbatim in its binaries and because we 718 # configure binary, include, library dir etc., this causes references in 719 # outputs where we don't want them. Patch the generated config.h to remove all 720 # such references except for data. 721 postConfigure = let 722 toStrip = map placeholder (lib.remove "data" finalAttrs.outputs) # We want to keep references to the data dir. 723 ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) buildPackages.stdenv.cc 724 ++ lib.optional withMetal xcode; 725 in 726 "remove-references-to ${lib.concatStringsSep " " (map (o: "-t ${o}") toStrip)} config.h"; 727 728 strictDeps = true; 729 730 nativeBuildInputs = [ removeReferencesTo addDriverRunpath perl pkg-config yasm ] 731 # Texinfo version 7.1 introduced breaking changes, which older versions of ffmpeg do not handle. 732 ++ (if versionOlder version "5" then [ texinfo6 ] else [ texinfo ]) 733 ++ optionals withCudaLLVM [ clang ]; 734 735 buildInputs = [] 736 ++ optionals withAlsa [ alsa-lib ] 737 ++ optionals withAom [ libaom ] 738 ++ optionals withAppKit [ AppKit ] 739 ++ optionals withAribcaption [ libaribcaption ] 740 ++ optionals withAss [ libass ] 741 ++ optionals withAudioToolbox [ AudioToolbox ] 742 ++ optionals withAvFoundation [ AVFoundation ] 743 ++ optionals withAvisynth [ avisynthplus ] 744 ++ optionals withBluray [ libbluray ] 745 ++ optionals withBs2b [ libbs2b ] 746 ++ optionals withBzlib [ bzip2 ] 747 ++ optionals withCaca [ libcaca ] 748 ++ optionals withCelt [ celt ] 749 ++ optionals withChromaprint [ chromaprint ] 750 ++ optionals withCodec2 [ codec2 ] 751 ++ optionals withCoreImage [ CoreImage ] 752 ++ optionals withDav1d [ dav1d ] 753 ++ optionals withDc1394 [ libdc1394 libraw1394 ] 754 ++ optionals withDrm [ libdrm ] 755 ++ optionals withDvdnav [ libdvdnav ] 756 ++ optionals withDvdread [ libdvdread ] 757 ++ optionals withFdkAac [ fdk_aac ] 758 ++ optionals withNvcodec [ (if (lib.versionAtLeast version "6") then nv-codec-headers-12 else nv-codec-headers) ] 759 ++ optionals withFlite [ flite ] 760 ++ optionals withFontconfig [ fontconfig ] 761 ++ optionals withFreetype [ freetype ] 762 ++ optionals withFrei0r [ frei0r ] 763 ++ optionals withFribidi [ fribidi ] 764 ++ optionals withGme [ game-music-emu ] 765 ++ optionals withGnutls [ gnutls ] 766 ++ optionals withGsm [ gsm ] 767 ++ optionals withHarfbuzz [ harfbuzz ] 768 ++ optionals withIconv [ libiconv ] # On Linux this should be in libc, do we really need it? 769 ++ optionals withJack [ libjack2 ] 770 ++ optionals withJxl [ libjxl ] 771 ++ optionals withLadspa [ ladspaH ] 772 ++ optionals withLcms2 [ lcms2 ] 773 ++ optionals withLzma [ xz ] 774 ++ optionals withMfx [ intel-media-sdk ] 775 ++ optionals withModplug [ libmodplug ] 776 ++ optionals withMp3lame [ lame ] 777 ++ optionals withMysofa [ libmysofa ] 778 ++ optionals withOgg [ libogg ] 779 ++ optionals withOpenal [ openal ] 780 ++ optionals withOpencl [ ocl-icd opencl-headers ] 781 ++ optionals (withOpencoreAmrnb || withOpencoreAmrwb) [ opencore-amr ] 782 ++ optionals withOpengl [ libGL libGLU ] 783 ++ optionals withOpenh264 [ openh264 ] 784 ++ optionals withOpenjpeg [ openjpeg ] 785 ++ optionals withOpenmpt [ libopenmpt ] 786 ++ optionals withOpus [ libopus ] 787 ++ optionals withPlacebo [ (if (lib.versionAtLeast version "6.1") then libplacebo else libplacebo_5) vulkan-headers ] 788 ++ optionals withPulse [ libpulseaudio ] 789 ++ optionals withQrencode [ qrencode ] 790 ++ optionals withQuirc [ quirc ] 791 ++ optionals withRav1e [ rav1e ] 792 ++ optionals withRtmp [ rtmpdump ] 793 ++ optionals withSamba [ samba ] 794 ++ optionals withSdl2 [ SDL2 ] 795 ++ optionals withShaderc [ shaderc ] 796 ++ optionals withSoxr [ soxr ] 797 ++ optionals withSpeex [ speex ] 798 ++ optionals withSrt [ srt ] 799 ++ optionals withSsh [ libssh ] 800 ++ optionals withSvg [ librsvg ] 801 ++ optionals withSvtav1 [ svt-av1 ] 802 ++ optionals withTensorflow [ libtensorflow ] 803 ++ optionals withTheora [ libtheora ] 804 ++ optionals withTwolame [ twolame ] 805 ++ optionals withV4l2 [ libv4l ] 806 ++ optionals withVaapi [ (if withSmallDeps then libva else libva-minimal) ] 807 ++ optionals withVdpau [ libvdpau ] 808 ++ optionals withVideoToolbox [ VideoToolbox ] 809 ++ optionals withVidStab [ vid-stab ] 810 ++ optionals withVmaf [ libvmaf ] 811 ++ optionals withVoAmrwbenc [ vo-amrwbenc ] 812 ++ optionals withVorbis [ libvorbis ] 813 ++ optionals withVpl [ libvpl ] 814 ++ optionals withVpx [ libvpx ] 815 ++ optionals withVulkan [ vulkan-headers vulkan-loader ] 816 ++ optionals withWebp [ libwebp ] 817 ++ optionals withX264 [ x264 ] 818 ++ optionals withX265 [ x265 ] 819 ++ optionals withXavs [ xavs ] 820 ++ optionals withXcb [ libxcb ] 821 ++ optionals withXevd [ xevd ] 822 ++ optionals withXeve [ xeve ] 823 ++ optionals withXlib [ libX11 libXv libXext ] 824 ++ optionals withXml2 [ libxml2 ] 825 ++ optionals withXvid [ xvidcore ] 826 ++ optionals withZimg [ zimg ] 827 ++ optionals withZlib [ zlib ] 828 ++ optionals withZmq [ zeromq4 ] 829 ; 830 831 buildFlags = [ "all" ] 832 ++ optional buildQtFaststart "tools/qt-faststart"; # Build qt-faststart executable 833 834 doCheck = stdenv.hostPlatform == stdenv.buildPlatform; 835 836 # Fails with SIGABRT otherwise FIXME: Why? 837 checkPhase = let 838 ldLibraryPathEnv = if stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH"; 839 libsToLink = [ ] 840 ++ optional buildAvcodec "libavcodec" 841 ++ optional buildAvdevice "libavdevice" 842 ++ optional buildAvfilter "libavfilter" 843 ++ optional buildAvformat "libavformat" 844 ++ optional buildAvresample "libavresample" 845 ++ optional buildAvutil "libavutil" 846 ++ optional buildPostproc "libpostproc" 847 ++ optional buildSwresample "libswresample" 848 ++ optional buildSwscale "libswscale" 849 ; 850 in '' 851 ${ldLibraryPathEnv}="${lib.concatStringsSep ":" libsToLink}" make check -j$NIX_BUILD_CORES 852 ''; 853 854 outputs = optionals withBin [ "bin" ] # The first output is the one that gets symlinked by default! 855 ++ optionals withLib [ "lib" "dev" ] 856 ++ optionals withDoc [ "doc" ] 857 ++ optionals withManPages [ "man" ] 858 ++ [ "data" "out" ] # We need an "out" output because we get an error otherwise. It's just an empty dir. 859 ; 860 861 postInstall = optionalString buildQtFaststart '' 862 install -D tools/qt-faststart -t $bin/bin 863 ''; 864 865 # Set RUNPATH so that libnvcuvid and libcuda in /run/opengl-driver(-32)/lib can be found. 866 # See the explanation in addDriverRunpath. 867 postFixup = optionalString (stdenv.isLinux && withLib) '' 868 addDriverRunpath ${placeholder "lib"}/lib/libavcodec.so 869 addDriverRunpath ${placeholder "lib"}/lib/libavutil.so 870 '' 871 # https://trac.ffmpeg.org/ticket/10809 872 + optionalString (versionAtLeast version "5.0" && withVulkan && !stdenv.hostPlatform.isMinGW) '' 873 patchelf $lib/lib/libavcodec.so --add-needed libvulkan.so --add-rpath ${lib.makeLibraryPath [ vulkan-loader ]} 874 ''; 875 876 enableParallelBuilding = true; 877 878 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 879 880 meta = with lib; { 881 description = "Complete, cross-platform solution to record, convert and stream audio and video"; 882 homepage = "https://www.ffmpeg.org/"; 883 changelog = "https://github.com/FFmpeg/FFmpeg/blob/n${version}/Changelog"; 884 longDescription = '' 885 FFmpeg is the leading multimedia framework, able to decode, encode, transcode, 886 mux, demux, stream, filter and play pretty much anything that humans and machines 887 have created. It supports the most obscure ancient formats up to the cutting edge. 888 No matter if they were designed by some standards committee, the community or 889 a corporation. 890 ''; 891 license = with licenses; [ lgpl21Plus ] 892 ++ optional withGPL gpl2Plus 893 ++ optional withVersion3 lgpl3Plus 894 ++ optional withGPLv3 gpl3Plus 895 ++ optional withUnfree unfreeRedistributable 896 ++ optional (withGPL && withUnfree) unfree; 897 pkgConfigModules = [ ] 898 ++ optional buildAvcodec "libavcodec" 899 ++ optional buildAvdevice "libavdevice" 900 ++ optional buildAvfilter "libavfilter" 901 ++ optional buildAvformat "libavformat" 902 ++ optional buildAvresample "libavresample" 903 ++ optional buildAvutil "libavutil" 904 ++ optional buildPostproc "libpostproc" 905 ++ optional buildSwresample "libswresample" 906 ++ optional buildSwscale "libswscale"; 907 platforms = platforms.all; 908 # See https://github.com/NixOS/nixpkgs/pull/295344#issuecomment-1992263658 909 broken = stdenv.hostPlatform.isMinGW && stdenv.hostPlatform.is64bit; 910 maintainers = with maintainers; [ atemu jopejoe1 ]; 911 mainProgram = "ffmpeg"; 912 }; 913} // lib.optionalAttrs withCudaLLVM { 914 # remove once https://github.com/NixOS/nixpkgs/issues/318674 is addressed properly 915 hardeningDisable = [ "zerocallusedregs" ]; 916})