2024-07-31 10:19:44 +00:00
{ lib , stdenv , buildPackages , removeReferencesTo , addDriverRunpath , pkg-config , perl , texinfo , texinfo6 , yasm
2023-02-16 17:41:37 +00:00
2024-04-21 15:54:59 +00:00
# You can fetch any upstream version using this derivation by specifying version and hash
# NOTICE: Always use this argument to override the version. Do not use overrideAttrs.
, version # ffmpeg ABI version. Also declare this if you're overriding the source.
, hash ? " " # hash of the upstream source for the given ABI version
, source ? fetchgit {
url = " h t t p s : / / g i t . f f m p e g . o r g / f f m p e g . g i t " ;
rev = " n ${ version } " ;
inherit hash ;
}
2023-02-16 17:41:37 +00:00
, ffmpegVariant ? " s m a l l " # Decides which dependencies are enabled by default
# Build with headless deps; excludes dependencies that are only necessary for
# GUI applications. To be used for purposes that don't generally need such
# components and i.e. only depend on libav
, withHeadlessDeps ? ffmpegVariant == " h e a d l e s s " || withSmallDeps
# Dependencies a user might customarily expect from a regular ffmpeg build.
# /All/ packages that depend on ffmpeg and some of its feaures should depend
# on the small variant. Small means the minimal set of features that satisfies
# all dependants in Nixpkgs
, withSmallDeps ? ffmpegVariant == " s m a l l " || withFullDeps
# Everything enabled; only guarded behind platform exclusivity or brokeness.
# If you need to depend on ffmpeg-full because ffmpeg is missing some feature
# your package needs, you should enable that feature in regular ffmpeg
# instead.
, withFullDeps ? ffmpegVariant == " f u l l "
, fetchgit
2024-04-21 15:54:59 +00:00
, fetchpatch2
2023-02-16 17:41:37 +00:00
# Feature flags
, withAlsa ? withHeadlessDeps && stdenv . isLinux # Alsa in/output supporT
, withAom ? withFullDeps # AV1 reference encoder
2024-04-21 15:54:59 +00:00
, withAppKit ? withHeadlessDeps && stdenv . isDarwin # Apple AppKit framework
2024-01-13 08:15:51 +00:00
, withAribcaption ? withFullDeps && lib . versionAtLeast version " 6 . 1 " # ARIB STD-B24 Caption Decoder/Renderer
2023-02-16 17:41:37 +00:00
, withAss ? withHeadlessDeps && stdenv . hostPlatform == stdenv . buildPlatform # (Advanced) SubStation Alpha subtitle rendering
2024-04-21 15:54:59 +00:00
, withAudioToolbox ? withHeadlessDeps && stdenv . isDarwin # Apple AudioToolbox
, withAvFoundation ? withHeadlessDeps && stdenv . isDarwin # Apple AVFoundation framework
2024-05-15 15:35:15 +00:00
, withAvisynth ? withFullDeps # AviSynth script files reading
2023-02-16 17:41:37 +00:00
, withBluray ? withFullDeps # BluRay reading
, withBs2b ? withFullDeps # bs2b DSP library
, withBzlib ? withHeadlessDeps
, withCaca ? withFullDeps # Textual display (ASCII art)
, withCelt ? withFullDeps # CELT decoder
2024-02-29 20:09:43 +00:00
, withChromaprint ? withFullDeps # Audio fingerprinting
2024-05-15 15:35:15 +00:00
, withCodec2 ? withFullDeps # codec2 en/decoding
2024-04-21 15:54:59 +00:00
, withCoreImage ? withHeadlessDeps && stdenv . isDarwin # Apple CoreImage framework
, withCuda ? withFullDeps && withNvcodec
2023-02-16 17:41:37 +00:00
, withCudaLLVM ? withFullDeps
2024-04-21 15:54:59 +00:00
, withCuvid ? withHeadlessDeps && withNvcodec
2023-02-16 17:41:37 +00:00
, withDav1d ? withHeadlessDeps # AV1 decoder (focused on speed and correctness)
, withDc1394 ? withFullDeps && ! stdenv . isDarwin # IIDC-1394 grabbing (ieee 1394)
, withDrm ? withHeadlessDeps && ( with stdenv ; isLinux || isFreeBSD ) # libdrm support
2024-04-21 15:54:59 +00:00
, withDvdnav ? withFullDeps && withGPL && lib . versionAtLeast version " 7 " # needed for DVD demuxing
, withDvdread ? withFullDeps && withGPL && lib . versionAtLeast version " 7 " # needed for DVD demuxing
, withFdkAac ? withFullDeps && ( ! withGPL || withUnfree ) # Fraunhofer FDK AAC de/encoder
, withNvcodec ? withHeadlessDeps && ( with stdenv ; ! isDarwin && ! isAarch32 && ! hostPlatform . isRiscV && hostPlatform == buildPlatform ) # dynamically linked Nvidia code
2024-02-29 20:09:43 +00:00
, withFlite ? withFullDeps # Voice Synthesis
2023-02-16 17:41:37 +00:00
, withFontconfig ? withHeadlessDeps # Needed for drawtext filter
, withFreetype ? withHeadlessDeps # Needed for drawtext filter
2024-02-29 20:09:43 +00:00
, withFrei0r ? withFullDeps && withGPL # frei0r video filtering
2023-02-16 17:41:37 +00:00
, withFribidi ? withFullDeps # Needed for drawtext filter
, withGme ? withFullDeps # Game Music Emulator
, withGnutls ? withHeadlessDeps
, withGsm ? withFullDeps # GSM de/encoder
2024-02-29 20:09:43 +00:00
, withHarfbuzz ? withHeadlessDeps && lib . versionAtLeast version " 6 . 1 " # Needed for drawtext filter
2023-02-16 17:41:37 +00:00
, withIconv ? withHeadlessDeps
, withJack ? withFullDeps && ! stdenv . isDarwin # Jack audio
2024-05-15 15:35:15 +00:00
, withJxl ? withFullDeps && lib . versionAtLeast version " 5 " # JPEG XL de/encoding
2023-02-16 17:41:37 +00:00
, withLadspa ? withFullDeps # LADSPA audio filtering
2024-07-31 10:19:44 +00:00
, withLcms2 ? withFullDeps # ICC profile support via lcms2
2023-02-16 17:41:37 +00:00
, withLzma ? withHeadlessDeps # xz-utils
2024-07-27 06:49:29 +00:00
, withMetal ? false # Unfree and requires manual downloading of files
2024-01-02 11:29:13 +00:00
, withMfx ? withFullDeps && ( with stdenv . hostPlatform ; isLinux && ! isAarch ) # Hardware acceleration via intel-media-sdk/libmfx
2023-02-16 17:41:37 +00:00
, withModplug ? withFullDeps && ! stdenv . isDarwin # ModPlug support
, withMp3lame ? withHeadlessDeps # LAME MP3 encoder
, withMysofa ? withFullDeps # HRTF support via SOFAlizer
2024-04-21 15:54:59 +00:00
, withNvdec ? withHeadlessDeps && withNvcodec
, withNvenc ? withHeadlessDeps && withNvcodec
2023-02-16 17:41:37 +00:00
, withOgg ? withHeadlessDeps # Ogg container used by vorbis & theora
, withOpenal ? withFullDeps # OpenAL 1.1 capture support
, withOpencl ? withFullDeps
2024-04-21 15:54:59 +00:00
, withOpencoreAmrnb ? withFullDeps && withVersion3 # AMR-NB de/encoder
, withOpencoreAmrwb ? withFullDeps && withVersion3 # AMR-WB decoder
, withOpengl ? withFullDeps && ! stdenv . isDarwin # OpenGL rendering
2023-02-16 17:41:37 +00:00
, withOpenh264 ? withFullDeps # H.264/AVC encoder
, withOpenjpeg ? withFullDeps # JPEG 2000 de/encoder
, withOpenmpt ? withFullDeps # Tracked music files decoder
, withOpus ? withHeadlessDeps # Opus de/encoder
2024-02-29 20:09:43 +00:00
, withPlacebo ? withFullDeps && ! stdenv . isDarwin # libplacebo video processing library
2024-04-21 15:54:59 +00:00
, withPulse ? withSmallDeps && stdenv . isLinux # Pulseaudio input support
, withQrencode ? withFullDeps && lib . versionAtLeast version " 7 " # QR encode generation
, withQuirc ? withFullDeps && lib . versionAtLeast version " 7 " # QR decoding
2023-02-16 17:41:37 +00:00
, withRav1e ? withFullDeps # AV1 encoder (focused on speed and safety)
2024-04-21 15:54:59 +00:00
, withRtmp ? withFullDeps # RTMP[E] support
2024-02-29 20:09:43 +00:00
, withSamba ? withFullDeps && ! stdenv . isDarwin && withGPLv3 # Samba protocol
2023-02-16 17:41:37 +00:00
, withSdl2 ? withSmallDeps
2024-01-25 14:12:00 +00:00
, withShaderc ? withFullDeps && ! stdenv . isDarwin && lib . versionAtLeast version " 5 . 0 "
2023-02-16 17:41:37 +00:00
, withSoxr ? withHeadlessDeps # Resampling via soxr
, withSpeex ? withHeadlessDeps # Speex de/encoder
, withSrt ? withHeadlessDeps # Secure Reliable Transport (SRT) protocol
, withSsh ? withHeadlessDeps # SFTP protocol
, withSvg ? withFullDeps # SVG protocol
2024-04-21 15:54:59 +00:00
, withSvtav1 ? withHeadlessDeps && ! stdenv . isAarch64 && ! stdenv . hostPlatform . isMinGW # AV1 encoder/decoder (focused on speed and correctness)
, withTensorflow ? false # Tensorflow dnn backend support (Increases closure size by ~390 MiB)
2023-02-16 17:41:37 +00:00
, withTheora ? withHeadlessDeps # Theora encoder
2024-07-27 06:49:29 +00:00
, withTwolame ? withFullDeps # MP2 encoding
2024-04-21 15:54:59 +00:00
, withV4l2 ? withHeadlessDeps && stdenv . isLinux # Video 4 Linux support
2023-02-16 17:41:37 +00:00
, withV4l2M2m ? withV4l2
, withVaapi ? withHeadlessDeps && ( with stdenv ; isLinux || isFreeBSD ) # Vaapi hardware acceleration
2024-04-21 15:54:59 +00:00
, withVdpau ? withSmallDeps && ! stdenv . hostPlatform . isMinGW # Vdpau hardware acceleration
, withVideoToolbox ? withHeadlessDeps && stdenv . isDarwin # Apple VideoToolbox
2024-02-29 20:09:43 +00:00
, withVidStab ? withFullDeps && withGPL # Video stabilization
, withVmaf ? withFullDeps && ! stdenv . isAarch64 && lib . versionAtLeast version " 5 " # Netflix's VMAF (Video Multi-Method Assessment Fusion)
, withVoAmrwbenc ? withFullDeps && withVersion3 # AMR-WB encoder
2023-02-16 17:41:37 +00:00
, withVorbis ? withHeadlessDeps # Vorbis de/encoding, native encoder exists
2024-04-21 15:54:59 +00:00
, withVpl ? false # Hardware acceleration via intel libvpl
2023-02-16 17:41:37 +00:00
, withVpx ? withHeadlessDeps && stdenv . buildPlatform == stdenv . hostPlatform # VP8 & VP9 de/encoding
2024-04-21 15:54:59 +00:00
, withVulkan ? withSmallDeps && ! stdenv . isDarwin
2023-02-16 17:41:37 +00:00
, withWebp ? withFullDeps # WebP encoder
2024-02-29 20:09:43 +00:00
, withX264 ? withHeadlessDeps && withGPL # H.264/AVC encoder
, withX265 ? withHeadlessDeps && withGPL # H.265/HEVC encoder
, withXavs ? withFullDeps && withGPL # AVS encoder
2023-02-16 17:41:37 +00:00
, withXcb ? withXcbShm || withXcbxfixes || withXcbShape # X11 grabbing using XCB
, withXcbShape ? withFullDeps # X11 grabbing shape rendering
, withXcbShm ? withFullDeps # X11 grabbing shm communication
, withXcbxfixes ? withFullDeps # X11 grabbing mouse rendering
2024-07-27 06:49:29 +00:00
# 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.
, withXevd ? withFullDeps && lib . versionAtLeast version " 7 " && stdenv . hostPlatform . isx86 && stdenv . cc . isGNU # MPEG-5 EVC decoding
, withXeve ? withFullDeps && lib . versionAtLeast version " 7 " && stdenv . hostPlatform . isx86 && stdenv . cc . isGNU # MPEG-5 EVC encoding
2023-02-16 17:41:37 +00:00
, withXlib ? withFullDeps # Xlib support
, withXml2 ? withFullDeps # libxml2 support, for IMF and DASH demuxers
2024-02-29 20:09:43 +00:00
, withXvid ? withHeadlessDeps && withGPL # Xvid encoder, native encoder exists
2023-02-16 17:41:37 +00:00
, withZimg ? withHeadlessDeps
, withZlib ? withHeadlessDeps
, withZmq ? withFullDeps # Message passing
/*
* Licensing options ( yes some are listed twice , filters and such are not listed )
* /
, withGPL ? true
2024-02-29 20:09:43 +00:00
, withVersion3 ? true # When withGPL is set this implies GPLv3 otherwise it is LGPLv3
, withGPLv3 ? withGPL && withVersion3
2023-02-16 17:41:37 +00:00
, withUnfree ? false
/*
* Build options
* /
, withSmallBuild ? false # Optimize for size instead of speed
, withRuntimeCPUDetection ? true # Detect CPU capabilities at runtime (disable to compile natively)
, withGrayscale ? withFullDeps # Full grayscale support
, withSwscaleAlpha ? buildSwscale # Alpha channel support in swscale. You probably want this when buildSwscale.
, withHardcodedTables ? withHeadlessDeps # Hardcode decode tables instead of runtime generation
, withSafeBitstreamReader ? withHeadlessDeps # Buffer boundary checking in bitreaders
, withMultithread ? true # Multithreading via pthreads/win32 threads
, withNetwork ? withHeadlessDeps # Network support
, withPixelutils ? withHeadlessDeps # Pixel utils in libavutil
2024-02-29 20:09:43 +00:00
, withStatic ? stdenv . hostPlatform . isStatic
, withShared ? ! stdenv . hostPlatform . isStatic
, withPic ? true
, withThumb ? false # On some ARM platforms
2023-02-16 17:41:37 +00:00
/*
* Program options
* /
, buildFfmpeg ? withHeadlessDeps # Build ffmpeg executable
2024-04-21 15:54:59 +00:00
, buildFfplay ? withSmallDeps # Build ffplay executable
2023-02-16 17:41:37 +00:00
, buildFfprobe ? withHeadlessDeps # Build ffprobe executable
, buildQtFaststart ? withFullDeps # Build qt-faststart executable
, withBin ? buildFfmpeg || buildFfplay || buildFfprobe || buildQtFaststart
/*
* Library options
* /
, buildAvcodec ? withHeadlessDeps # Build avcodec library
, buildAvdevice ? withHeadlessDeps # Build avdevice library
, buildAvfilter ? withHeadlessDeps # Build avfilter library
, buildAvformat ? withHeadlessDeps # Build avformat library
# Deprecated but depended upon by some packages.
# https://github.com/NixOS/nixpkgs/pull/211834#issuecomment-1417435991)
, buildAvresample ? withHeadlessDeps && lib . versionOlder version " 5 " # Build avresample library
, buildAvutil ? withHeadlessDeps # Build avutil library
, buildPostproc ? withHeadlessDeps # Build postproc library
, buildSwresample ? withHeadlessDeps # Build swresample library
, buildSwscale ? withHeadlessDeps # Build swscale library
, withLib ? buildAvcodec
|| buildAvdevice
|| buildAvfilter
|| buildAvformat
|| buildAvutil
|| buildPostproc
|| buildSwresample
|| buildSwscale
/*
* Documentation options
* /
, withDocumentation ? withHtmlDoc || withManPages || withPodDoc || withTxtDoc
, withHtmlDoc ? withHeadlessDeps # HTML documentation pages
, withManPages ? withHeadlessDeps # Man documentation pages
, withPodDoc ? withHeadlessDeps # POD documentation pages
, withTxtDoc ? withHeadlessDeps # Text documentation pages
# Whether a "doc" output will be produced. Note that withManPages does not produce
# a "doc" output because its files go to "man".
, withDoc ? withDocumentation && ( withHtmlDoc || withPodDoc || withTxtDoc )
/*
* Developer options
* /
, withDebug ? false
, withOptimisations ? true
, withExtraWarnings ? false
, withStripping ? false
/*
* External libraries options
* /
, alsa-lib
2024-05-15 15:35:15 +00:00
, avisynthplus
2023-02-16 17:41:37 +00:00
, bzip2
, celt
2024-02-29 20:09:43 +00:00
, chromaprint
2024-05-15 15:35:15 +00:00
, codec2
2024-01-13 08:15:51 +00:00
, clang
2023-02-16 17:41:37 +00:00
, dav1d
, fdk_aac
2024-02-29 20:09:43 +00:00
, flite
2023-02-16 17:41:37 +00:00
, fontconfig
, freetype
, frei0r
, fribidi
, game-music-emu
, gnutls
, gsm
2024-02-29 20:09:43 +00:00
, harfbuzz
2024-01-13 08:15:51 +00:00
, intel-media-sdk
2023-02-16 17:41:37 +00:00
, ladspaH
, lame
2024-07-31 10:19:44 +00:00
, lcms2
2023-02-16 17:41:37 +00:00
, libaom
2024-01-13 08:15:51 +00:00
, libaribcaption
, libass
2023-02-16 17:41:37 +00:00
, libbluray
, libbs2b
, libcaca
, libdc1394
, libdrm
2024-04-21 15:54:59 +00:00
, libdvdnav
, libdvdread
2024-01-13 08:15:51 +00:00
, libGL
, libGLU
2023-02-16 17:41:37 +00:00
, libiconv
2024-01-13 08:15:51 +00:00
, libjack2
2024-05-15 15:35:15 +00:00
, libjxl
2023-02-16 17:41:37 +00:00
, libmodplug
, libmysofa
, libogg
, libopenmpt
, libopus
2023-04-29 16:46:19 +00:00
, libplacebo
2024-01-25 14:12:00 +00:00
, libplacebo_5
2024-01-13 08:15:51 +00:00
, libpulseaudio
, libraw1394
2023-02-16 17:41:37 +00:00
, librsvg
, libssh
2023-05-24 13:37:59 +00:00
, libtensorflow
2023-02-16 17:41:37 +00:00
, libtheora
, libv4l
, libva
, libva-minimal
, libvdpau
, libvmaf
, libvorbis
2024-04-21 15:54:59 +00:00
, libvpl
2023-02-16 17:41:37 +00:00
, libvpx
, libwebp
, libX11
, libxcb
, libXext
, libxml2
2024-01-13 08:15:51 +00:00
, libXv
2023-02-16 17:41:37 +00:00
, nv-codec-headers
2024-01-13 08:15:51 +00:00
, nv-codec-headers-12
2023-02-16 17:41:37 +00:00
, ocl-icd # OpenCL ICD
2024-01-13 08:15:51 +00:00
, openal
2023-02-16 17:41:37 +00:00
, opencl-headers # OpenCL headers
, opencore-amr
, openh264
, openjpeg
2024-04-21 15:54:59 +00:00
, qrencode
, quirc
2023-02-16 17:41:37 +00:00
, rav1e
, rtmpdump
2024-07-27 06:49:29 +00:00
, twolame
2023-02-16 17:41:37 +00:00
, samba
, SDL2
2024-01-25 14:12:00 +00:00
, shaderc
2023-02-16 17:41:37 +00:00
, soxr
, speex
, srt
2024-01-13 08:15:51 +00:00
, svt-av1
2023-02-16 17:41:37 +00:00
, vid-stab
, vo-amrwbenc
2024-01-13 08:15:51 +00:00
, vulkan-headers
, vulkan-loader
2023-02-16 17:41:37 +00:00
, x264
, x265
, xavs
2024-04-21 15:54:59 +00:00
, xevd
, xeve
2023-02-16 17:41:37 +00:00
, xvidcore
2024-01-13 08:15:51 +00:00
, xz
2023-02-16 17:41:37 +00:00
, zeromq4
, zimg
, zlib
/*
* Darwin frameworks
* /
2024-04-21 15:54:59 +00:00
, AppKit
, AudioToolbox
2023-02-16 17:41:37 +00:00
, AVFoundation
2024-04-21 15:54:59 +00:00
, CoreImage
2023-02-16 17:41:37 +00:00
, VideoToolbox
2024-07-27 06:49:29 +00:00
, xcode # unfree contains metalcc and metallib
2023-02-16 17:41:37 +00:00
/*
* Testing
* /
, testers
2020-04-24 23:36:52 +00:00
} :
/* M a i n t a i n e r n o t e s :
*
2023-02-16 17:41:37 +00:00
* Version bumps :
* It should always be safe to bump patch releases ( e . g . 2 .1 . x , x being a patch release )
* If adding a new branch , note any configure flags that were added , changed , or deprecated/removed
* and make the necessary changes .
2020-04-24 23:36:52 +00:00
*
* Known issues :
2023-02-16 17:41:37 +00:00
* Cross-compiling will disable features not present on host OS
* ( e . g . dxva2 support [ DirectX ] will not be enabled unless natively compiled on Cygwin )
2020-04-24 23:36:52 +00:00
*
* /
let
2024-04-21 15:54:59 +00:00
inherit ( lib ) optional optionals optionalString enableFeature versionOlder versionAtLeast ;
2023-02-16 17:41:37 +00:00
in
2020-04-24 23:36:52 +00:00
2023-02-16 17:41:37 +00:00
assert lib . elem ffmpegVariant [ " h e a d l e s s " " s m a l l " " f u l l " ] ;
2020-04-24 23:36:52 +00:00
2023-02-16 17:41:37 +00:00
/*
* Licensing dependencies
* /
2024-02-29 20:09:43 +00:00
assert withGPLv3 -> withGPL && withVersion3 ;
2023-02-16 17:41:37 +00:00
/*
* Build dependencies
* /
assert withPixelutils -> buildAvutil ;
2024-04-21 15:54:59 +00:00
assert ! ( withMfx && withVpl ) ; # incompatible features
2023-02-16 17:41:37 +00:00
/*
* Program dependencies
* /
assert buildFfmpeg -> buildAvcodec
&& buildAvfilter
&& buildAvformat
&& ( buildSwresample || buildAvresample ) ;
assert buildFfplay -> buildAvcodec
&& buildAvformat
&& buildSwscale
&& ( buildSwresample || buildAvresample ) ;
assert buildFfprobe -> buildAvcodec && buildAvformat ;
/*
* Library dependencies
* /
assert buildAvcodec -> buildAvutil ; # configure flag since 0.6
assert buildAvdevice -> buildAvformat
&& buildAvcodec
&& buildAvutil ; # configure flag since 0.6
assert buildAvformat -> buildAvcodec && buildAvutil ; # configure flag since 0.6
assert buildPostproc -> buildAvutil ;
assert buildSwscale -> buildAvutil ;
2020-04-24 23:36:52 +00:00
2024-04-21 15:54:59 +00:00
/*
* External Library dependencies
* /
assert ( withCuda || withCuvid || withNvdec || withNvenc ) -> withNvcodec ;
2023-02-16 17:41:37 +00:00
stdenv . mkDerivation ( finalAttrs : {
2023-08-04 22:07:22 +00:00
pname = " f f m p e g " + ( optionalString ( ffmpegVariant != " s m a l l " ) " - ${ ffmpegVariant } " ) ;
2020-04-24 23:36:52 +00:00
inherit version ;
2024-04-21 15:54:59 +00:00
src = source ;
2020-04-24 23:36:52 +00:00
2023-02-16 17:41:37 +00:00
postPatch = ''
patchShebangs .
'' + l i b . o p t i o n a l S t r i n g w i t h F r e i 0 r ''
substituteInPlace libavfilter/vf_frei0r.c \
- - replace /usr/local/lib/frei0r-1 $ { frei0r } /lib/frei0r-1
substituteInPlace doc/filters.texi \
- - replace /usr/local/lib/frei0r-1 $ { frei0r } /lib/frei0r-1
'' ;
2020-04-24 23:36:52 +00:00
2024-07-27 06:49:29 +00:00
patches = [ ]
2024-04-21 15:54:59 +00:00
++ optionals ( versionOlder version " 5 " ) [
2024-07-27 06:49:29 +00:00
( fetchpatch2 {
2024-04-21 15:54:59 +00:00
name = " l i b s v t a v 1 - 1 . 5 . 0 - c o m p a t - c o m p r e s s e d _ t e n _ b i t _ f o r m a t . p a t c h " ;
url = " h t t p s : / / g i t . f f m p e g . o r g / g i t w e b / f f m p e g . g i t / p a t c h / 0 3 1 f 1 5 6 1 c d 2 8 6 5 9 6 c d b 3 7 4 d a 3 2 f 8 a a 8 1 6 c e 3 b 1 3 5 " ;
hash = " s h a 2 5 6 - a g J g z I z r B T Q B A y p u C m G X X F o 7 v w 6 I o d w 5 N y 5 O 5 Q C K C n 8 = " ;
2024-07-27 06:49:29 +00:00
} )
( fetchpatch2 {
2024-04-21 15:54:59 +00:00
# Backport fix for binutils-2.41.
name = " b i n u t i l s - 2 . 4 1 . p a t c h " ;
url = " h t t p s : / / g i t . f f m p e g . o r g / g i t w e b / f f m p e g . g i t / p a t c h / e f f a d c e 6 c 7 5 6 2 4 7 e a 8 b a e 3 2 d c 1 3 b b 3 e 6 f 4 6 4 f 0 e b " ;
hash = " s h a 2 5 6 - v L S l t v Z V M c Q 0 C n k U 0 A 2 9 x 6 f J S y w E 8 / a U + M p 9 o s 8 D Z Y Y = " ;
2024-07-27 06:49:29 +00:00
} )
2024-04-21 15:54:59 +00:00
# The upstream patch isn’ t for ffmpeg 4, but it will apply with a few tweaks.
# Fixes a crash when built with clang 16 due to UB in ff_seek_frame_binary.
2024-07-27 06:49:29 +00:00
( fetchpatch2 {
2024-04-21 15:54:59 +00:00
name = " u t i l s - f i x _ c r a s h _ i n _ f f _ s e e k _ f r a m e _ b i n a r y . p a t c h " ;
url = " h t t p s : / / g i t . f f m p e g . o r g / g i t w e b / f f m p e g . g i t / p a t c h / a b 7 9 2 6 3 4 1 9 7 e 3 6 4 c a 1 b b 1 9 4 f 9 a b e 3 6 8 3 6 e 4 2 f 1 2 d " ;
hash = " s h a 2 5 6 - v q q V A C j b C c G L 9 Q v m g 1 Q A r S K q V m O q r 8 B E r + O x T B D t 6 m A = " ;
postFetch = ''
substituteInPlace " $ o u t " \
- - replace libavformat/seek.c libavformat/utils.c \
- - replace ' const AVInputFormat * const ' ' const AVInputFormat * '
'' ;
2024-07-27 06:49:29 +00:00
} )
( fetchpatch2 {
2024-07-31 10:19:44 +00:00
name = " C V E - 2 0 2 3 - 5 1 7 9 4 . p a t c h " ;
url = " h t t p s : / / g i t . f f m p e g . o r g / g i t w e b / f f m p e g . g i t / p a t c h / 5 0 f 0 f 8 c 5 3 c 8 1 8 f 7 3 f e 2 d 7 5 2 7 0 8 e 2 f a 9 d 2 a 2 d 8 a 0 7 " ;
hash = " s h a 2 5 6 - 5 G 9 l m K j M E a 0 + v q b A 8 E E i N I r 6 Q G + P e E o I L + u Z P 4 H l o 2 8 = " ;
2024-07-27 06:49:29 +00:00
} )
]
++ optionals ( lib . versionAtLeast version " 6 . 1 " && lib . versionOlder version " 6 . 2 " ) [
( fetchpatch2 { # this can be removed post 6.1
2024-01-13 08:15:51 +00:00
name = " f i x _ b u i l d _ f a i l u r e _ d u e _ t o _ P r o p e r t y K e y _ E n c o d e r I D " ;
url = " h t t p s : / / g i t . f f m p e g . o r g / g i t w e b / f f m p e g . g i t / p a t c h / c b 0 4 9 d 3 7 7 f 5 4 f 6 b 7 4 7 6 6 7 a 9 3 e 4 b 7 1 9 3 8 0 c 3 e 9 4 7 5 " ;
2024-04-21 15:54:59 +00:00
hash = " s h a 2 5 6 - s x R X K K g U a k 5 v s Q T i V 7 g e 8 v p + N 2 2 C d T I v u c z N g V R P 7 2 c = " ;
2024-07-27 06:49:29 +00:00
} )
( fetchpatch2 {
2024-04-21 15:54:59 +00:00
name = " f i x _ v u l k a n _ a v 1 " ;
url = " h t t p s : / / g i t . f f m p e g . o r g / g i t w e b / f f m p e g . g i t / p a t c h / e 0 6 c e 6 d 2 b 4 5 e d a c 4 a 2 d f 0 4 f 3 0 4 e 1 8 d 4 7 2 7 4 1 7 d 2 4 " ;
hash = " s h a 2 5 6 - 7 3 m l X 1 r d J r g u w 7 O X a S I t f H t I 7 g f l D r F j + 7 S e p V v v U I g = " ;
2024-07-27 06:49:29 +00:00
} )
( fetchpatch2 {
2024-06-05 15:53:02 +00:00
name = " C V E - 2 0 2 4 - 3 1 5 8 2 . p a t c h " ;
url = " h t t p s : / / g i t . f f m p e g . o r g / g i t w e b / f f m p e g . g i t / p a t c h / 9 9 d e b e 5 f 8 2 3 f 4 5 a 4 8 2 e 1 d c 0 8 d e 3 5 8 7 9 a a 9 c 7 4 b d 2 " ;
hash = " s h a 2 5 6 - + C Q 9 F X R 6 V r / A m s b X F i C U X Z c x K j 1 s 8 n I n E d k e / O c / k U A = " ;
2024-07-27 06:49:29 +00:00
} )
( fetchpatch2 {
2024-06-05 15:53:02 +00:00
name = " C V E - 2 0 2 4 - 3 1 5 7 8 . p a t c h " ;
url = " h t t p s : / / g i t . f f m p e g . o r g / g i t w e b / f f m p e g . g i t / p a t c h / 3 b b 0 0 c 0 a 4 2 0 c 3 c e 8 3 c 6 f a f e e 3 0 2 7 0 d 6 9 6 2 2 c c a d 7 " ;
hash = " s h a 2 5 6 - o Z M Z y s B A + / g w a G E M 1 y v I + 8 w C a d X W E 7 q L R L 6 E m a p 3 b 8 Q = " ;
2024-07-27 06:49:29 +00:00
} )
( fetchpatch2 {
name = " C V E - 2 0 2 3 - 4 9 5 0 1 . p a t c h " ;
url = " h t t p s : / / g i t . f f m p e g . o r g / g i t w e b / f f m p e g . g i t / p a t c h / 4 a d b 9 3 d f f 0 5 d d 9 4 7 8 7 8 c 6 7 7 8 4 d 9 8 c 9 a 4 e 1 3 b 5 7 a 7 " ;
hash = " s h a 2 5 6 - 7 c w k t t o 3 f P M D G v C Z C V t B 0 1 X 8 Q 9 S / 4 V 4 b D L U I C S N f G g w = " ;
} )
( fetchpatch2 {
name = " C V E - 2 0 2 3 - 4 9 5 0 2 . p a t c h " ;
url = " h t t p s : / / g i t . f f m p e g . o r g / g i t w e b / f f m p e g . g i t / p a t c h / 7 3 7 e d e 4 0 5 b 1 1 a 3 7 f d d 6 1 d 1 9 c f 2 5 d f 2 9 6 a 0 c b 0 b 7 5 " ;
hash = " s h a 2 5 6 - m p S J w R 9 T X 5 E N j j C K v z u M / 9 e 1 A j / A O i Q W 0 + 7 2 o O M l 9 v 8 = " ;
} )
( fetchpatch2 {
name = " C V E - 2 0 2 3 - 5 0 0 0 7 . p a t c h " ;
url = " h t t p s : / / g i t . f f m p e g . o r g / g i t w e b / f f m p e g . g i t / p a t c h / b 1 9 4 2 7 3 4 c 7 c b c d c 9 0 3 4 0 3 4 3 7 3 a b c c 9 e c b 9 6 4 4 c 4 7 " ;
hash = " s h a 2 5 6 - v 0 h N c q B t m 8 G C G A U 9 U b R U C E 0 s l o d O j Z C H r k S 8 e 4 T r V c Q = " ;
} )
( fetchpatch2 {
name = " C V E - 2 0 2 3 - 5 0 0 0 8 . p a t c h " ;
url = " h t t p s : / / g i t . f f m p e g . o r g / g i t w e b / f f m p e g . g i t / p a t c h / 5 f 8 7 a 6 8 c f 7 0 d a f e a b 2 f b 8 9 b 4 2 e 4 1 a 4 c 2 9 0 5 3 b 8 9 b " ;
hash = " s h a 2 5 6 - s q U U S O P T P L w u 2 h 8 G b A w 4 S f E f + 0 o W i o z 5 2 B c p W 1 n 4 v 3 Y = " ;
} )
]
++ optionals ( lib . versionAtLeast version " 7 . 0 " && lib . versionOlder version " 7 . 0 . 1 " ) [
( fetchpatch2 {
2024-04-21 15:54:59 +00:00
# Will likely be obsolete in >7.0
name = " f a t e _ a v o i d _ d e p e n d e n c y _ o n _ s a m p l e s " ;
url = " h t t p s : / / g i t . f f m p e g . o r g / g i t w e b / f f m p e g . g i t / p a t c h / 7 b 7 b 7 8 1 9 b d 2 1 c c 9 2 a c 0 7 f 6 6 9 6 b 0 e 7 f 2 6 f a 8 f 9 8 3 4 " ;
hash = " s h a 2 5 6 - T K I 2 8 9 X q t G 8 6 S j 9 s 7 m V Y v m k j A u R X e K + 2 c Y Y E D k g 6 u 6 I = " ;
2024-07-27 06:49:29 +00:00
} )
]
++ optionals ( lib . versionAtLeast version " 7 . 0 " ) [
./0001-avfoundation.m-macOS-SDK-10.12-compatibility.patch
] ;
2020-04-24 23:36:52 +00:00
configurePlatforms = [ ] ;
2023-02-16 17:41:37 +00:00
setOutputFlags = false ; # Only accepts some of them
configureFlags = [
#mingw64 is internally treated as mingw32, so 32 and 64 make no difference here
" - - t a r g e t _ o s = ${ if stdenv . hostPlatform . isMinGW then " m i n g w 6 4 " else stdenv . hostPlatform . parsed . kernel . name } "
" - - a r c h = ${ stdenv . hostPlatform . parsed . cpu . name } "
" - - p k g - c o n f i g = ${ buildPackages . pkg-config . targetPrefix } p k g - c o n f i g "
/*
* Licensing flags
* /
( enableFeature withGPL " g p l " )
2024-02-29 20:09:43 +00:00
( enableFeature withVersion3 " v e r s i o n 3 " )
2023-02-16 17:41:37 +00:00
( enableFeature withUnfree " n o n f r e e " )
/*
* Build flags
* /
2024-02-29 20:09:43 +00:00
( enableFeature withStatic " s t a t i c " )
( enableFeature withShared " s h a r e d " )
( enableFeature withPic " p i c " )
( enableFeature withThumb " t h u m b " )
2023-02-16 17:41:37 +00:00
( enableFeature withSmallBuild " s m a l l " )
( enableFeature withRuntimeCPUDetection " r u n t i m e - c p u d e t e c t " )
( enableFeature withGrayscale " g r a y " )
( enableFeature withSwscaleAlpha " s w s c a l e - a l p h a " )
( enableFeature withHardcodedTables " h a r d c o d e d - t a b l e s " )
( enableFeature withSafeBitstreamReader " s a f e - b i t s t r e a m - r e a d e r " )
2024-01-02 11:29:13 +00:00
( enableFeature ( withMultithread && stdenv . hostPlatform . isUnix ) " p t h r e a d s " )
( enableFeature ( withMultithread && stdenv . hostPlatform . isWindows ) " w 3 2 t h r e a d s " )
2023-02-16 17:41:37 +00:00
" - - d i s a b l e - o s 2 t h r e a d s " # We don't support OS/2
( enableFeature withNetwork " n e t w o r k " )
( enableFeature withPixelutils " p i x e l u t i l s " )
" - - d a t a d i r = ${ placeholder " d a t a " } / s h a r e / f f m p e g "
/*
* Program flags
* /
( enableFeature buildFfmpeg " f f m p e g " )
( enableFeature buildFfplay " f f p l a y " )
( enableFeature buildFfprobe " f f p r o b e " )
] ++ optionals withBin [
" - - b i n d i r = ${ placeholder " b i n " } / b i n "
] ++ [
/*
* Library flags
* /
( enableFeature buildAvcodec " a v c o d e c " )
( enableFeature buildAvdevice " a v d e v i c e " )
( enableFeature buildAvfilter " a v f i l t e r " )
( enableFeature buildAvformat " a v f o r m a t " )
2024-04-21 15:54:59 +00:00
] ++ optionals ( lib . versionOlder version " 5 " ) [
2023-02-16 17:41:37 +00:00
# Ffmpeg > 4 doesn't know about the flag anymore
( enableFeature buildAvresample " a v r e s a m p l e " )
] ++ [
( enableFeature buildAvutil " a v u t i l " )
( enableFeature ( buildPostproc && withGPL ) " p o s t p r o c " )
( enableFeature buildSwresample " s w r e s a m p l e " )
( enableFeature buildSwscale " s w s c a l e " )
] ++ optionals withLib [
" - - l i b d i r = ${ placeholder " l i b " } / l i b "
" - - i n c d i r = ${ placeholder " d e v " } / i n c l u d e "
] ++ [
/*
* Documentation flags
* /
( enableFeature withDocumentation " d o c " )
( enableFeature withHtmlDoc " h t m l p a g e s " )
( enableFeature withManPages " m a n p a g e s " )
] ++ optionals withManPages [
" - - m a n d i r = ${ placeholder " m a n " } / s h a r e / m a n "
] ++ [
( enableFeature withPodDoc " p o d p a g e s " )
( enableFeature withTxtDoc " t x t p a g e s " )
] ++ optionals withDoc [
" - - d o c d i r = ${ placeholder " d o c " } / s h a r e / d o c / f f m p e g "
] ++ [
/*
* External libraries
* /
( enableFeature withAlsa " a l s a " )
2024-02-29 20:09:43 +00:00
( enableFeature withAom " l i b a o m " )
2024-04-21 15:54:59 +00:00
( enableFeature withAppKit " a p p k i t " )
] ++ optionals ( versionAtLeast version " 6 . 1 " ) [
2024-02-29 20:09:43 +00:00
( enableFeature withAribcaption " l i b a r i b c a p t i o n " )
] ++ [
( enableFeature withAss " l i b a s s " )
2024-04-21 15:54:59 +00:00
( enableFeature withAudioToolbox " a u d i o t o o l b o x " )
( enableFeature withAvFoundation " a v f o u n d a t i o n " )
2024-05-15 15:35:15 +00:00
( enableFeature withAvisynth " a v i s y n t h " )
2024-02-29 20:09:43 +00:00
( enableFeature withBluray " l i b b l u r a y " )
( enableFeature withBs2b " l i b b s 2 b " )
2023-02-16 17:41:37 +00:00
( enableFeature withBzlib " b z l i b " )
2024-04-21 15:54:59 +00:00
( enableFeature withCaca " l i b c a c a " )
2023-02-16 17:41:37 +00:00
( enableFeature withCelt " l i b c e l t " )
2024-02-29 20:09:43 +00:00
( enableFeature withChromaprint " c h r o m a p r i n t " )
2024-05-15 15:35:15 +00:00
( enableFeature withCodec2 " l i b c o d e c 2 " )
2024-04-21 15:54:59 +00:00
( enableFeature withCoreImage " c o r e i m a g e " )
2023-02-16 17:41:37 +00:00
( enableFeature withCuda " c u d a " )
( enableFeature withCudaLLVM " c u d a - l l v m " )
2024-04-21 15:54:59 +00:00
( enableFeature withCuvid " c u v i d " )
2023-02-16 17:41:37 +00:00
( enableFeature withDav1d " l i b d a v 1 d " )
2024-02-29 20:09:43 +00:00
( enableFeature withDc1394 " l i b d c 1 3 9 4 " )
( enableFeature withDrm " l i b d r m " )
2024-04-21 15:54:59 +00:00
] ++ optionals ( versionAtLeast version " 7 " ) [
( enableFeature withDvdnav " l i b d v d n a v " )
( enableFeature withDvdread " l i b d v d r e a d " )
] ++ [
2023-02-16 17:41:37 +00:00
( enableFeature withFdkAac " l i b f d k - a a c " )
2024-04-21 15:54:59 +00:00
( enableFeature withNvcodec " f f n v c o d e c " )
2024-02-29 20:09:43 +00:00
( enableFeature withFlite " l i b f l i t e " )
2023-02-16 17:41:37 +00:00
( enableFeature withFontconfig " f o n t c o n f i g " )
2024-04-21 15:54:59 +00:00
( enableFeature withFontconfig " l i b f o n t c o n f i g " )
2023-02-16 17:41:37 +00:00
( enableFeature withFreetype " l i b f r e e t y p e " )
( enableFeature withFrei0r " f r e i 0 r " )
( enableFeature withFribidi " l i b f r i b i d i " )
( enableFeature withGme " l i b g m e " )
( enableFeature withGnutls " g n u t l s " )
( enableFeature withGsm " l i b g s m " )
2024-04-21 15:54:59 +00:00
] ++ optionals ( versionAtLeast version " 6 . 1 " ) [
2024-02-29 20:09:43 +00:00
( enableFeature withHarfbuzz " l i b h a r f b u z z " )
] ++ [
2023-02-16 17:41:37 +00:00
( enableFeature withIconv " i c o n v " )
( enableFeature withJack " l i b j a c k " )
2024-05-15 15:35:15 +00:00
] ++ optionals ( versionAtLeast finalAttrs . version " 5 . 0 " ) [
( enableFeature withJxl " l i b j x l " )
] ++ [
2024-02-29 20:09:43 +00:00
( enableFeature withLadspa " l a d s p a " )
2024-07-31 10:19:44 +00:00
] ++ optionals ( versionAtLeast version " 5 . 1 " ) [
( enableFeature withLcms2 " l c m s 2 " )
] ++ [
2024-02-29 20:09:43 +00:00
( enableFeature withLzma " l z m a " )
2024-07-27 06:49:29 +00:00
] ++ optionals ( versionAtLeast version " 5 . 0 " ) [
( enableFeature withMetal " m e t a l " )
] ++ [
2023-02-16 17:41:37 +00:00
( enableFeature withMfx " l i b m f x " )
( enableFeature withModplug " l i b m o d p l u g " )
2024-02-29 20:09:43 +00:00
( enableFeature withMp3lame " l i b m p 3 l a m e " )
2023-02-16 17:41:37 +00:00
( enableFeature withMysofa " l i b m y s o f a " )
( enableFeature withNvdec " n v d e c " )
( enableFeature withNvenc " n v e n c " )
( enableFeature withOpenal " o p e n a l " )
( enableFeature withOpencl " o p e n c l " )
( enableFeature withOpencoreAmrnb " l i b o p e n c o r e - a m r n b " )
2024-04-21 15:54:59 +00:00
( enableFeature withOpencoreAmrwb " l i b o p e n c o r e - a m r w b " )
2023-02-16 17:41:37 +00:00
( enableFeature withOpengl " o p e n g l " )
( enableFeature withOpenh264 " l i b o p e n h 2 6 4 " )
( enableFeature withOpenjpeg " l i b o p e n j p e g " )
( enableFeature withOpenmpt " l i b o p e n m p t " )
2024-02-29 20:09:43 +00:00
( enableFeature withOpus " l i b o p u s " )
2024-04-21 15:54:59 +00:00
] ++ optionals ( versionAtLeast version " 5 . 0 " ) [
2024-02-29 20:09:43 +00:00
( enableFeature withPlacebo " l i b p l a c e b o " )
] ++ [
2023-02-16 17:41:37 +00:00
( enableFeature withPulse " l i b p u l s e " )
2024-04-21 15:54:59 +00:00
] ++ optionals ( versionAtLeast version " 7 " ) [
( enableFeature withQrencode " l i b q r e n c o d e " )
( enableFeature withQuirc " l i b q u i r c " )
] ++ [
2023-02-16 17:41:37 +00:00
( enableFeature withRav1e " l i b r a v 1 e " )
( enableFeature withRtmp " l i b r t m p " )
2024-02-29 20:09:43 +00:00
( enableFeature withSamba " l i b s m b c l i e n t " )
2023-02-16 17:41:37 +00:00
( enableFeature withSdl2 " s d l 2 " )
2024-04-21 15:54:59 +00:00
] ++ optionals ( versionAtLeast version " 5 . 0 " ) [
2024-02-29 20:09:43 +00:00
( enableFeature withShaderc " l i b s h a d e r c " )
] ++ [
2023-02-16 17:41:37 +00:00
( enableFeature withSoxr " l i b s o x r " )
( enableFeature withSpeex " l i b s p e e x " )
2024-02-29 20:09:43 +00:00
( enableFeature withSrt " l i b s r t " )
( enableFeature withSsh " l i b s s h " )
( enableFeature withSvg " l i b r s v g " )
( enableFeature withSvtav1 " l i b s v t a v 1 " )
( enableFeature withTensorflow " l i b t e n s o r f l o w " )
( enableFeature withTheora " l i b t h e o r a " )
2024-07-27 06:49:29 +00:00
( enableFeature withTwolame " l i b t w o l a m e " )
2024-02-29 20:09:43 +00:00
( enableFeature withV4l2 " l i b v 4 l 2 " )
( enableFeature withV4l2M2m " v 4 l 2 - m 2 m " )
( enableFeature withVaapi " v a a p i " )
( enableFeature withVdpau " v d p a u " )
2024-04-21 15:54:59 +00:00
] ++ optionals ( versionAtLeast version " 6 . 0 " ) [
( enableFeature withVpl " l i b v p l " )
] ++ [
( enableFeature withVideoToolbox " v i d e o t o o l b o x " )
2023-02-16 17:41:37 +00:00
( enableFeature withVidStab " l i b v i d s t a b " ) # Actual min. version 2.0
2024-02-29 20:09:43 +00:00
( enableFeature withVmaf " l i b v m a f " )
2023-02-16 17:41:37 +00:00
( enableFeature withVoAmrwbenc " l i b v o - a m r w b e n c " )
2024-02-29 20:09:43 +00:00
( enableFeature withVorbis " l i b v o r b i s " )
( enableFeature withVpx " l i b v p x " )
( enableFeature withVulkan " v u l k a n " )
( enableFeature withWebp " l i b w e b p " )
2023-02-16 17:41:37 +00:00
( enableFeature withX264 " l i b x 2 6 4 " )
( enableFeature withX265 " l i b x 2 6 5 " )
( enableFeature withXavs " l i b x a v s " )
2024-02-29 20:09:43 +00:00
( enableFeature withXcb " l i b x c b " )
( enableFeature withXcbShape " l i b x c b - s h a p e " )
( enableFeature withXcbShm " l i b x c b - s h m " )
( enableFeature withXcbxfixes " l i b x c b - x f i x e s " )
2024-04-21 15:54:59 +00:00
] ++ optionals ( versionAtLeast version " 7 " ) [
( enableFeature withXevd " l i b x e v d " )
( enableFeature withXeve " l i b x e v e " )
] ++ [
2024-02-29 20:09:43 +00:00
( enableFeature withXlib " x l i b " )
( enableFeature withXml2 " l i b x m l 2 " )
2023-02-16 17:41:37 +00:00
( enableFeature withXvid " l i b x v i d " )
( enableFeature withZimg " l i b z i m g " )
( enableFeature withZlib " z l i b " )
2024-02-29 20:09:43 +00:00
( enableFeature withZmq " l i b z m q " )
2023-02-16 17:41:37 +00:00
/*
* Developer flags
* /
( enableFeature withDebug " d e b u g " )
( enableFeature withOptimisations " o p t i m i z a t i o n s " )
( enableFeature withExtraWarnings " e x t r a - w a r n i n g s " )
( enableFeature withStripping " s t r i p p i n g " )
2020-04-24 23:36:52 +00:00
] ++ optionals ( stdenv . hostPlatform != stdenv . buildPlatform ) [
2023-02-16 17:41:37 +00:00
" - - c r o s s - p r e f i x = ${ stdenv . cc . targetPrefix } "
" - - e n a b l e - c r o s s - c o m p i l e "
" - - h o s t - c c = ${ buildPackages . stdenv . cc } / b i n / c c "
] ++ optionals stdenv . cc . isClang [
" - - c c = c l a n g "
" - - c x x = c l a n g + + "
2024-07-27 06:49:29 +00:00
] ++ optionals withMetal [
" - - m e t a l c c = ${ xcode } / C o n t e n t s / D e v e l o p e r / T o o l c h a i n s / X c o d e D e f a u l t . x c t o o l c h a i n / u s r / b i n / m e t a l "
" - - m e t a l l i b = ${ xcode } / C o n t e n t s / D e v e l o p e r / T o o l c h a i n s / X c o d e D e f a u l t . x c t o o l c h a i n / u s r / b i n / m e t a l l i b "
2023-02-16 17:41:37 +00:00
] ;
2020-04-24 23:36:52 +00:00
2023-02-16 17:41:37 +00:00
# ffmpeg embeds the configureFlags verbatim in its binaries and because we
# configure binary, include, library dir etc., this causes references in
# outputs where we don't want them. Patch the generated config.h to remove all
# such references except for data.
postConfigure = let
2023-07-15 17:15:38 +00:00
toStrip = map placeholder ( lib . remove " d a t a " finalAttrs . outputs ) # We want to keep references to the data dir.
2024-07-27 06:49:29 +00:00
++ lib . optional ( stdenv . hostPlatform != stdenv . buildPlatform ) buildPackages . stdenv . cc
++ lib . optional withMetal xcode ;
2023-02-16 17:41:37 +00:00
in
2023-07-15 17:15:38 +00:00
" r e m o v e - r e f e r e n c e s - t o ${ lib . concatStringsSep " " ( map ( o : " - t ${ o } " ) toStrip ) } c o n f i g . h " ;
2023-02-16 17:41:37 +00:00
2023-10-09 19:29:22 +00:00
strictDeps = true ;
2024-07-31 10:19:44 +00:00
nativeBuildInputs = [ removeReferencesTo addDriverRunpath perl pkg-config yasm ]
# Texinfo version 7.1 introduced breaking changes, which older versions of ffmpeg do not handle.
++ ( if versionOlder version " 5 " then [ texinfo6 ] else [ texinfo ] )
2023-10-09 19:29:22 +00:00
++ optionals withCudaLLVM [ clang ] ;
2023-02-16 17:41:37 +00:00
2024-04-21 15:54:59 +00:00
buildInputs = [ ]
2023-02-16 17:41:37 +00:00
++ optionals withAlsa [ alsa-lib ]
++ optionals withAom [ libaom ]
2024-04-21 15:54:59 +00:00
++ optionals withAppKit [ AppKit ]
2024-01-13 08:15:51 +00:00
++ optionals withAribcaption [ libaribcaption ]
2023-02-16 17:41:37 +00:00
++ optionals withAss [ libass ]
2024-04-21 15:54:59 +00:00
++ optionals withAudioToolbox [ AudioToolbox ]
++ optionals withAvFoundation [ AVFoundation ]
2024-05-15 15:35:15 +00:00
++ optionals withAvisynth [ avisynthplus ]
2023-02-16 17:41:37 +00:00
++ optionals withBluray [ libbluray ]
++ optionals withBs2b [ libbs2b ]
++ optionals withBzlib [ bzip2 ]
++ optionals withCaca [ libcaca ]
++ optionals withCelt [ celt ]
2024-02-29 20:09:43 +00:00
++ optionals withChromaprint [ chromaprint ]
2024-05-15 15:35:15 +00:00
++ optionals withCodec2 [ codec2 ]
2024-04-21 15:54:59 +00:00
++ optionals withCoreImage [ CoreImage ]
2023-02-16 17:41:37 +00:00
++ optionals withDav1d [ dav1d ]
2024-02-29 20:09:43 +00:00
++ optionals withDc1394 [ libdc1394 libraw1394 ]
2023-02-16 17:41:37 +00:00
++ optionals withDrm [ libdrm ]
2024-04-21 15:54:59 +00:00
++ optionals withDvdnav [ libdvdnav ]
++ optionals withDvdread [ libdvdread ]
2023-02-16 17:41:37 +00:00
++ optionals withFdkAac [ fdk_aac ]
2024-04-21 15:54:59 +00:00
++ optionals withNvcodec [ ( if ( lib . versionAtLeast version " 6 " ) then nv-codec-headers-12 else nv-codec-headers ) ]
2024-02-29 20:09:43 +00:00
++ optionals withFlite [ flite ]
2023-02-16 17:41:37 +00:00
++ optionals withFontconfig [ fontconfig ]
++ optionals withFreetype [ freetype ]
++ optionals withFrei0r [ frei0r ]
++ optionals withFribidi [ fribidi ]
++ optionals withGme [ game-music-emu ]
++ optionals withGnutls [ gnutls ]
++ optionals withGsm [ gsm ]
2024-02-29 20:09:43 +00:00
++ optionals withHarfbuzz [ harfbuzz ]
2023-02-16 17:41:37 +00:00
++ optionals withIconv [ libiconv ] # On Linux this should be in libc, do we really need it?
++ optionals withJack [ libjack2 ]
2024-05-15 15:35:15 +00:00
++ optionals withJxl [ libjxl ]
2023-02-16 17:41:37 +00:00
++ optionals withLadspa [ ladspaH ]
2024-07-31 10:19:44 +00:00
++ optionals withLcms2 [ lcms2 ]
2023-02-16 17:41:37 +00:00
++ optionals withLzma [ xz ]
++ optionals withMfx [ intel-media-sdk ]
++ optionals withModplug [ libmodplug ]
++ optionals withMp3lame [ lame ]
++ optionals withMysofa [ libmysofa ]
++ optionals withOgg [ libogg ]
++ optionals withOpenal [ openal ]
++ optionals withOpencl [ ocl-icd opencl-headers ]
2024-04-21 15:54:59 +00:00
++ optionals ( withOpencoreAmrnb || withOpencoreAmrwb ) [ opencore-amr ]
2023-02-16 17:41:37 +00:00
++ optionals withOpengl [ libGL libGLU ]
++ optionals withOpenh264 [ openh264 ]
++ optionals withOpenjpeg [ openjpeg ]
++ optionals withOpenmpt [ libopenmpt ]
++ optionals withOpus [ libopus ]
2024-04-21 15:54:59 +00:00
++ optionals withPlacebo [ ( if ( lib . versionAtLeast version " 6 . 1 " ) then libplacebo else libplacebo_5 ) vulkan-headers ]
2023-02-16 17:41:37 +00:00
++ optionals withPulse [ libpulseaudio ]
2024-04-21 15:54:59 +00:00
++ optionals withQrencode [ qrencode ]
++ optionals withQuirc [ quirc ]
2023-02-16 17:41:37 +00:00
++ optionals withRav1e [ rav1e ]
++ optionals withRtmp [ rtmpdump ]
++ optionals withSamba [ samba ]
++ optionals withSdl2 [ SDL2 ]
2024-01-25 14:12:00 +00:00
++ optionals withShaderc [ shaderc ]
2023-02-16 17:41:37 +00:00
++ optionals withSoxr [ soxr ]
++ optionals withSpeex [ speex ]
++ optionals withSrt [ srt ]
++ optionals withSsh [ libssh ]
++ optionals withSvg [ librsvg ]
++ optionals withSvtav1 [ svt-av1 ]
2023-05-24 13:37:59 +00:00
++ optionals withTensorflow [ libtensorflow ]
2023-02-16 17:41:37 +00:00
++ optionals withTheora [ libtheora ]
2024-07-27 06:49:29 +00:00
++ optionals withTwolame [ twolame ]
2024-02-29 20:09:43 +00:00
++ optionals withV4l2 [ libv4l ]
2023-02-16 17:41:37 +00:00
++ optionals withVaapi [ ( if withSmallDeps then libva else libva-minimal ) ]
++ optionals withVdpau [ libvdpau ]
2024-04-21 15:54:59 +00:00
++ optionals withVideoToolbox [ VideoToolbox ]
2023-02-16 17:41:37 +00:00
++ optionals withVidStab [ vid-stab ]
++ optionals withVmaf [ libvmaf ]
++ optionals withVoAmrwbenc [ vo-amrwbenc ]
++ optionals withVorbis [ libvorbis ]
2024-04-21 15:54:59 +00:00
++ optionals withVpl [ libvpl ]
2023-02-16 17:41:37 +00:00
++ optionals withVpx [ libvpx ]
2023-03-04 12:14:45 +00:00
++ optionals withVulkan [ vulkan-headers vulkan-loader ]
2023-02-16 17:41:37 +00:00
++ optionals withWebp [ libwebp ]
++ optionals withX264 [ x264 ]
++ optionals withX265 [ x265 ]
++ optionals withXavs [ xavs ]
++ optionals withXcb [ libxcb ]
2024-04-21 15:54:59 +00:00
++ optionals withXevd [ xevd ]
++ optionals withXeve [ xeve ]
2023-02-16 17:41:37 +00:00
++ optionals withXlib [ libX11 libXv libXext ]
++ optionals withXml2 [ libxml2 ]
++ optionals withXvid [ xvidcore ]
++ optionals withZimg [ zimg ]
++ optionals withZlib [ zlib ]
++ optionals withZmq [ zeromq4 ]
2024-04-21 15:54:59 +00:00
;
2023-02-16 17:41:37 +00:00
buildFlags = [ " a l l " ]
++ optional buildQtFaststart " t o o l s / q t - f a s t s t a r t " ; # Build qt-faststart executable
doCheck = stdenv . hostPlatform == stdenv . buildPlatform ;
2020-04-24 23:36:52 +00:00
2023-02-16 17:41:37 +00:00
# Fails with SIGABRT otherwise FIXME: Why?
2021-09-18 10:52:07 +00:00
checkPhase = let
ldLibraryPathEnv = if stdenv . isDarwin then " D Y L D _ L I B R A R Y _ P A T H " else " L D _ L I B R A R Y _ P A T H " ;
2023-02-16 17:41:37 +00:00
libsToLink = [ ]
++ optional buildAvcodec " l i b a v c o d e c "
++ optional buildAvdevice " l i b a v d e v i c e "
++ optional buildAvfilter " l i b a v f i l t e r "
++ optional buildAvformat " l i b a v f o r m a t "
++ optional buildAvresample " l i b a v r e s a m p l e "
++ optional buildAvutil " l i b a v u t i l "
++ optional buildPostproc " l i b p o s t p r o c "
++ optional buildSwresample " l i b s w r e s a m p l e "
++ optional buildSwscale " l i b s w s c a l e "
;
2021-09-18 10:52:07 +00:00
in ''
2023-02-16 17:41:37 +00:00
$ { ldLibraryPathEnv } = " ${ lib . concatStringsSep " : " libsToLink } " make check - j $ NIX_BUILD_CORES
2021-09-18 10:52:07 +00:00
'' ;
2020-04-24 23:36:52 +00:00
2023-02-16 17:41:37 +00:00
outputs = optionals withBin [ " b i n " ] # The first output is the one that gets symlinked by default!
++ optionals withLib [ " l i b " " d e v " ]
++ optionals withDoc [ " d o c " ]
++ optionals withManPages [ " m a n " ]
++ [ " d a t a " " o u t " ] # We need an "out" output because we get an error otherwise. It's just an empty dir.
;
postInstall = optionalString buildQtFaststart ''
install - D tools/qt-faststart - t $ bin/bin
'' ;
# Set RUNPATH so that libnvcuvid and libcuda in /run/opengl-driver(-32)/lib can be found.
2024-07-31 10:19:44 +00:00
# See the explanation in addDriverRunpath.
2023-03-15 16:39:30 +00:00
postFixup = optionalString ( stdenv . isLinux && withLib ) ''
2024-07-31 10:19:44 +00:00
addDriverRunpath $ { placeholder " l i b " } /lib/libavcodec.so
addDriverRunpath $ { placeholder " l i b " } /lib/libavutil.so
2024-04-21 15:54:59 +00:00
''
# https://trac.ffmpeg.org/ticket/10809
+ optionalString ( versionAtLeast version " 5 . 0 " && withVulkan && ! stdenv . hostPlatform . isMinGW ) ''
patchelf $ lib/lib/libavcodec.so - - add-needed libvulkan . so - - add-rpath $ { lib . makeLibraryPath [ vulkan-loader ] }
2020-04-24 23:36:52 +00:00
'' ;
2023-02-16 17:41:37 +00:00
enableParallelBuilding = true ;
2020-04-24 23:36:52 +00:00
2023-02-16 17:41:37 +00:00
passthru . tests . pkg-config = testers . testMetaPkgConfig finalAttrs . finalPackage ;
2020-04-24 23:36:52 +00:00
2021-02-05 17:12:51 +00:00
meta = with lib ; {
2024-06-20 14:57:18 +00:00
description = " C o m p l e t e , c r o s s - p l a t f o r m s o l u t i o n t o r e c o r d , c o n v e r t a n d s t r e a m a u d i o a n d v i d e o " ;
2021-05-20 23:08:51 +00:00
homepage = " h t t p s : / / w w w . f f m p e g . o r g / " ;
2024-04-21 15:54:59 +00:00
changelog = " h t t p s : / / g i t h u b . c o m / F F m p e g / F F m p e g / b l o b / n ${ version } / C h a n g e l o g " ;
2020-04-24 23:36:52 +00:00
longDescription = ''
FFmpeg is the leading multimedia framework , able to decode , encode , transcode ,
mux , demux , stream , filter and play pretty much anything that humans and machines
have created . It supports the most obscure ancient formats up to the cutting edge .
No matter if they were designed by some standards committee , the community or
a corporation .
'' ;
2023-02-16 17:41:37 +00:00
license = with licenses ; [ lgpl21Plus ]
++ optional withGPL gpl2Plus
2024-02-29 20:09:43 +00:00
++ optional withVersion3 lgpl3Plus
2023-02-16 17:41:37 +00:00
++ optional withGPLv3 gpl3Plus
2024-02-29 20:09:43 +00:00
++ optional withUnfree unfreeRedistributable
++ optional ( withGPL && withUnfree ) unfree ;
2024-04-21 15:54:59 +00:00
pkgConfigModules = [ ]
++ optional buildAvcodec " l i b a v c o d e c "
++ optional buildAvdevice " l i b a v d e v i c e "
++ optional buildAvfilter " l i b a v f i l t e r "
++ optional buildAvformat " l i b a v f o r m a t "
++ optional buildAvresample " l i b a v r e s a m p l e "
++ optional buildAvutil " l i b a v u t i l "
++ optional buildPostproc " l i b p o s t p r o c "
++ optional buildSwresample " l i b s w r e s a m p l e "
++ optional buildSwscale " l i b s w s c a l e " ;
2020-04-24 23:36:52 +00:00
platforms = platforms . all ;
2024-04-21 15:54:59 +00:00
# See https://github.com/NixOS/nixpkgs/pull/295344#issuecomment-1992263658
broken = stdenv . hostPlatform . isMinGW && stdenv . hostPlatform . is64bit ;
2024-07-27 06:49:29 +00:00
maintainers = with maintainers ; [ atemu jopejoe1 ] ;
2023-10-09 19:29:22 +00:00
mainProgram = " f f m p e g " ;
2020-04-24 23:36:52 +00:00
} ;
2024-07-27 06:49:29 +00:00
} // lib . optionalAttrs withCudaLLVM {
# remove once https://github.com/NixOS/nixpkgs/issues/318674 is addressed properly
hardeningDisable = [ " z e r o c a l l u s e d r e g s " ] ;
2023-02-16 17:41:37 +00:00
} )