diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/ffmpeg/generic.nix')
-rw-r--r-- | nixpkgs/pkgs/development/libraries/ffmpeg/generic.nix | 146 |
1 files changed, 104 insertions, 42 deletions
diff --git a/nixpkgs/pkgs/development/libraries/ffmpeg/generic.nix b/nixpkgs/pkgs/development/libraries/ffmpeg/generic.nix index 6dba78cad219..bdc0cdd5ffa4 100644 --- a/nixpkgs/pkgs/development/libraries/ffmpeg/generic.nix +++ b/nixpkgs/pkgs/development/libraries/ffmpeg/generic.nix @@ -30,25 +30,33 @@ , withFullDeps ? ffmpegVariant == "full" , fetchgit -, fetchpatch +, fetchpatch2 # Feature flags , withAlsa ? withHeadlessDeps && stdenv.isLinux # Alsa in/output supporT , withAom ? withFullDeps # AV1 reference encoder +, withAppKit ? withHeadlessDeps && stdenv.isDarwin # Apple AppKit framework , withAribcaption ? withFullDeps && lib.versionAtLeast version "6.1" # ARIB STD-B24 Caption Decoder/Renderer , withAss ? withHeadlessDeps && stdenv.hostPlatform == stdenv.buildPlatform # (Advanced) SubStation Alpha subtitle rendering +, withAudioToolbox ? withHeadlessDeps && stdenv.isDarwin # Apple AudioToolbox +, withAvFoundation ? withHeadlessDeps && stdenv.isDarwin # Apple AVFoundation framework , withBluray ? withFullDeps # BluRay reading , withBs2b ? withFullDeps # bs2b DSP library , withBzlib ? withHeadlessDeps , withCaca ? withFullDeps # Textual display (ASCII art) , withCelt ? withFullDeps # CELT decoder , withChromaprint ? withFullDeps # Audio fingerprinting -, withCuda ? withFullDeps && (with stdenv; (!isDarwin && !hostPlatform.isAarch && !hostPlatform.isRiscV)) +, withCoreImage ? withHeadlessDeps && stdenv.isDarwin # Apple CoreImage framework +, withCuda ? withFullDeps && withNvcodec , withCudaLLVM ? withFullDeps +, withCuvid ? withHeadlessDeps && withNvcodec , 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 +, 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 , withFlite ? withFullDeps # Voice Synthesis , withFontconfig ? withHeadlessDeps # Needed for drawtext filter , withFreetype ? withHeadlessDeps # Needed for drawtext filter @@ -66,22 +74,24 @@ , withModplug ? withFullDeps && !stdenv.isDarwin # ModPlug support , withMp3lame ? withHeadlessDeps # LAME MP3 encoder , withMysofa ? withFullDeps # HRTF support via SOFAlizer -, withNvdec ? withHeadlessDeps && (with stdenv; !isDarwin && hostPlatform == buildPlatform && !isAarch32 && !hostPlatform.isRiscV) -, withNvenc ? withHeadlessDeps && (with stdenv; !isDarwin && hostPlatform == buildPlatform && !isAarch32 && !hostPlatform.isRiscV) +, withNvdec ? withHeadlessDeps && withNvcodec +, withNvenc ? withHeadlessDeps && withNvcodec , withOgg ? withHeadlessDeps # Ogg container used by vorbis & theora , withOpenal ? withFullDeps # OpenAL 1.1 capture support , withOpencl ? withFullDeps , withOpencoreAmrnb ? withFullDeps && withVersion3 # AMR-NB de/encoder , withOpencoreAmrwb ? withFullDeps && withVersion3 # AMR-WB decoder -, withOpengl ? false # OpenGL rendering +, withOpengl ? withFullDeps && !stdenv.isDarwin # OpenGL rendering , withOpenh264 ? withFullDeps # H.264/AVC encoder , withOpenjpeg ? withFullDeps # JPEG 2000 de/encoder , withOpenmpt ? withFullDeps # Tracked music files decoder , withOpus ? withHeadlessDeps # Opus de/encoder , withPlacebo ? withFullDeps && !stdenv.isDarwin # libplacebo video processing library , withPulse ? withSmallDeps && stdenv.isLinux # Pulseaudio input support +, withQrencode ? withFullDeps && lib.versionAtLeast version "7" # QR encode generation +, withQuirc ? withFullDeps && lib.versionAtLeast version "7" # QR decoding , withRav1e ? withFullDeps # AV1 encoder (focused on speed and safety) -, withRtmp ? false # RTMP[E] support +, withRtmp ? withFullDeps # RTMP[E] support , withSamba ? withFullDeps && !stdenv.isDarwin && withGPLv3 # Samba protocol , withSdl2 ? withSmallDeps , withShaderc ? withFullDeps && !stdenv.isDarwin && lib.versionAtLeast version "5.0" @@ -91,16 +101,18 @@ , withSsh ? withHeadlessDeps # SFTP protocol , withSvg ? withFullDeps # SVG protocol , withSvtav1 ? withHeadlessDeps && !stdenv.isAarch64 && !stdenv.hostPlatform.isMinGW # AV1 encoder/decoder (focused on speed and correctness) -, withTensorflow ? false # Tensorflow dnn backend support +, withTensorflow ? false # Tensorflow dnn backend support (Increases closure size by ~390 MiB) , withTheora ? withHeadlessDeps # Theora encoder , withV4l2 ? withHeadlessDeps && stdenv.isLinux # Video 4 Linux support , withV4l2M2m ? withV4l2 , withVaapi ? withHeadlessDeps && (with stdenv; isLinux || isFreeBSD) # Vaapi hardware acceleration , withVdpau ? withSmallDeps && !stdenv.hostPlatform.isMinGW # Vdpau hardware acceleration +, withVideoToolbox ? withHeadlessDeps && stdenv.isDarwin # Apple VideoToolbox , 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 , withVorbis ? withHeadlessDeps # Vorbis de/encoding, native encoder exists +, withVpl ? false # Hardware acceleration via intel libvpl , withVpx ? withHeadlessDeps && stdenv.buildPlatform == stdenv.hostPlatform # VP8 & VP9 de/encoding , withVulkan ? withSmallDeps && !stdenv.isDarwin , withWebp ? withFullDeps # WebP encoder @@ -111,6 +123,8 @@ , withXcbShape ? withFullDeps # X11 grabbing shape rendering , withXcbShm ? withFullDeps # X11 grabbing shm communication , withXcbxfixes ? withFullDeps # X11 grabbing mouse rendering +, withXevd ? withFullDeps && lib.versionAtLeast version "7" && stdenv.hostPlatform.isx86 # MPEG-5 EVC decoding +, withXeve ? withFullDeps && lib.versionAtLeast version "7" && stdenv.hostPlatform.isx86 # MPEG-5 EVC encoding , withXlib ? withFullDeps # Xlib support , withXml2 ? withFullDeps # libxml2 support, for IMF and DASH demuxers , withXvid ? withHeadlessDeps && withGPL # Xvid encoder, native encoder exists @@ -147,7 +161,7 @@ * Program options */ , buildFfmpeg ? withHeadlessDeps # Build ffmpeg executable -, buildFfplay ? withFullDeps # Build ffplay executable +, buildFfplay ? withSmallDeps # Build ffplay executable , buildFfprobe ? withHeadlessDeps # Build ffprobe executable , buildQtFaststart ? withFullDeps # Build qt-faststart executable , withBin ? buildFfmpeg || buildFfplay || buildFfprobe || buildQtFaststart @@ -223,6 +237,8 @@ , libcaca , libdc1394 , libdrm +, libdvdnav +, libdvdread , libGL , libGLU , libiconv @@ -246,6 +262,7 @@ , libvdpau , libvmaf , libvorbis +, libvpl , libvpx , libwebp , libX11 @@ -261,6 +278,8 @@ , opencore-amr , openh264 , openjpeg +, qrencode +, quirc , rav1e , rtmpdump , samba @@ -277,6 +296,8 @@ , x264 , x265 , xavs +, xevd +, xeve , xvidcore , xz , zeromq4 @@ -285,13 +306,10 @@ /* * Darwin frameworks */ +, AppKit +, AudioToolbox , AVFoundation -, Cocoa -, CoreAudio -, CoreMedia -, CoreServices -, MediaToolbox -, VideoDecodeAcceleration +, CoreImage , VideoToolbox /* * Testing @@ -328,6 +346,7 @@ assert withGPLv3 -> withGPL && withVersion3; * Build dependencies */ assert withPixelutils -> buildAvutil; +assert !(withMfx && withVpl); # incompatible features /* * Program dependencies */ @@ -351,6 +370,11 @@ assert buildAvformat -> buildAvcodec && buildAvutil; # configure flag since 0.6 assert buildPostproc -> buildAvutil; assert buildSwscale -> buildAvutil; +/* + * External Library dependencies + */ +assert (withCuda || withCuvid || withNvdec || withNvenc) -> withNvcodec; + stdenv.mkDerivation (finalAttrs: { pname = "ffmpeg" + (optionalString (ffmpegVariant != "small") "-${ffmpegVariant}"); inherit version; @@ -365,25 +389,25 @@ stdenv.mkDerivation (finalAttrs: { --replace /usr/local/lib/frei0r-1 ${frei0r}/lib/frei0r-1 ''; - patches = map (patch: fetchpatch patch) ([ ] + patches = map (patch: fetchpatch2 patch) ([ ] ++ optionals (versionOlder version "5") [ { name = "libsvtav1-1.5.0-compat-compressed_ten_bit_format.patch"; url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/031f1561cd286596cdb374da32f8aa816ce3b135"; - hash = "sha256-mSnmAkoNikDpxcN+A/hpB7mUbbtcMvm4tG6gZFuroe8="; + hash = "sha256-agJgzIzrBTQBAypuCmGXXFo7vw6Iodw5Ny5O5QCKCn8="; } { # Backport fix for binutils-2.41. name = "binutils-2.41.patch"; url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/effadce6c756247ea8bae32dc13bb3e6f464f0eb"; - hash = "sha256-vlBUMJ1bORQHRNpuzc5iXsTWwS/CN5BmGIA8g7H7mJE="; + hash = "sha256-vLSltvZVMcQ0CnkU0A29x6fJSywE8/aU+Mp9os8DZYY="; } # 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. { name = "utils-fix_crash_in_ff_seek_frame_binary.patch"; url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/ab792634197e364ca1bb194f9abe36836e42f12d"; - hash = "sha256-UxZ4VneZpw+Q/UwkEUDNdb2nOx1QnMrZ40UagspNTxI="; + hash = "sha256-vqqVACjbCcGL9Qvmg1QArSKqVmOqr8BEr+OxTBDt6mA="; postFetch = '' substituteInPlace "$out" \ --replace libavformat/seek.c libavformat/utils.c \ @@ -391,20 +415,26 @@ stdenv.mkDerivation (finalAttrs: { ''; } ] - ++ (lib.optional (lib.versionAtLeast version "6" && lib.versionOlder version "6.1") - { # this can be removed post 6.1 - name = "fix_aacps_tablegen"; - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/814178f92647be2411516bbb82f48532373d2554"; - hash = "sha256-FQV9/PiarPXCm45ldtCsxGHjlrriL8DKpn1LaKJ8owI="; - } - ) - ++ (lib.optional (lib.versionAtLeast version "6.1" && lib.versionOlder version "6.2") + ++ (lib.optionals (lib.versionAtLeast version "6.1" && lib.versionOlder version "6.2") [ { # this can be removed post 6.1 name = "fix_build_failure_due_to_PropertyKey_EncoderID"; url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/cb049d377f54f6b747667a93e4b719380c3e9475"; - hash = "sha256-Ittka0mId1N/BwJ0FQ0ygpTSS6Y11u2SjWDpbGN+KXo="; + hash = "sha256-sxRXKKgUak5vsQTiV7ge8vp+N22CdTIvuczNgVRP72c="; + } + { + name = "fix_vulkan_av1"; + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/e06ce6d2b45edac4a2df04f304e18d4727417d24"; + hash = "sha256-73mlX1rdJrguw7OXaSItfHtI7gflDrFj+7SepVvvUIg="; + } + ]) + ++ (lib.optionals (lib.versionAtLeast version "7.0") [ + { + # Will likely be obsolete in >7.0 + name = "fate_avoid_dependency_on_samples"; + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/7b7b7819bd21cc92ac07f6696b0e7f26fa8f9834"; + hash = "sha256-TKI289XqtG86Sj9s7mVYvmkjAuRXeK+2cYYEDkg6u6I="; } - )); + ])); configurePlatforms = []; setOutputFlags = false; # Only accepts some of them @@ -490,22 +520,32 @@ stdenv.mkDerivation (finalAttrs: { */ (enableFeature withAlsa "alsa") (enableFeature withAom "libaom") + (enableFeature withAppKit "appkit") ] ++ optionals (versionAtLeast version "6.1") [ (enableFeature withAribcaption "libaribcaption") ] ++ [ (enableFeature withAss "libass") + (enableFeature withAudioToolbox "audiotoolbox") + (enableFeature withAvFoundation "avfoundation") (enableFeature withBluray "libbluray") (enableFeature withBs2b "libbs2b") (enableFeature withBzlib "bzlib") (enableFeature withCaca "libcaca") (enableFeature withCelt "libcelt") (enableFeature withChromaprint "chromaprint") + (enableFeature withCoreImage "coreimage") (enableFeature withCuda "cuda") (enableFeature withCudaLLVM "cuda-llvm") + (enableFeature withCuvid "cuvid") (enableFeature withDav1d "libdav1d") (enableFeature withDc1394 "libdc1394") (enableFeature withDrm "libdrm") + ] ++ optionals (versionAtLeast version "7") [ + (enableFeature withDvdnav "libdvdnav") + (enableFeature withDvdread "libdvdread") + ] ++ [ (enableFeature withFdkAac "libfdk-aac") + (enableFeature withNvcodec "ffnvcodec") (enableFeature withFlite "libflite") (enableFeature withFontconfig "fontconfig") (enableFeature withFontconfig "libfontconfig") @@ -526,7 +566,6 @@ stdenv.mkDerivation (finalAttrs: { (enableFeature withModplug "libmodplug") (enableFeature withMp3lame "libmp3lame") (enableFeature withMysofa "libmysofa") - (enableFeature withNvdec "cuvid") (enableFeature withNvdec "nvdec") (enableFeature withNvenc "nvenc") (enableFeature withOpenal "openal") @@ -542,6 +581,10 @@ stdenv.mkDerivation (finalAttrs: { (enableFeature withPlacebo "libplacebo") ] ++ [ (enableFeature withPulse "libpulse") + ] ++ optionals (versionAtLeast version "7") [ + (enableFeature withQrencode "libqrencode") + (enableFeature withQuirc "libquirc") + ] ++ [ (enableFeature withRav1e "librav1e") (enableFeature withRtmp "librtmp") (enableFeature withSamba "libsmbclient") @@ -561,6 +604,10 @@ stdenv.mkDerivation (finalAttrs: { (enableFeature withV4l2M2m "v4l2-m2m") (enableFeature withVaapi "vaapi") (enableFeature withVdpau "vdpau") + ] ++ optionals (versionAtLeast version "6.0") [ + (enableFeature withVpl "libvpl") + ] ++ [ + (enableFeature withVideoToolbox "videotoolbox") (enableFeature withVidStab "libvidstab") # Actual min. version 2.0 (enableFeature withVmaf "libvmaf") (enableFeature withVoAmrwbenc "libvo-amrwbenc") @@ -575,6 +622,10 @@ stdenv.mkDerivation (finalAttrs: { (enableFeature withXcbShape "libxcb-shape") (enableFeature withXcbShm "libxcb-shm") (enableFeature withXcbxfixes "libxcb-xfixes") + ] ++ optionals (versionAtLeast version "7") [ + (enableFeature withXevd "libxevd") + (enableFeature withXeve "libxeve") + ] ++ [ (enableFeature withXlib "xlib") (enableFeature withXml2 "libxml2") (enableFeature withXvid "libxvid") @@ -615,18 +666,25 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [] ++ optionals withAlsa [ alsa-lib ] ++ optionals withAom [ libaom ] + ++ optionals withAppKit [ AppKit ] ++ optionals withAribcaption [ libaribcaption ] ++ optionals withAss [ libass ] + ++ optionals withAudioToolbox [ AudioToolbox ] + ++ optionals withAvFoundation [ AVFoundation ] ++ optionals withBluray [ libbluray ] ++ optionals withBs2b [ libbs2b ] ++ optionals withBzlib [ bzip2 ] ++ optionals withCaca [ libcaca ] ++ optionals withCelt [ celt ] ++ optionals withChromaprint [ chromaprint ] + ++ optionals withCoreImage [ CoreImage ] ++ optionals withDav1d [ dav1d ] ++ optionals withDc1394 [ libdc1394 libraw1394 ] ++ optionals withDrm [ libdrm ] + ++ optionals withDvdnav [ libdvdnav ] + ++ optionals withDvdread [ libdvdread ] ++ optionals withFdkAac [ fdk_aac ] + ++ optionals withNvcodec [ (if (lib.versionAtLeast version "6") then nv-codec-headers-12 else nv-codec-headers) ] ++ optionals withFlite [ flite ] ++ optionals withFontconfig [ fontconfig ] ++ optionals withFreetype [ freetype ] @@ -644,7 +702,6 @@ stdenv.mkDerivation (finalAttrs: { ++ optionals withModplug [ libmodplug ] ++ optionals withMp3lame [ lame ] ++ optionals withMysofa [ libmysofa ] - ++ optionals (withNvdec || withNvenc) [ (if (lib.versionAtLeast version "6") then nv-codec-headers-12 else nv-codec-headers) ] ++ optionals withOgg [ libogg ] ++ optionals withOpenal [ openal ] ++ optionals withOpencl [ ocl-icd opencl-headers ] @@ -656,6 +713,8 @@ stdenv.mkDerivation (finalAttrs: { ++ optionals withOpus [ libopus ] ++ optionals withPlacebo [ (if (lib.versionAtLeast version "6.1") then libplacebo else libplacebo_5) vulkan-headers ] ++ optionals withPulse [ libpulseaudio ] + ++ optionals withQrencode [ qrencode ] + ++ optionals withQuirc [ quirc ] ++ optionals withRav1e [ rav1e ] ++ optionals withRtmp [ rtmpdump ] ++ optionals withSamba [ samba ] @@ -672,10 +731,12 @@ stdenv.mkDerivation (finalAttrs: { ++ optionals withV4l2 [ libv4l ] ++ optionals withVaapi [ (if withSmallDeps then libva else libva-minimal) ] ++ optionals withVdpau [ libvdpau ] + ++ optionals withVideoToolbox [ VideoToolbox ] ++ optionals withVidStab [ vid-stab ] ++ optionals withVmaf [ libvmaf ] ++ optionals withVoAmrwbenc [ vo-amrwbenc ] ++ optionals withVorbis [ libvorbis ] + ++ optionals withVpl [ libvpl ] ++ optionals withVpx [ libvpx ] ++ optionals withVulkan [ vulkan-headers vulkan-loader ] ++ optionals withWebp [ libwebp ] @@ -683,23 +744,15 @@ stdenv.mkDerivation (finalAttrs: { ++ optionals withX265 [ x265 ] ++ optionals withXavs [ xavs ] ++ optionals withXcb [ libxcb ] + ++ optionals withXevd [ xevd ] + ++ optionals withXeve [ xeve ] ++ optionals withXlib [ libX11 libXv libXext ] ++ optionals withXml2 [ libxml2 ] ++ optionals withXvid [ xvidcore ] ++ optionals withZimg [ zimg ] ++ optionals withZlib [ zlib ] ++ optionals withZmq [ zeromq4 ] - ++ optionals stdenv.isDarwin [ - # TODO fine-grained flags - AVFoundation - Cocoa - CoreAudio - CoreMedia - CoreServices - MediaToolbox - VideoDecodeAcceleration - VideoToolbox - ]; + ; buildFlags = [ "all" ] ++ optional buildQtFaststart "tools/qt-faststart"; # Build qt-faststart executable @@ -767,7 +820,16 @@ stdenv.mkDerivation (finalAttrs: { ++ optional withGPLv3 gpl3Plus ++ optional withUnfree unfreeRedistributable ++ optional (withGPL && withUnfree) unfree; - pkgConfigModules = [ "libavutil" ]; + pkgConfigModules = [ ] + ++ optional buildAvcodec "libavcodec" + ++ optional buildAvdevice "libavdevice" + ++ optional buildAvfilter "libavfilter" + ++ optional buildAvformat "libavformat" + ++ optional buildAvresample "libavresample" + ++ optional buildAvutil "libavutil" + ++ optional buildPostproc "libpostproc" + ++ optional buildSwresample "libswresample" + ++ optional buildSwscale "libswscale"; platforms = platforms.all; # See https://github.com/NixOS/nixpkgs/pull/295344#issuecomment-1992263658 broken = stdenv.hostPlatform.isMinGW && stdenv.hostPlatform.is64bit; |