]> git.sesse.net Git - mlt/blob - src/modules/avformat/configure
Fix aspect ratio if width or height are set after aspect property.
[mlt] / src / modules / avformat / configure
1 #!/bin/sh
2
3 # Determine whether to recommend/use the HEAD revision of FFmpeg (unreleased)
4 # or a specific revision based upon whether the last digit of our version
5 # is even or odd. An odd MLT version number always represents unreleased.
6 ffmpeg_ver="1.2"
7 libav_ver="0.8.7"
8 micro_version=$(echo $version | cut -d . -f 3)
9 odd_version=$(($micro_version % 2))
10 [ "$odd_version" -eq "1" ] && ffmpeg_ver="HEAD" && libav_ver="HEAD"
11
12 if [ "$help" = "1" ]
13 then
14         cat << EOF
15 FFmpeg/avformat options:
16
17   --avformat-shared=path  - Link against a shared installation of libavformat (default)
18   --avformat-static=path  - Link against a static build of libavformat
19   --avformat-ldextra=libs - Provide additional libs to link with
20   --avformat-suffix=suff  - Specify a custom suffix
21   --avformat-no-codecs    - Disable the producer and consumer to avoid the codecs
22   --avformat-no-filters   - Disable the filters to make a codecs+muxers-only plugin
23   --avformat-no-devices   - Disable support for libavdevice
24   --avformat-vdpau        - Enable support for NVIDIA VDPAU
25
26   NOTE: The recommended version of FFmpeg is $ffmpeg_ver or libav $libav_ver.
27
28 EOF
29
30 else
31         targetos=$(uname -s)
32         case $targetos in
33         Darwin)
34                 export LIBSUF=.dylib
35                 ;;
36         Linux|FreeBSD|NetBSD)
37                 export LIBSUF=.so
38                 ;;
39         *)
40                 ;;
41         esac
42                 
43         bits=$(uname -m)
44         case $bits in
45         x86_64)
46                 [ -d /usr/lib/lib64 ] && export LIBDIR=lib64 || export LIBDIR=lib
47                 ;;
48         *)
49                 export LIBDIR=lib
50                 ;;
51         esac
52
53         echo > config.mak
54
55         export static_ffmpeg=
56         export shared_ffmpeg=
57         export extra_libs=
58         export avformat_suffix=
59         export codecs=true
60         export filters=true
61         export devices=true
62         export vdpau=false
63         pkg-config x11 > /dev/null 2>&1
64         export x11=$?
65
66         for i in "$@"
67         do
68                 case $i in
69                         --avformat-static=* )   static_ffmpeg="${i#--avformat-static=}" ;;
70                         --avformat-shared=* )   shared_ffmpeg="${i#--avformat-shared=}" ;;
71                         --avformat-ldextra=* )  extra_libs="${i#--avformat-ldextra=}" ;;
72                         --avformat-suffix=* )   avformat_suffix="${i#--avformat-suffix=}" ;;
73                         --avformat-no-codecs )  codecs=false ;;
74                         --avformat-no-filters ) filters=false ;;
75                         --avformat-no-devices ) devices=false ;;
76                         --avformat-no-vdpau )   vdpau=false ;;
77                         --avformat-vdpau )      vdpau=true ;;
78                 esac
79         done
80
81         : ${shared_ffmpeg:=$(pkg-config --variable=prefix libavformat${avformat_suffix})}
82
83         if [ "$static_ffmpeg" != "" ]
84         then 
85                 if [ -d "$static_ffmpeg" ]
86                 then
87                         echo "CFLAGS+=-DAVDATADIR=\\\"${static_ffmpeg}/ffpresets/\\\"" >> config.mak
88                         echo "CFLAGS+=-I$static_ffmpeg" >> config.mak
89                         echo "LDFLAGS+=-L$static_ffmpeg/libavformat -L$static_ffmpeg/libavcodec -L$static_ffmpeg/libavutil" >> config.mak
90                         echo "LDFLAGS+=-L$static_ffmpeg/libswscale" >> config.mak
91                         [ $targetos = "Darwin" ] &&
92                                 echo "LDFLAGS+=-single_module" >> config.mak
93                         if [ "$devices" = "true" ]
94                         then
95                                 echo "LDFLAGS+=-L$static_ffmpeg/libavdevice" >> config.mak
96                         fi
97                         echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
98                         extra_libs="$extra_libs -lm -lz -lbz2"
99                         
100                         if [ "$vdpau" = "true" ]
101                         then
102                                 printf "#include <libavcodec/vdpau.h>\n int main(){ VdpBitstreamBuffer test; test.struct_version; return 0;}" | $CC -I"$static_ffmpeg" $CFLAGS -c -x c -  >/dev/null 2>&1
103                                 [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
104                         fi
105                 else
106                         echo "avformat: Invalid path specified: $static_ffmpeg"
107                         touch ../disable-avformat
108                         echo 0
109                 fi
110         elif [ "$shared_ffmpeg" != "" ]
111         then
112                 if ! $(pkg-config libswscale${avformat_suffix}); then
113                         echo "- libswscale not found: disabling"
114                         touch ../disable-avformat
115                         exit 0
116                 fi
117                 echo "PREFIX=$shared_ffmpeg" >> config.mak
118                 case $targetos in
119                         MINGW32_NT-*)
120                                 echo "CFLAGS+=-DAVDATADIR=\\\"share/ffmpeg/\\\"" >> config.mak
121                         ;;
122                         *)
123                                 echo "CFLAGS+=-DAVDATADIR=\\\"${shared_ffmpeg}/share/ffmpeg${avformat_suffix}/\\\"" >> config.mak
124                         ;;
125                 esac
126                 echo "CFLAGS+=$(pkg-config --cflags libavformat${avformat_suffix})" >> config.mak
127                 echo "LDFLAGS+=$(pkg-config --libs-only-L libavformat${avformat_suffix})" >> config.mak
128                 echo "CFLAGS+=$(pkg-config --cflags libswscale${avformat_suffix})" >> config.mak
129                 echo "LDFLAGS+=$(pkg-config --libs-only-L libswscale${avformat_suffix})" >> config.mak
130                 if [ "$devices" = "true" ]
131                 then
132                         if ! $(pkg-config libavdevice${avformat_suffix}); then
133                                 echo "- libavdevice not found: disabling"
134                                 touch ../disable-avformat
135                                 exit 0
136                         fi
137                         echo "CFLAGS+=$(pkg-config --cflags libavdevice${avformat_suffix})" >> config.mak
138                         echo "LDFLAGS+=$(pkg-config --libs-only-L libavdevice${avformat_suffix})" >> config.mak
139                 fi
140                 
141                 if [ "$vdpau" = "true" ]
142                 then
143                         printf "#include <libavcodec/vdpau.h>\n int main(){ VdpBitstreamBuffer test; test.struct_version; return 0;}" | $CC $(pkg-config --cflags libavformat${avformat_suffix}) -I"$shared_ffmpeg/include" $CFLAGS -c -x c -  >/dev/null 2>&1
144                         [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
145                 fi
146         else
147                 echo "- libavformat not found: disabling"
148                 touch ../disable-avformat
149                 exit 0
150         fi
151
152         echo "EXTRA_LIBS=$extra_libs" >> config.mak
153         echo "AVFORMAT_SUFFIX=$avformat_suffix" >> config.mak
154         [ "$codecs" = "true" ] && echo "CODECS=1" >> config.mak
155         [ "$filters" = "true" ] && echo "FILTERS=1" >> config.mak
156         [ "$devices" = "true" ] && echo "DEVICES=1" >> config.mak
157         exit 0
158
159 fi