1{ stdenv, fetchurl, pkgconfig, yasm, bzip2, zlib
2, mp3Support ? true, lame ? null
3, speexSupport ? true, speex ? null
4, theoraSupport ? true, libtheora ? null
5, vorbisSupport ? true, libvorbis ? null
6, vpxSupport ? true, libvpx ? null
7, x264Support ? false, x264 ? null
8, xvidSupport ? true, xvidcore ? null
9, faacSupport ? false, faac ? null
10, vaapiSupport ? false, libva ? null # ToDo: it has huge closure
11, vdpauSupport ? true, libvdpau ? null
12, freetypeSupport ? true, freetype ? null # it's small and almost everywhere
13, SDL # only for avplay in $tools, adds nontrivial closure to it
14, enableGPL ? true # ToDo: some additional default stuff may need GPL
15, enableUnfree ? faacSupport
16}:
17
18assert faacSupport -> enableUnfree;
19
20with { inherit (stdenv.lib) optional optionals; };
21
22/* ToDo:
23 - more deps, inspiration: http://packages.ubuntu.com/raring/libav-tools
24 - maybe do some more splitting into outputs
25*/
26
27let
28 result = {
29 libav_0_8 = libavFun "0.8.17" "31ace2daeb8c105deed9cd3476df47318d417714";
30 libav_9 = libavFun "9.18" "e10cde4587c4d4d3bb11d30c7b47e953664cd714";
31 libav_11 = libavFun "11.4" "c2ab12102de187f2675a56b828b4a5e9136ab747";
32 };
33
34 libavFun = version : sha1 : stdenv.mkDerivation rec {
35 name = "libav-${version}";
36
37 src = fetchurl {
38 url = "${meta.homepage}/releases/${name}.tar.xz";
39 inherit sha1; # upstream directly provides sha1 of releases over https
40 };
41 configureFlags =
42 assert stdenv.lib.all (x: x!=null) buildInputs;
43 [
44 #"--enable-postproc" # it's now a separate package in upstream
45 "--disable-avserver" # upstream says it's in a bad state
46 "--enable-avplay"
47 "--enable-shared"
48 "--enable-runtime-cpudetect"
49 ]
50 ++ optionals enableGPL [ "--enable-gpl" "--enable-swscale" ]
51 ++ optional mp3Support "--enable-libmp3lame"
52 ++ optional speexSupport "--enable-libspeex"
53 ++ optional theoraSupport "--enable-libtheora"
54 ++ optional vorbisSupport "--enable-libvorbis"
55 ++ optional vpxSupport "--enable-libvpx"
56 ++ optional x264Support "--enable-libx264"
57 ++ optional xvidSupport "--enable-libxvid"
58 ++ optional faacSupport "--enable-libfaac --enable-nonfree"
59 ++ optional vaapiSupport "--enable-vaapi"
60 ++ optional vdpauSupport "--enable-vdpau"
61 ++ optional freetypeSupport "--enable-libfreetype"
62 ;
63
64 buildInputs = [ pkgconfig lame yasm zlib bzip2 SDL ]
65 ++ optional mp3Support lame
66 ++ optional speexSupport speex
67 ++ optional theoraSupport libtheora
68 ++ optional vorbisSupport libvorbis
69 ++ optional vpxSupport libvpx
70 ++ optional x264Support x264
71 ++ optional xvidSupport xvidcore
72 ++ optional faacSupport faac
73 ++ optional vaapiSupport libva
74 ++ optional vdpauSupport libvdpau
75 ++ optional freetypeSupport freetype
76 ;
77
78 enableParallelBuilding = true;
79
80 outputs = [ "out" "tools" ];
81
82 # move avplay to get rid of the SDL dependency in the main output
83 postInstall = ''
84 mkdir -p "$tools/bin"
85 mv "$out/bin/avplay" "$tools/bin"
86 '';
87
88 doInstallCheck = false; # fails randomly
89 installCheckTarget = "check"; # tests need to be run *after* installation
90
91 crossAttrs = {
92 dontSetConfigureCross = true;
93 configureFlags = configureFlags ++ [
94 "--cross-prefix=${stdenv.cross.config}-"
95 "--enable-cross-compile"
96 "--target_os=linux"
97 "--arch=${stdenv.cross.arch}"
98 ];
99 };
100
101 passthru = { inherit vdpauSupport; };
102
103 meta = with stdenv.lib; {
104 homepage = http://libav.org/;
105 description = "A complete, cross-platform solution to record, convert and stream audio and video (fork of ffmpeg)";
106 license = with licenses; if enableUnfree then unfree #ToDo: redistributable or not?
107 else if enableGPL then gpl2Plus else lgpl21Plus;
108 platforms = platforms.linux;
109 maintainers = [ maintainers.vcunat ];
110 };
111 }; # libavFun
112
113in result
114