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