2015-02-28 17:12:25 +00:00
|
|
|
{ stdenv, fetchurl, pkgconfig, perl, texinfo, yasm
|
2015-05-28 12:39:10 +01:00
|
|
|
, alsaLib, bzip2, fontconfig, freetype, gnutls, libiconv, lame, libass, libogg
|
2016-03-22 14:00:36 +00:00
|
|
|
, libtheora, libva, libvorbis, libvpx, lzma, libpulseaudio, soxr
|
2016-04-09 12:00:30 +01:00
|
|
|
, x264, x265, xvidcore, zlib, libopus
|
2015-04-07 08:34:27 +01:00
|
|
|
, openglSupport ? false, mesa ? null
|
|
|
|
# Build options
|
|
|
|
, runtimeCpuDetectBuild ? true # Detect CPU capabilities at runtime
|
2015-02-28 17:12:25 +00:00
|
|
|
, multithreadBuild ? true # Multithreading via pthreads/win32 threads
|
2016-03-22 14:00:36 +00:00
|
|
|
, sdlSupport ? !stdenv.isArm, SDL ? null
|
|
|
|
, vdpauSupport ? !stdenv.isArm, libvdpau ? null
|
2015-04-07 08:34:27 +01:00
|
|
|
# Developer options
|
2015-02-28 17:12:25 +00:00
|
|
|
, debugDeveloper ? false
|
|
|
|
, optimizationsDeveloper ? true
|
2015-04-07 08:34:27 +01:00
|
|
|
, extraWarningsDeveloper ? false
|
2015-10-29 13:15:42 +00:00
|
|
|
# Darwin frameworks
|
|
|
|
, Cocoa
|
2015-04-07 08:34:27 +01:00
|
|
|
# Inherit generics
|
2015-02-28 17:12:25 +00:00
|
|
|
, branch, sha256, version, ...
|
|
|
|
}:
|
|
|
|
|
|
|
|
/* Maintainer notes:
|
|
|
|
*
|
2015-04-07 08:34:27 +01:00
|
|
|
* THIS IS A MINIMAL BUILD OF FFMPEG, do not include dependencies unless
|
|
|
|
* a build that depends on ffmpeg requires them to be compiled into ffmpeg,
|
|
|
|
* see `ffmpeg-full' for an ffmpeg build with all features included.
|
2015-02-28 17:12:25 +00:00
|
|
|
*
|
2015-03-29 21:42:42 +01:00
|
|
|
* Need fixes to support Darwin:
|
2015-04-07 08:34:27 +01:00
|
|
|
* libvpx pulseaudio
|
2015-02-28 17:12:25 +00:00
|
|
|
*
|
|
|
|
* Known issues:
|
2015-04-07 08:34:27 +01:00
|
|
|
* 0.6 - fails to compile (unresolved) (so far, only disabling a number of
|
|
|
|
* features works, but that is not a feasible solution)
|
2015-02-28 17:12:25 +00:00
|
|
|
* 0.6.90 - mmx: compile errors (fix: disable for 0.6.90-rc0)
|
|
|
|
* 1.1 - libsoxr: compile error (fix: disable for 1.1)
|
2015-04-07 08:34:27 +01:00
|
|
|
* Support was initially added in 1.1 before soxr api change, fix
|
|
|
|
* would probably be to add soxr-1.0
|
2015-02-28 17:12:25 +00:00
|
|
|
* ALL - Cross-compiling will disable features not present on host OS
|
2015-04-07 08:34:27 +01:00
|
|
|
* (e.g. dxva2 support [DirectX] will not be enabled unless natively
|
|
|
|
* compiled on Cygwin)
|
2015-02-28 17:12:25 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
let
|
2016-03-22 14:00:36 +00:00
|
|
|
inherit (stdenv) icCygwin isDarwin isFreeBSD isLinux isArm;
|
2015-04-07 08:34:27 +01:00
|
|
|
inherit (stdenv.lib) optional optionals enableFeature;
|
|
|
|
|
2015-02-28 17:12:25 +00:00
|
|
|
cmpVer = builtins.compareVersions;
|
|
|
|
reqMin = requiredVersion: (cmpVer requiredVersion branch != 1);
|
|
|
|
reqMatch = requiredVersion: (cmpVer requiredVersion branch == 0);
|
|
|
|
|
2015-04-07 08:34:27 +01:00
|
|
|
ifMinVer = minVer: flag: if reqMin minVer then flag else null;
|
2015-02-28 17:12:25 +00:00
|
|
|
|
|
|
|
# Version specific fix
|
|
|
|
verFix = withoutFix: fixVer: withFix: if reqMatch fixVer then withFix else withoutFix;
|
|
|
|
|
2016-03-22 14:00:36 +00:00
|
|
|
# Disable dependency that needs fixes before it will work on Darwin or Arm
|
|
|
|
disDarwinOrArmFix = origArg: minVer: fixArg: if ((isDarwin || isArm) && reqMin minVer) then fixArg else origArg;
|
2015-02-28 17:12:25 +00:00
|
|
|
in
|
|
|
|
|
2015-04-07 08:34:27 +01:00
|
|
|
assert openglSupport -> mesa != null;
|
2015-02-28 17:12:25 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
|
|
|
|
name = "ffmpeg-${version}";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://www.ffmpeg.org/releases/${name}.tar.bz2";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
patchPhase = ''patchShebangs .'';
|
|
|
|
|
2015-10-11 15:34:23 +01:00
|
|
|
outputs = [ "dev" "out" "bin" ]
|
|
|
|
++ optional (reqMin "1.0") "doc" ; # just dev-doc
|
|
|
|
setOutputFlags = false; # doesn't accept all and stores configureFlags in libs!
|
|
|
|
|
2015-02-28 17:12:25 +00:00
|
|
|
configureFlags = [
|
2015-04-07 08:34:27 +01:00
|
|
|
# License
|
|
|
|
"--enable-gpl"
|
|
|
|
"--enable-version3"
|
|
|
|
# Build flags
|
|
|
|
"--enable-shared"
|
|
|
|
"--disable-static"
|
|
|
|
(ifMinVer "0.6" "--enable-pic")
|
|
|
|
(enableFeature runtimeCpuDetectBuild "runtime-cpudetect")
|
|
|
|
"--enable-hardcoded-tables"
|
|
|
|
(if multithreadBuild then (
|
|
|
|
if stdenv.isCygwin then
|
2015-02-28 17:12:25 +00:00
|
|
|
"--disable-pthreads --enable-w32threads"
|
|
|
|
else # Use POSIX threads by default
|
|
|
|
"--enable-pthreads --disable-w32threads")
|
|
|
|
else
|
|
|
|
"--disable-pthreads --disable-w32threads")
|
2015-04-07 08:34:27 +01:00
|
|
|
(ifMinVer "0.9" "--disable-os2threads") # We don't support OS/2
|
2015-05-28 12:39:10 +01:00
|
|
|
"--enable-network"
|
2015-04-07 08:34:27 +01:00
|
|
|
(ifMinVer "2.4" "--enable-pixelutils")
|
|
|
|
# Executables
|
|
|
|
"--enable-ffmpeg"
|
|
|
|
"--disable-ffplay"
|
|
|
|
(ifMinVer "0.6" "--enable-ffprobe")
|
|
|
|
"--disable-ffserver"
|
|
|
|
# Libraries
|
|
|
|
(ifMinVer "0.6" "--enable-avcodec")
|
|
|
|
(ifMinVer "0.6" "--enable-avdevice")
|
|
|
|
"--enable-avfilter"
|
|
|
|
(ifMinVer "0.6" "--enable-avformat")
|
|
|
|
(ifMinVer "1.0" "--enable-avresample")
|
|
|
|
(ifMinVer "1.1" "--enable-avutil")
|
|
|
|
"--enable-postproc"
|
|
|
|
(ifMinVer "0.9" "--enable-swresample")
|
|
|
|
"--enable-swscale"
|
|
|
|
# Docs
|
|
|
|
(ifMinVer "0.6" "--disable-doc")
|
|
|
|
# External Libraries
|
|
|
|
"--enable-bzlib"
|
2015-05-28 12:39:10 +01:00
|
|
|
"--enable-gnutls"
|
2015-04-07 08:34:27 +01:00
|
|
|
(ifMinVer "1.0" "--enable-fontconfig")
|
|
|
|
(ifMinVer "0.7" "--enable-libfreetype")
|
|
|
|
"--enable-libmp3lame"
|
|
|
|
(ifMinVer "1.2" "--enable-iconv")
|
|
|
|
"--enable-libtheora"
|
|
|
|
(ifMinVer "0.6" (enableFeature (isLinux || isFreeBSD) "vaapi"))
|
|
|
|
"--enable-vdpau"
|
|
|
|
"--enable-libvorbis"
|
2016-03-22 14:00:36 +00:00
|
|
|
(disDarwinOrArmFix (ifMinVer "0.6" "--enable-libvpx") "0.6" "--disable-libvpx")
|
2015-04-07 08:34:27 +01:00
|
|
|
(ifMinVer "2.4" "--enable-lzma")
|
|
|
|
(ifMinVer "2.2" (enableFeature openglSupport "opengl"))
|
2016-03-22 14:00:36 +00:00
|
|
|
(disDarwinOrArmFix (ifMinVer "0.9" "--enable-libpulse") "0.9" "--disable-libpulse")
|
|
|
|
(ifMinVer "2.5" (if sdlSupport then "--enable-sdl" else "")) # Only configurable since 2.5, auto detected before then
|
2015-04-07 08:34:27 +01:00
|
|
|
(ifMinVer "1.2" "--enable-libsoxr")
|
|
|
|
"--enable-libx264"
|
|
|
|
"--enable-libxvid"
|
|
|
|
"--enable-zlib"
|
2016-03-26 14:01:22 +00:00
|
|
|
(ifMinVer "2.8" "--enable-libopus")
|
2016-04-09 12:00:30 +01:00
|
|
|
(ifMinVer "2.8" "--enable-libx265")
|
2015-04-07 08:34:27 +01:00
|
|
|
# Developer flags
|
|
|
|
(enableFeature debugDeveloper "debug")
|
|
|
|
(enableFeature optimizationsDeveloper "optimizations")
|
|
|
|
(enableFeature extraWarningsDeveloper "extra-warnings")
|
|
|
|
"--disable-stripping"
|
2015-02-28 17:12:25 +00:00
|
|
|
# Disable mmx support for 0.6.90
|
2015-04-07 08:34:27 +01:00
|
|
|
(verFix null "0.6.90" "--disable-mmx")
|
2015-05-11 22:37:53 +01:00
|
|
|
] ++ optional stdenv.cc.isClang "--cc=clang";
|
2015-02-28 17:12:25 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [ perl pkgconfig texinfo yasm ];
|
|
|
|
|
|
|
|
buildInputs = [
|
2015-05-28 12:39:10 +01:00
|
|
|
bzip2 fontconfig freetype gnutls libiconv lame libass libogg libtheora
|
2016-04-09 12:00:30 +01:00
|
|
|
libvdpau libvorbis lzma SDL soxr x264 x265 xvidcore zlib libopus
|
2015-04-07 08:34:27 +01:00
|
|
|
] ++ optional openglSupport mesa
|
2016-03-22 14:00:36 +00:00
|
|
|
++ optionals (!isDarwin && !isArm) [ libvpx libpulseaudio ] # Need to be fixed on Darwin and ARM
|
|
|
|
++ optional ((isLinux || isFreeBSD) && !isArm) libva
|
2015-10-29 13:15:42 +00:00
|
|
|
++ optional isLinux alsaLib
|
2016-03-22 14:00:36 +00:00
|
|
|
++ optional isDarwin Cocoa
|
|
|
|
++ optional vdpauSupport libvdpau
|
|
|
|
++ optional sdlSupport SDL;
|
|
|
|
|
2015-02-28 17:12:25 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2015-10-11 15:34:23 +01:00
|
|
|
postFixup = ''
|
2015-12-02 09:03:23 +00:00
|
|
|
moveToOutput bin "$bin"
|
|
|
|
moveToOutput share/ffmpeg/examples "$doc"
|
2015-10-11 15:34:23 +01:00
|
|
|
'';
|
|
|
|
|
2015-02-28 17:12:25 +00:00
|
|
|
/* Cross-compilation is untested, consider this an outline, more work
|
|
|
|
needs to be done to portions of the build to get it to work correctly */
|
|
|
|
crossAttrs = let
|
|
|
|
os = ''
|
|
|
|
if [ "${stdenv.cross.config}" = "*cygwin*" ] ; then
|
|
|
|
# Probably should look for mingw too
|
|
|
|
echo "cygwin"
|
|
|
|
elif [ "${stdenv.cross.config}" = "*darwin*" ] ; then
|
|
|
|
echo "darwin"
|
|
|
|
elif [ "${stdenv.cross.config}" = "*freebsd*" ] ; then
|
|
|
|
echo "freebsd"
|
|
|
|
elif [ "${stdenv.cross.config}" = "*linux*" ] ; then
|
|
|
|
echo "linux"
|
|
|
|
elif [ "${stdenv.cross.config}" = "*netbsd*" ] ; then
|
|
|
|
echo "netbsd"
|
|
|
|
elif [ "${stdenv.cross.config}" = "*openbsd*" ] ; then
|
|
|
|
echo "openbsd"
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
dontSetConfigureCross = true;
|
|
|
|
configureFlags = configureFlags ++ [
|
|
|
|
"--cross-prefix=${stdenv.cross.config}-"
|
|
|
|
"--enable-cross-compile"
|
|
|
|
"--target_os=${os}"
|
|
|
|
"--arch=${stdenv.cross.arch}"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2016-04-09 12:00:39 +01:00
|
|
|
installFlags = [ "install-man" ];
|
|
|
|
|
2015-02-28 17:12:25 +00:00
|
|
|
passthru = {
|
2016-03-22 14:00:36 +00:00
|
|
|
vaapiSupport = if reqMin "0.6" && ((isLinux || isFreeBSD) && !isArm) then true else false;
|
|
|
|
inherit vdpauSupport;
|
2015-02-28 17:12:25 +00:00
|
|
|
};
|
|
|
|
|
2015-04-07 08:34:27 +01:00
|
|
|
meta = with stdenv.lib; {
|
2015-02-28 17:12:25 +00:00
|
|
|
description = "A complete, cross-platform solution to record, convert and stream audio and video";
|
|
|
|
homepage = http://www.ffmpeg.org/;
|
|
|
|
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.
|
|
|
|
'';
|
2015-04-07 08:34:27 +01:00
|
|
|
license = licenses.gpl3;
|
2015-02-28 17:12:25 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
maintainers = with maintainers; [ codyopel fuuzetsu ];
|
|
|
|
inherit branch;
|
|
|
|
};
|
|
|
|
}
|