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