2020-01-04 08:26:03 +00:00
{ stdenv , buildPackages , fetchurl , pkgconfig , addOpenGLRunpath , perl , texinfo , yasm
2015-05-28 12:39:10 +01:00
, alsaLib , bzip2 , fontconfig , freetype , gnutls , libiconv , lame , libass , libogg
2018-10-29 12:23:42 +00:00
, libssh , libtheora , libva , libdrm , libvorbis , libvpx , lzma , libpulseaudio , soxr
2019-08-10 13:31:47 +01:00
, x264 , x265 , xvidcore , zlib , libopus , speex , nv-codec-headers , dav1d
2019-11-10 16:44:34 +00:00
, openglSupport ? false , libGLU ? null , libGL ? null
2019-11-06 21:22:59 +00:00
, libmfxSupport ? false , intel-media-sdk ? null
, libaomSupport ? false , libaom ? null
2015-04-07 08:34:27 +01:00
# Build options
, runtimeCpuDetectBuild ? true # Detect CPU capabilities at runtime
2015-02-28 17:12:25 +00:00
, multithreadBuild ? true # Multithreading via pthreads/win32 threads
treewide: isArm -> isAarch32
Following legacy packing conventions, `isArm` was defined just for
32-bit ARM instruction set. This is confusing to non packagers though,
because Aarch64 is an ARM instruction set.
The official ARM overview for ARMv8[1] is surprisingly not confusing,
given the overall state of affairs for ARM naming conventions, and
offers us a solution. It divides the nomenclature into three levels:
```
ISA: ARMv8 {-A, -R, -M}
/ \
Mode: Aarch32 Aarch64
| / \
Encoding: A64 A32 T32
```
At the top is the overall v8 instruction set archicture. Second are the
two modes, defined by bitwidth but differing in other semantics too, and
buttom are the encodings, (hopefully?) isomorphic if they encode the
same mode.
The 32 bit encodings are mostly backwards compatible with previous
non-Thumb and Thumb encodings, and if so we can pun the mode names to
instead mean "sets of compatable or isomorphic encodings", and then
voilà we have nice names for 32-bit and 64-bit arm instruction sets
which do not use the word ARM so as to not confused either laymen or
experienced ARM packages.
[1]: https://developer.arm.com/products/architecture/a-profile
2018-03-20 02:41:06 +00:00
, sdlSupport ? ! stdenv . isAarch32 , SDL ? null , SDL2 ? null
, vdpauSupport ? ! stdenv . isAarch32 , 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
2016-08-07 11:25:01 +01:00
, Cocoa , darwinFrameworks ? [ Cocoa ]
2015-04-07 08:34:27 +01:00
# Inherit generics
2016-05-16 23:58:15 +01:00
, branch , sha256 , version , patches ? [ ] , . . .
2015-02-28 17:12:25 +00:00
} :
/* M a i n t a i n e r n o t e s :
*
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 :
2018-07-16 05:15:42 +01:00
* 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 . 9 0 - 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
2018-07-20 20:36:12 +01:00
inherit ( stdenv ) isDarwin isFreeBSD isLinux isAarch32 ;
2019-11-11 19:53:15 +00:00
inherit ( stdenv . lib ) optional optionals optionalString enableFeature filter ;
2015-04-07 08:34:27 +01:00
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
treewide: isArm -> isAarch32
Following legacy packing conventions, `isArm` was defined just for
32-bit ARM instruction set. This is confusing to non packagers though,
because Aarch64 is an ARM instruction set.
The official ARM overview for ARMv8[1] is surprisingly not confusing,
given the overall state of affairs for ARM naming conventions, and
offers us a solution. It divides the nomenclature into three levels:
```
ISA: ARMv8 {-A, -R, -M}
/ \
Mode: Aarch32 Aarch64
| / \
Encoding: A64 A32 T32
```
At the top is the overall v8 instruction set archicture. Second are the
two modes, defined by bitwidth but differing in other semantics too, and
buttom are the encodings, (hopefully?) isomorphic if they encode the
same mode.
The 32 bit encodings are mostly backwards compatible with previous
non-Thumb and Thumb encodings, and if so we can pun the mode names to
instead mean "sets of compatable or isomorphic encodings", and then
voilà we have nice names for 32-bit and 64-bit arm instruction sets
which do not use the word ARM so as to not confused either laymen or
experienced ARM packages.
[1]: https://developer.arm.com/products/architecture/a-profile
2018-03-20 02:41:06 +00:00
disDarwinOrArmFix = origArg : minVer : fixArg : if ( ( isDarwin || isAarch32 ) && reqMin minVer ) then fixArg else origArg ;
2017-05-18 23:59:44 +01:00
treewide: isArm -> isAarch32
Following legacy packing conventions, `isArm` was defined just for
32-bit ARM instruction set. This is confusing to non packagers though,
because Aarch64 is an ARM instruction set.
The official ARM overview for ARMv8[1] is surprisingly not confusing,
given the overall state of affairs for ARM naming conventions, and
offers us a solution. It divides the nomenclature into three levels:
```
ISA: ARMv8 {-A, -R, -M}
/ \
Mode: Aarch32 Aarch64
| / \
Encoding: A64 A32 T32
```
At the top is the overall v8 instruction set archicture. Second are the
two modes, defined by bitwidth but differing in other semantics too, and
buttom are the encodings, (hopefully?) isomorphic if they encode the
same mode.
The 32 bit encodings are mostly backwards compatible with previous
non-Thumb and Thumb encodings, and if so we can pun the mode names to
instead mean "sets of compatable or isomorphic encodings", and then
voilà we have nice names for 32-bit and 64-bit arm instruction sets
which do not use the word ARM so as to not confused either laymen or
experienced ARM packages.
[1]: https://developer.arm.com/products/architecture/a-profile
2018-03-20 02:41:06 +00:00
vaapiSupport = reqMin " 0 . 6 " && ( ( isLinux || isFreeBSD ) && ! isAarch32 ) ;
2018-07-16 05:15:42 +01:00
vpxSupport = reqMin " 0 . 6 " && ! isAarch32 ;
2015-02-28 17:12:25 +00:00
in
2019-11-10 16:44:34 +00:00
assert openglSupport -> libGL != null && libGLU != null ;
2019-11-06 21:22:59 +00:00
assert libmfxSupport -> intel-media-sdk != null ;
assert libaomSupport -> libaom != null ;
2015-02-28 17:12:25 +00:00
stdenv . mkDerivation rec {
2019-08-15 13:41:18 +01:00
pname = " f f m p e g " ;
2015-02-28 17:12:25 +00:00
inherit version ;
src = fetchurl {
2019-08-15 13:41:18 +01:00
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 / ${ pname } - ${ version } . t a r . b z 2 " ;
2015-02-28 17:12:25 +00:00
inherit sha256 ;
} ;
2016-05-16 23:58:15 +01:00
postPatch = '' p a t c h S h e b a n g s . '' ;
inherit patches ;
2015-02-28 17:12:25 +00:00
2017-07-11 09:53:28 +01:00
outputs = [ " b i n " " d e v " " o u t " " m a n " ]
2015-10-11 15:34:23 +01:00
++ optional ( reqMin " 1 . 0 " ) " d o c " ; # just dev-doc
setOutputFlags = false ; # doesn't accept all and stores configureFlags in libs!
2018-05-10 06:38:51 +01:00
configurePlatforms = [ ] ;
2019-11-11 19:53:15 +00:00
configureFlags = filter ( v : v != null ) ( [
2018-08-20 19:43:41 +01:00
" - - a r c h = ${ stdenv . hostPlatform . parsed . cpu . name } "
" - - t a r g e t _ o s = ${ stdenv . hostPlatform . parsed . kernel . name } "
2015-04-07 08:34:27 +01: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 "
( 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 "
2019-11-11 19:53:15 +00:00
] ++
2015-04-07 08:34:27 +01:00
( if multithreadBuild then (
if stdenv . isCygwin then
2019-11-11 19:53:15 +00: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 " ]
2015-02-28 17:12:25 +00:00
else # Use POSIX threads by default
2019-11-11 19:53:15 +00:00
[ " - - 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 " ] )
2015-02-28 17:12:25 +00:00
else
2019-11-11 19:53:15 +00:00
[ " - - 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 08:34:27 +01: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 12:39:10 +01:00
" - - e n a b l e - n e t w o r k "
2015-04-07 08:34:27 +01: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 " )
2018-05-10 15:44:40 +01:00
( if reqMin " 4 " then null else " - - d i s a b l e - f f s e r v e r " )
2015-04-07 08:34:27 +01:00
# 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 12:39:10 +01:00
" - - e n a b l e - g n u t l s "
2015-04-07 08:34:27 +01: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 "
2018-10-02 10:16:54 +01:00
( ifMinVer " 2 . 1 " " - - e n a b l e - l i b s s h " )
2017-05-18 23:59:44 +01:00
( ifMinVer " 0 . 6 " ( enableFeature vaapiSupport " v a a p i " ) )
2018-10-29 12:23:42 +00:00
( ifMinVer " 3 . 4 " ( enableFeature vaapiSupport " l i b d r m " ) )
2020-02-08 07:00:37 +00:00
( enableFeature vdpauSupport " v d p a u " )
2015-04-07 08:34:27 +01:00
" - - e n a b l e - l i b v o r b i s "
2018-07-16 05:15:42 +01:00
( ifMinVer " 0 . 6 " ( enableFeature vpxSupport " l i b v p x " ) )
2015-04-07 08:34:27 +01: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 " ) )
2019-11-06 21:22:59 +00:00
( ifMinVer " 4 . 2 " ( enableFeature libmfxSupport " l i b m f x " ) )
( ifMinVer " 4 . 2 " ( enableFeature libaomSupport " l i b a o m " ) )
2016-03-22 14:00:36 +00: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-23 02:46:23 +01: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 08:34:27 +01: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 14:01:22 +00:00
( ifMinVer " 2 . 8 " " - - e n a b l e - l i b o p u s " )
2018-09-05 16:17:01 +01:00
" - - e n a b l e - l i b s p e e x "
2016-04-09 12:00:30 +01:00
( ifMinVer " 2 . 8 " " - - e n a b l e - l i b x 2 6 5 " )
2019-08-10 13:31:47 +01:00
( ifMinVer " 4 . 2 " ( enableFeature ( dav1d != null ) " l i b d a v 1 d " ) )
2015-04-07 08:34:27 +01: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 17:12:25 +00:00
# Disable mmx support for 0.6.90
2015-04-07 08:34:27 +01:00
( verFix null " 0 . 6 . 9 0 " " - - d i s a b l e - m m x " )
2018-07-15 05:15:24 +01:00
] ++ optionals ( stdenv . hostPlatform != stdenv . buildPlatform ) [
2018-05-10 06:38:51 +01:00
" - - c r o s s - p r e f i x = ${ stdenv . cc . targetPrefix } "
" - - e n a b l e - c r o s s - c o m p i l e "
2020-01-04 08:26:03 +00:00
" - - p k g - c o n f i g = p k g - c o n f i g " # Override ffmpeg's ./configure assumption that pkg-config is prefixed by the architecture. (e.g. aarch64-unknown-linux-gnu-pkg-config)
2019-11-11 19:53:15 +00:00
] ++ optional stdenv . cc . isClang " - - c c = c l a n g " ) ;
2015-02-28 17:12:25 +00:00
2020-01-04 08:26:03 +00:00
depsBuildBuild = [ buildPackages . stdenv . cc ] ;
2019-08-30 20:54:08 +01:00
nativeBuildInputs = [ addOpenGLRunpath perl pkgconfig texinfo yasm ] ;
2015-02-28 17:12:25 +00:00
buildInputs = [
2018-09-05 16:17:01 +01:00
bzip2 fontconfig freetype gnutls libiconv lame libass libogg libssh libtheora
2020-02-08 07:00:37 +00:00
libvorbis lzma soxr x264 x265 xvidcore zlib libopus speex nv-codec-headers
2019-11-10 16:44:34 +00:00
] ++ optionals openglSupport [ libGL libGLU ]
2019-11-06 21:22:59 +00:00
++ optional libmfxSupport intel-media-sdk
++ optional vpxSupport libaom
2018-07-16 05:15:42 +01:00
++ optional vpxSupport libvpx
++ optionals ( ! isDarwin && ! isAarch32 ) [ libpulseaudio ] # Need to be fixed on Darwin and ARM
treewide: isArm -> isAarch32
Following legacy packing conventions, `isArm` was defined just for
32-bit ARM instruction set. This is confusing to non packagers though,
because Aarch64 is an ARM instruction set.
The official ARM overview for ARMv8[1] is surprisingly not confusing,
given the overall state of affairs for ARM naming conventions, and
offers us a solution. It divides the nomenclature into three levels:
```
ISA: ARMv8 {-A, -R, -M}
/ \
Mode: Aarch32 Aarch64
| / \
Encoding: A64 A32 T32
```
At the top is the overall v8 instruction set archicture. Second are the
two modes, defined by bitwidth but differing in other semantics too, and
buttom are the encodings, (hopefully?) isomorphic if they encode the
same mode.
The 32 bit encodings are mostly backwards compatible with previous
non-Thumb and Thumb encodings, and if so we can pun the mode names to
instead mean "sets of compatable or isomorphic encodings", and then
voilà we have nice names for 32-bit and 64-bit arm instruction sets
which do not use the word ARM so as to not confused either laymen or
experienced ARM packages.
[1]: https://developer.arm.com/products/architecture/a-profile
2018-03-20 02:41:06 +00:00
++ optional ( ( isLinux || isFreeBSD ) && ! isAarch32 ) libva
2018-10-29 12:23:42 +00:00
++ optional ( ( isLinux || isFreeBSD ) && ! isAarch32 ) libdrm
2015-10-29 13:15:42 +00:00
++ optional isLinux alsaLib
2016-08-07 11:25:01 +01:00
++ optionals isDarwin darwinFrameworks
2016-03-22 14:00:36 +00:00
++ optional vdpauSupport libvdpau
2019-08-10 13:31:47 +01:00
++ optional sdlSupport ( if reqMin " 3 . 2 " then SDL2 else SDL )
++ optional ( reqMin " 4 . 2 " ) dav1d ;
2016-03-22 14:00:36 +00:00
2015-02-28 17:12:25 +00:00
enableParallelBuilding = true ;
2018-04-25 04:20:18 +01:00
doCheck = false ; # fails
2018-07-15 06:41:45 +01:00
# ffmpeg 3+ generates pkg-config (.pc) files that don't have the
# form automatically handled by the multiple-outputs hooks.
2015-10-11 15:34:23 +01:00
postFixup = ''
2015-12-02 09:03:23 +00:00
moveToOutput bin " $ b i n "
moveToOutput share/ffmpeg/examples " $ d o c "
2018-07-15 06:41:45 +01:00
for pc in '' ${ ! outputDev } / l i b / p k g c o n f i g / * . p c ; d o
substituteInPlace $ pc \
- - replace " i n c l u d e d i r = $ o u t " " i n c l u d e d i r = ' ' ${ ! outputInclude } "
done
2019-08-30 20:54:08 +01:00
'' + o p t i o n a l S t r i n g s t d e n v . i s L i n u x ''
# Set RUNPATH so that libnvcuvid in /run/opengl-driver(-32)/lib can be found.
# See the explanation in addOpenGLRunpath.
addOpenGLRunpath $ out/lib/libavcodec.so *
2015-10-11 15:34:23 +01:00
'' ;
2016-04-09 12:00:39 +01:00
installFlags = [ " i n s t a l l - m a n " ] ;
2015-02-28 17:12:25 +00:00
passthru = {
2017-05-18 23:59:44 +01:00
inherit vaapiSupport 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 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 " ;
2020-04-01 02:11:51 +01:00
homepage = " h t t p : / / w w w . f f m p e g . o r g / " ;
2015-02-28 17:12:25 +00:00
longDescription = ''
2018-08-08 19:24:19 +01:00
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-02-28 17:12:25 +00:00
'' ;
2015-04-07 08:34:27 +01:00
license = licenses . gpl3 ;
2015-02-28 17:12:25 +00:00
platforms = platforms . all ;
2019-12-05 07:29:48 +00:00
maintainers = with maintainers ; [ codyopel ] ;
2015-02-28 17:12:25 +00:00
inherit branch ;
} ;
}