2021-01-21 17:00:13 +00:00
|
|
|
{ lib, stdenv, fetchurl, pkg-config, yasm, bzip2, zlib, perl, bash
|
2013-08-17 06:17:44 +01:00
|
|
|
, mp3Support ? true, lame ? null
|
|
|
|
, speexSupport ? true, speex ? null
|
|
|
|
, theoraSupport ? true, libtheora ? null
|
|
|
|
, vorbisSupport ? true, libvorbis ? null
|
|
|
|
, vpxSupport ? true, libvpx ? null
|
|
|
|
, x264Support ? false, x264 ? null
|
|
|
|
, xvidSupport ? true, xvidcore ? null
|
|
|
|
, faacSupport ? false, faac ? null
|
2015-10-28 13:15:44 +00:00
|
|
|
, vaapiSupport ? true, libva ? null
|
2013-08-17 06:17:44 +01:00
|
|
|
, vdpauSupport ? true, libvdpau ? null
|
|
|
|
, freetypeSupport ? true, freetype ? null # it's small and almost everywhere
|
2014-08-30 22:30:31 +01:00
|
|
|
, SDL # only for avplay in $bin, adds nontrivial closure to it
|
2013-08-17 06:17:44 +01:00
|
|
|
, enableGPL ? true # ToDo: some additional default stuff may need GPL
|
|
|
|
, enableUnfree ? faacSupport
|
2011-07-15 13:20:34 +01:00
|
|
|
}:
|
|
|
|
|
2013-08-17 06:17:44 +01:00
|
|
|
assert faacSupport -> enableUnfree;
|
2011-07-15 13:20:34 +01:00
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
let inherit (lib) optional hasPrefix enableFeature; in
|
2011-07-15 13:20:34 +01:00
|
|
|
|
2013-08-17 06:17:44 +01:00
|
|
|
/* ToDo:
|
2018-07-20 02:12:04 +01:00
|
|
|
- more deps, inspiration: https://packages.ubuntu.com/raring/libav-tools
|
2013-08-17 06:17:44 +01:00
|
|
|
- maybe do some more splitting into outputs
|
|
|
|
*/
|
|
|
|
|
|
|
|
let
|
|
|
|
result = {
|
2017-10-30 23:12:08 +00:00
|
|
|
# e.g. https://libav.org/releases/libav-11.11.tar.xz.sha1
|
2018-02-18 18:56:34 +00:00
|
|
|
libav_0_8 = libavFun "0.8.21" "d858f65128dad0bac1a8c3a51e5cbb27a7c79b3f";
|
|
|
|
libav_11 = libavFun "11.12" "61d5dcab5fde349834af193a572b12a5fd6a4d42";
|
|
|
|
libav_12 = libavFun "12.3" "386c18c8b857f23dfcf456ce40370716130211d9";
|
2011-07-15 13:20:34 +01:00
|
|
|
};
|
2013-08-17 06:17:44 +01:00
|
|
|
|
2014-09-13 20:05:16 +01:00
|
|
|
libavFun = version : sha1 : stdenv.mkDerivation rec {
|
2019-08-13 22:52:01 +01:00
|
|
|
pname = "libav";
|
|
|
|
inherit version;
|
2013-08-17 06:17:44 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
2019-08-13 22:52:01 +01:00
|
|
|
url = "${meta.homepage}/releases/${pname}-${version}.tar.xz";
|
2014-09-13 20:05:16 +01:00
|
|
|
inherit sha1; # upstream directly provides sha1 of releases over https
|
2013-08-17 06:17:44 +01:00
|
|
|
};
|
2016-03-21 08:56:25 +00:00
|
|
|
|
2016-05-01 17:22:40 +01:00
|
|
|
patches = []
|
2016-06-22 09:24:26 +01:00
|
|
|
++ optional (vpxSupport && hasPrefix "0.8." version) ./vpxenc-0.8.17-libvpx-1.5.patch
|
2021-01-29 15:58:26 +00:00
|
|
|
++ optional (vpxSupport && hasPrefix "12." version) ./vpx-12.3-libvpx-1.8.patch
|
2017-04-18 17:50:40 +01:00
|
|
|
;
|
2016-05-01 17:22:40 +01:00
|
|
|
|
2018-03-08 22:34:57 +00:00
|
|
|
postPatch = ''
|
|
|
|
patchShebangs .
|
|
|
|
# another shebang was hidden in a here document text
|
|
|
|
substituteInPlace ./configure --replace "#! /bin/sh" "#!${bash}/bin/sh"
|
|
|
|
'';
|
2016-03-21 08:56:25 +00:00
|
|
|
|
2018-05-10 06:38:51 +01:00
|
|
|
configurePlatforms = [];
|
2021-01-21 17:00:13 +00:00
|
|
|
configureFlags = assert lib.all (x: x!=null) buildInputs; [
|
2018-08-20 19:43:41 +01:00
|
|
|
"--arch=${stdenv.hostPlatform.parsed.cpu.name}"
|
|
|
|
"--target_os=${stdenv.hostPlatform.parsed.kernel.name}"
|
2013-08-17 06:17:44 +01:00
|
|
|
#"--enable-postproc" # it's now a separate package in upstream
|
|
|
|
"--disable-avserver" # upstream says it's in a bad state
|
|
|
|
"--enable-avplay"
|
|
|
|
"--enable-shared"
|
|
|
|
"--enable-runtime-cpudetect"
|
2021-02-16 11:48:46 +00:00
|
|
|
"--cc=${stdenv.cc.targetPrefix}cc"
|
2018-05-10 06:38:51 +01:00
|
|
|
(enableFeature enableGPL "gpl")
|
|
|
|
(enableFeature enableGPL "swscale")
|
|
|
|
(enableFeature mp3Support "libmp3lame")
|
|
|
|
(enableFeature mp3Support "libmp3lame")
|
|
|
|
(enableFeature speexSupport "libspeex")
|
|
|
|
(enableFeature theoraSupport "libtheora")
|
|
|
|
(enableFeature vorbisSupport "libvorbis")
|
|
|
|
(enableFeature vpxSupport "libvpx")
|
|
|
|
(enableFeature x264Support "libx264")
|
|
|
|
(enableFeature xvidSupport "libxvid")
|
|
|
|
(enableFeature faacSupport "libfaac")
|
|
|
|
(enableFeature faacSupport "nonfree")
|
|
|
|
(enableFeature vaapiSupport "vaapi")
|
|
|
|
(enableFeature vdpauSupport "vdpau")
|
|
|
|
(enableFeature freetypeSupport "libfreetype")
|
|
|
|
] ++ optional (stdenv.hostPlatform != stdenv.buildPlatform) [
|
|
|
|
"--cross-prefix=${stdenv.cc.targetPrefix}"
|
|
|
|
"--enable-cross-compile"
|
|
|
|
];
|
2013-08-17 06:17:44 +01:00
|
|
|
|
2021-01-19 06:50:56 +00:00
|
|
|
nativeBuildInputs = [ pkg-config perl ];
|
2018-03-08 22:34:57 +00:00
|
|
|
buildInputs = [ lame yasm zlib bzip2 SDL bash ]
|
2016-03-18 06:49:38 +00:00
|
|
|
++ [ perl ] # for install-man target
|
2013-08-17 06:17:44 +01:00
|
|
|
++ optional mp3Support lame
|
|
|
|
++ optional speexSupport speex
|
|
|
|
++ optional theoraSupport libtheora
|
|
|
|
++ optional vorbisSupport libvorbis
|
|
|
|
++ optional vpxSupport libvpx
|
|
|
|
++ optional x264Support x264
|
|
|
|
++ optional xvidSupport xvidcore
|
|
|
|
++ optional faacSupport faac
|
|
|
|
++ optional vaapiSupport libva
|
|
|
|
++ optional vdpauSupport libvdpau
|
|
|
|
++ optional freetypeSupport freetype
|
|
|
|
;
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2016-08-29 01:30:01 +01:00
|
|
|
outputs = [ "bin" "dev" "out" ];
|
2015-10-04 10:29:37 +01:00
|
|
|
setOutputFlags = false;
|
2013-08-17 06:17:44 +01:00
|
|
|
|
2016-03-18 06:49:38 +00:00
|
|
|
# alltools to build smaller tools, incl. aviocat, ismindex, qt-faststart, etc.
|
2019-10-27 13:03:25 +00:00
|
|
|
buildFlags = [ "all" "alltools" "install-man" ];
|
2016-03-18 06:49:38 +00:00
|
|
|
|
2018-03-08 22:34:57 +00:00
|
|
|
|
2013-08-17 06:17:44 +01:00
|
|
|
postInstall = ''
|
2016-04-01 09:06:01 +01:00
|
|
|
moveToOutput bin "$bin"
|
2016-03-18 06:49:38 +00:00
|
|
|
# alltools target compiles an executable in tools/ for every C
|
|
|
|
# source file in tools/, so move those to $out
|
|
|
|
for tool in $(find tools -type f -executable); do
|
2016-04-01 09:06:01 +01:00
|
|
|
mv "$tool" "$bin/bin/"
|
2016-03-18 06:49:38 +00:00
|
|
|
done
|
2013-08-17 06:17:44 +01:00
|
|
|
'';
|
|
|
|
|
2014-05-07 13:02:25 +01:00
|
|
|
doInstallCheck = false; # fails randomly
|
2013-08-17 06:17:44 +01:00
|
|
|
installCheckTarget = "check"; # tests need to be run *after* installation
|
|
|
|
|
|
|
|
passthru = { inherit vdpauSupport; };
|
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
meta = with lib; {
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://libav.org/";
|
2013-08-17 06:17:44 +01:00
|
|
|
description = "A complete, cross-platform solution to record, convert and stream audio and video (fork of ffmpeg)";
|
|
|
|
license = with licenses; if enableUnfree then unfree #ToDo: redistributable or not?
|
|
|
|
else if enableGPL then gpl2Plus else lgpl21Plus;
|
2016-03-18 06:49:38 +00:00
|
|
|
platforms = with platforms; linux ++ darwin;
|
2021-01-30 17:27:03 +00:00
|
|
|
knownVulnerabilities =
|
|
|
|
lib.optional (lib.versionOlder version "12.1") "CVE-2017-9051"
|
|
|
|
++ lib.optionals (lib.versionOlder version "12.3") [ "CVE-2018-5684" "CVE-2018-5766" ]
|
|
|
|
++ lib.optionals (lib.versionOlder version "12.4") [ "CVE-2019-9717" "CVE-2019-9720" ];
|
2013-08-17 06:17:44 +01:00
|
|
|
};
|
|
|
|
}; # libavFun
|
|
|
|
|
|
|
|
in result
|