2015-02-28 12:12:25 -05:00
{ stdenv , fetchurl , pkgconfig , perl , texinfo , yasm
2015-05-28 07:39:10 -04:00
, alsaLib , bzip2 , fontconfig , freetype , gnutls , libiconv , lame , libass , libogg
2016-03-22 15:00:36 +01:00
, libtheora , libva , libvorbis , libvpx , lzma , libpulseaudio , soxr
2016-04-09 14:00:30 +03:00
, x264 , x265 , xvidcore , zlib , libopus
2015-04-07 03:34:27 -04:00
, openglSupport ? false , mesa ? null
# Build options
, runtimeCpuDetectBuild ? true # Detect CPU capabilities at runtime
2015-02-28 12:12:25 -05:00
, multithreadBuild ? true # Multithreading via pthreads/win32 threads
2017-04-22 18:46:23 -07:00
, sdlSupport ? ! stdenv . isArm , SDL ? null , SDL2 ? null
2016-03-22 15:00:36 +01:00
, vdpauSupport ? ! stdenv . isArm , libvdpau ? null
2015-04-07 03:34:27 -04:00
# Developer options
2015-02-28 12:12:25 -05:00
, debugDeveloper ? false
, optimizationsDeveloper ? true
2015-04-07 03:34:27 -04:00
, extraWarningsDeveloper ? false
2015-10-29 15:15:42 +02:00
# Darwin frameworks
2016-08-07 12:25:01 +02:00
, Cocoa , darwinFrameworks ? [ Cocoa ]
2015-04-07 03:34:27 -04:00
# Inherit generics
2016-05-17 00:58:15 +02:00
, branch , sha256 , version , patches ? [ ] , . . .
2015-02-28 12:12:25 -05:00
}:
/* M a i n t a i n e r n o t e s :
*
2015-04-07 03:34:27 -04:00
* T H I S I S A M I N I M A L B U I L D O F F F M P E G , d o n o t i n c l u d e d e p e n d e n c i e s u n l e s s
* a b u i l d t h a t d e p e n d s o n f f m p e g r e q u i r e s t h e m t o b e c o m p i l e d i n t o f f m p e g ,
* s e e ` f f m p e g - f u l l ' f o r a n f f m p e g b u i l d w i t h a l l f e a t u r e s i n c l u d e d .
2015-02-28 12:12:25 -05:00
*
2015-03-29 16:42:42 -04:00
* N e e d f i x e s t o s u p p o r t D a r w i n :
2015-04-07 03:34:27 -04:00
* l i b v p x p u l s e a u d i o
2015-02-28 12:12:25 -05:00
*
* K n o w n i s s u e s :
2015-04-07 03:34:27 -04:00
* 0 . 6 - f a i l s t o c o m p i l e ( u n r e s o l v e d ) ( s o f a r , o n l y d i s a b l i n g a n u m b e r o f
* f e a t u r e s w o r k s , b u t t h a t i s n o t a f e a s i b l e s o l u t i o n )
2015-02-28 12:12:25 -05:00
* 0 . 6 . 9 0 - m m x : c o m p i l e e r r o r s ( f i x : d i s a b l e f o r 0 . 6 . 9 0 - r c 0 )
* 1 . 1 - l i b s o x r : c o m p i l e e r r o r ( f i x : d i s a b l e f o r 1 . 1 )
2015-04-07 03:34:27 -04:00
* S u p p o r t w a s i n i t i a l l y a d d e d i n 1 . 1 b e f o r e s o x r a p i c h a n g e , f i x
* w o u l d p r o b a b l y b e t o a d d s o x r - 1 . 0
2015-02-28 12:12:25 -05:00
* A L L - C r o s s - c o m p i l i n g w i l l d i s a b l e f e a t u r e s n o t p r e s e n t o n h o s t O S
2015-04-07 03:34:27 -04:00
* ( e . g . d x v a 2 s u p p o r t [ D i r e c t X ] w i l l n o t b e e n a b l e d u n l e s s n a t i v e l y
* c o m p i l e d o n C y g w i n )
2015-02-28 12:12:25 -05:00
*
*/
let
2016-03-22 15:00:36 +01:00
inherit ( stdenv ) icCygwin isDarwin isFreeBSD isLinux isArm ;
2015-04-07 03:34:27 -04:00
inherit ( stdenv . lib ) optional optionals enableFeature ;
2015-02-28 12:12:25 -05:00
cmpVer = builtins . compareVersions ;
reqMin = requiredVersion : ( cmpVer requiredVersion branch != 1 ) ;
reqMatch = requiredVersion : ( cmpVer requiredVersion branch = = 0 ) ;
2015-04-07 03:34:27 -04:00
ifMinVer = minVer : flag : if reqMin minVer then flag else null ;
2015-02-28 12:12:25 -05:00
# Version specific fix
verFix = withoutFix : fixVer : withFix : if reqMatch fixVer then withFix else withoutFix ;
2016-03-22 15:00:36 +01: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 ;
2017-05-19 01:59:44 +03:00
vaapiSupport = reqMin " 0 . 6 " && ( ( isLinux || isFreeBSD ) && ! isArm ) ;
2015-02-28 12:12:25 -05:00
in
2015-04-07 03:34:27 -04:00
assert openglSupport -> mesa != null ;
2015-02-28 12:12:25 -05:00
stdenv . mkDerivation rec {
name = " f f m p e g - ${ version } " ;
inherit version ;
src = fetchurl {
url = " h t t p s : / / w w w . f f m p e g . o r g / r e l e a s e s / ${ name } . t a r . b z 2 " ;
inherit sha256 ;
} ;
2016-05-17 00:58:15 +02:00
postPatch = '' p a t c h S h e b a n g s . '' ;
inherit patches ;
2015-02-28 12:12:25 -05:00
2016-08-29 03:30:01 +03:00
outputs = [ " b i n " " d e v " " o u t " ]
2015-10-11 16:34:23 +02:00
++ optional ( reqMin " 1 . 0 " ) " d o c " ; # just dev-doc
setOutputFlags = false ; # doesn't accept all and stores configureFlags in libs!
2015-02-28 12:12:25 -05:00
configureFlags = [
2015-04-07 03:34:27 -04:00
# License
" - - e n a b l e - g p l "
" - - e n a b l e - v e r s i o n 3 "
# Build flags
" - - e n a b l e - s h a r e d "
" - - d i s a b l e - s t a t i c "
( ifMinVer " 0 . 6 " " - - e n a b l e - p i c " )
( enableFeature runtimeCpuDetectBuild " r u n t i m e - c p u d e t e c t " )
" - - e n a b l e - h a r d c o d e d - t a b l e s "
( if multithreadBuild then (
if stdenv . isCygwin then
2015-02-28 12:12:25 -05:00
" - - d i s a b l e - p t h r e a d s - - e n a b l e - w 3 2 t h r e a d s "
else # Use POSIX threads by default
" - - e n a b l e - p t h r e a d s - - d i s a b l e - w 3 2 t h r e a d s " )
else
" - - d i s a b l e - p t h r e a d s - - d i s a b l e - w 3 2 t h r e a d s " )
2015-04-07 03:34:27 -04:00
( ifMinVer " 0 . 9 " " - - d i s a b l e - o s 2 t h r e a d s " ) # We don't support OS/2
2015-05-28 07:39:10 -04:00
" - - e n a b l e - n e t w o r k "
2015-04-07 03:34:27 -04:00
( ifMinVer " 2 . 4 " " - - e n a b l e - p i x e l u t i l s " )
# Executables
" - - e n a b l e - f f m p e g "
" - - d i s a b l e - f f p l a y "
( ifMinVer " 0 . 6 " " - - e n a b l e - f f p r o b e " )
" - - d i s a b l e - f f s e r v e r "
# Libraries
( ifMinVer " 0 . 6 " " - - e n a b l e - a v c o d e c " )
( ifMinVer " 0 . 6 " " - - e n a b l e - a v d e v i c e " )
" - - e n a b l e - a v f i l t e r "
( ifMinVer " 0 . 6 " " - - e n a b l e - a v f o r m a t " )
( ifMinVer " 1 . 0 " " - - e n a b l e - a v r e s a m p l e " )
( ifMinVer " 1 . 1 " " - - e n a b l e - a v u t i l " )
" - - e n a b l e - p o s t p r o c "
( ifMinVer " 0 . 9 " " - - e n a b l e - s w r e s a m p l e " )
" - - e n a b l e - s w s c a l e "
# Docs
( ifMinVer " 0 . 6 " " - - d i s a b l e - d o c " )
# External Libraries
" - - e n a b l e - b z l i b "
2015-05-28 07:39:10 -04:00
" - - e n a b l e - g n u t l s "
2015-04-07 03:34:27 -04:00
( ifMinVer " 1 . 0 " " - - e n a b l e - f o n t c o n f i g " )
( ifMinVer " 0 . 7 " " - - e n a b l e - l i b f r e e t y p e " )
" - - e n a b l e - l i b m p 3 l a m e "
( ifMinVer " 1 . 2 " " - - e n a b l e - i c o n v " )
" - - e n a b l e - l i b t h e o r a "
2017-05-19 01:59:44 +03:00
( ifMinVer " 0 . 6 " ( enableFeature vaapiSupport " v a a p i " ) )
2015-04-07 03:34:27 -04:00
" - - e n a b l e - v d p a u "
" - - e n a b l e - l i b v o r b i s "
2016-03-22 15:00:36 +01:00
( disDarwinOrArmFix ( ifMinVer " 0 . 6 " " - - e n a b l e - l i b v p x " ) " 0 . 6 " " - - d i s a b l e - l i b v p x " )
2015-04-07 03:34:27 -04:00
( ifMinVer " 2 . 4 " " - - e n a b l e - l z m a " )
( ifMinVer " 2 . 2 " ( enableFeature openglSupport " o p e n g l " ) )
2016-03-22 15:00:36 +01:00
( disDarwinOrArmFix ( ifMinVer " 0 . 9 " " - - e n a b l e - l i b p u l s e " ) " 0 . 9 " " - - d i s a b l e - l i b p u l s e " )
2017-04-22 18:46:23 -07:00
( ifMinVer " 2 . 5 " ( if sdlSupport && reqMin " 3 . 2 " then " - - e n a b l e - s d l 2 " else if sdlSupport then " - - e n a b l e - s d l " else null ) ) # autodetected before 2.5, SDL1 support removed in 3.2 for SDL2
2015-04-07 03:34:27 -04:00
( ifMinVer " 1 . 2 " " - - e n a b l e - l i b s o x r " )
" - - e n a b l e - l i b x 2 6 4 "
" - - e n a b l e - l i b x v i d "
" - - e n a b l e - z l i b "
2016-03-26 17:01:22 +03:00
( ifMinVer " 2 . 8 " " - - e n a b l e - l i b o p u s " )
2016-04-09 14:00:30 +03:00
( ifMinVer " 2 . 8 " " - - e n a b l e - l i b x 2 6 5 " )
2015-04-07 03:34:27 -04:00
# Developer flags
( enableFeature debugDeveloper " d e b u g " )
( enableFeature optimizationsDeveloper " o p t i m i z a t i o n s " )
( enableFeature extraWarningsDeveloper " e x t r a - w a r n i n g s " )
" - - d i s a b l e - s t r i p p i n g "
2015-02-28 12:12:25 -05:00
# Disable mmx support for 0.6.90
2015-04-07 03:34:27 -04:00
( verFix null " 0 . 6 . 9 0 " " - - d i s a b l e - m m x " )
2015-05-11 14:37:53 -07:00
] ++ optional stdenv . cc . isClang " - - c c = c l a n g " ;
2015-02-28 12:12:25 -05:00
nativeBuildInputs = [ perl pkgconfig texinfo yasm ] ;
buildInputs = [
2015-05-28 07:39:10 -04:00
bzip2 fontconfig freetype gnutls libiconv lame libass libogg libtheora
2016-12-13 22:37:06 +01:00
libvdpau libvorbis lzma soxr x264 x265 xvidcore zlib libopus
2015-04-07 03:34:27 -04:00
] ++ optional openglSupport mesa
2016-03-22 15:00:36 +01:00
++ optionals ( ! isDarwin && ! isArm ) [ libvpx libpulseaudio ] # Need to be fixed on Darwin and ARM
++ optional ( ( isLinux || isFreeBSD ) && ! isArm ) libva
2015-10-29 15:15:42 +02:00
++ optional isLinux alsaLib
2016-08-07 12:25:01 +02:00
++ optionals isDarwin darwinFrameworks
2016-03-22 15:00:36 +01:00
++ optional vdpauSupport libvdpau
2017-04-22 18:46:23 -07:00
++ optional sdlSupport ( if reqMin " 3 . 2 " then SDL2 else SDL ) ;
2016-03-22 15:00:36 +01:00
2015-02-28 12:12:25 -05:00
enableParallelBuilding = true ;
2015-10-11 16:34:23 +02:00
postFixup = ''
2015-12-02 10:03:23 +01:00
m o v e T o O u t p u t b i n " $b i n "
m o v e T o O u t p u t s h a r e / f f m p e g / e x a m p l e s " $d o c "
2015-10-11 16:34:23 +02:00
'' ;
2015-02-28 12:12:25 -05:00
/* C r o s s - c o m p i l a t i o n i s u n t e s t e d , c o n s i d e r t h i s a n o u t l i n e , m o r e w o r k
n e e d s t o b e d o n e t o p o r t i o n s o f t h e b u i l d t o g e t i t t o w o r k c o r r e c t l y */
crossAttrs = let
os = ''
i f [ " ${ stdenv . cross . config } " = " * c y g w i n * " ] ; t h e n
# P r o b a b l y s h o u l d l o o k f o r m i n g w t o o
e c h o " c y g w i n "
e l i f [ " ${ stdenv . cross . config } " = " * d a r w i n * " ] ; t h e n
e c h o " d a r w i n "
e l i f [ " ${ stdenv . cross . config } " = " * f r e e b s d * " ] ; t h e n
e c h o " f r e e b s d "
e l i f [ " ${ stdenv . cross . config } " = " * l i n u x * " ] ; t h e n
e c h o " l i n u x "
e l i f [ " ${ stdenv . cross . config } " = " * n e t b s d * " ] ; t h e n
e c h o " n e t b s d "
e l i f [ " ${ stdenv . cross . config } " = " * o p e n b s d * " ] ; t h e n
e c h o " o p e n b s d "
f i
'' ;
in {
2017-04-26 00:06:11 -04:00
configurePlatforms = [ ] ;
2015-02-28 12:12:25 -05:00
configureFlags = configureFlags ++ [
" - - c r o s s - p r e f i x = ${ stdenv . cross . config } - "
" - - e n a b l e - c r o s s - c o m p i l e "
" - - t a r g e t _ o s = ${ os } "
" - - a r c h = ${ stdenv . cross . arch } "
] ;
} ;
2016-04-09 14:00:39 +03:00
installFlags = [ " i n s t a l l - m a n " ] ;
2015-02-28 12:12:25 -05:00
passthru = {
2017-05-19 01:59:44 +03:00
inherit vaapiSupport vdpauSupport ;
2015-02-28 12:12:25 -05:00
} ;
2015-04-07 03:34:27 -04:00
meta = with stdenv . lib ; {
2015-02-28 12:12:25 -05:00
description = " A 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 " ;
homepage = http://www.ffmpeg.org/ ;
longDescription = ''
F F m p e g i s t h e l e a d i n g m u l t i m e d i a f r a m e w o r k , a b l e t o d e c o d e , e n c o d e , t r a n s c o d e ,
m u x , d e m u x , s t r e a m , f i l t e r a n d p l a y p r e t t y m u c h a n y t h i n g t h a t h u m a n s a n d m a c h i n e s
h a v e c r e a t e d . I t s u p p o r t s t h e m o s t o b s c u r e a n c i e n t f o r m a t s u p t o t h e c u t t i n g e d g e .
N o m a t t e r i f t h e y w e r e d e s i g n e d b y s o m e s t a n d a r d s c o m m i t t e e , t h e c o m m u n i t y o r
a c o r p o r a t i o n .
'' ;
2015-04-07 03:34:27 -04:00
license = licenses . gpl3 ;
2015-02-28 12:12:25 -05:00
platforms = platforms . all ;
maintainers = with maintainers ; [ codyopel fuuzetsu ] ;
inherit branch ;
} ;
}