]> git.sesse.net Git - ffmpeg/blob - tests/regression.sh
be2cf5a8e956a9c9b273fe126503a8a9084a19a7
[ffmpeg] / tests / regression.sh
1 #!/bin/sh
2 #
3 # automatic regression test for ffmpeg
4 #
5 #
6 #set -x
7 set -e
8
9 datadir="./data"
10
11 logfile="$datadir/ffmpeg.regression"
12
13 # tests to do
14 if [ "$1" = "mpeg4" ] ; then
15     do_mpeg4=y
16 elif [ "$1" = "mpeg" ] ; then
17     do_mpeg=y
18 elif [ "$1" = "libavtest" ] ; then
19     do_libav=y
20     logfile="$datadir/libav.regression"
21 else
22     do_mpeg=y
23     do_msmpeg4=y
24     do_h263=y
25     do_mpeg4=y
26     do_mjpeg=y
27     do_rv10=y
28     do_mp2=y
29     do_ac3=y
30 fi
31
32
33 # various files
34 ffmpeg="../ffmpeg"
35 outfile="$datadir/a-"
36 reffile="$2"
37 benchfile="$datadir/ffmpeg.bench"
38 raw_src="vsynth1/%d.pgm"
39 raw_dst="$datadir/out.yuv"
40 pcm_src="asynth1.sw"
41 pcm_dst="$datadir/out.wav"
42
43 # create the data directory if it does not exists
44 mkdir -p $datadir
45
46 do_ffmpeg()
47 {
48     f="$1"
49     shift
50     echo $ffmpeg -bitexact -dct_algo 1 $*
51     $ffmpeg -bitexact -dct_algo 1 -benchmark $* > $datadir/bench.tmp
52     md5sum -b $f >> $logfile
53     expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
54     echo `cat $datadir/bench2.tmp` $f >> $benchfile
55 }
56
57 do_ffmpeg_crc()
58 {
59     f="$1"
60     shift
61     echo $ffmpeg -y -bitexact -dct_algo 1 $* -f crc $datadir/ffmpeg.crc
62     $ffmpeg -y -bitexact -dct_algo 1 $* -f crc $datadir/ffmpeg.crc
63     echo -n "$f " >> $logfile
64     cat $datadir/ffmpeg.crc >> $logfile
65 }
66
67 echo "ffmpeg regression test" > $logfile
68 echo "ffmpeg benchmarks" > $benchfile
69
70 ###################################
71 if [ -n "$do_mpeg" ] ; then
72 # mpeg1 encoding
73 file=${outfile}mpeg1.mpg
74 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpeg1video $file 
75
76 # mpeg1 decoding
77 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
78
79 # mpeg2 decoding
80 #do_ffmpeg /tmp/out-mpeg2.yuv -y -f mpegvideo -i a.vob \
81 #          -f rawvideo /tmp/out-mpeg2.yuv
82 fi
83
84 ###################################
85 if [ -n "$do_msmpeg4" ] ; then
86 # msmpeg4 encoding
87 file=${outfile}msmpeg4.avi
88 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
89
90 # msmpeg4 decoding
91 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
92 fi
93
94 ###################################
95 if [ -n "$do_h263" ] ; then
96 # h263 encoding
97 file=${outfile}h263.avi
98 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
99
100 # h263p decoding
101 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
102 fi
103
104 ###################################
105 if [ -n "$do_mpeg4" ] ; then
106 # mpeg4
107 file=${outfile}odivx.avi
108 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
109
110 # mpeg4 decoding
111 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
112 fi
113
114 ###################################
115 if [ -n "$do_mjpeg" ] ; then
116 # mjpeg
117 file=${outfile}mjpeg.avi
118 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
119
120 # mjpeg decoding
121 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
122 fi
123
124 ###################################
125 if [ -n "$do_rv10" ] ; then
126 # rv10 encoding
127 file=${outfile}rv10.rm
128 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file 
129
130 # rv10 decoding
131 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
132 fi
133
134 ###################################
135 if [ -n "$do_mp2" ] ; then
136 # mp2 encoding
137 file=${outfile}mp2.mp2
138 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file 
139
140 # mp2 decoding
141 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst 
142 fi
143
144 ###################################
145 if [ -n "$do_ac3" ] ; then
146 # ac3 encoding
147 file=${outfile}ac3.rm
148 do_ffmpeg $file -y -ab 128 -ac 2 -f s16le  -i $pcm_src -vn $file 
149
150 # ac3 decoding
151 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst 
152 fi
153
154 ###################################
155 # libav testing
156 ###################################
157
158 if [ -n "$do_libav" ] ; then
159
160 # avi
161 file=${outfile}libav.avi
162 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
163 do_ffmpeg_crc $file -i $file
164
165 # asf
166 file=${outfile}libav.asf
167 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
168 do_ffmpeg_crc $file -i $file
169
170 # rm
171 file=${outfile}libav.rm
172 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
173 # broken
174 #do_ffmpeg_crc $file -i $file
175
176 # mpegps
177 file=${outfile}libav.mpg
178 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
179 do_ffmpeg_crc $file -i $file
180
181 # swf (decode audio only)
182 file=${outfile}libav.swf
183 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
184 do_ffmpeg_crc $file -i $file
185
186 # ffm
187 file=${outfile}libav.ffm
188 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
189 do_ffmpeg_crc $file -i $file
190
191 # XXX: need mov and mpegts tests (add bitstreams or add output capability in ffmpeg)
192
193 ####################
194 # streamed images
195 # mjpeg
196 file=${outfile}libav.mjpeg
197 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
198 do_ffmpeg_crc $file -i $file
199
200 # pgmpipe
201 file=${outfile}libav.pgmpipe
202 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f pgmpipe $file
203 do_ffmpeg_crc $file -f pgmpipe -i $file
204
205 # ppmpipe
206 file=${outfile}libav.ppmpipe
207 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f ppmpipe $file
208 do_ffmpeg_crc $file -f ppmpipe -i $file
209
210 # gif
211 file=${outfile}libav.gif
212 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f ppmpipe $file
213 #do_ffmpeg_crc $file -f ppmpipe -i $file
214
215 ####################
216 # image formats
217 # pgm (we do not do md5 on image files yet)
218 file=${outfile}libav%d.pgm
219 $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
220 do_ffmpeg_crc $file -i $file
221
222 # ppm (we do not do md5 on image files yet)
223 file=${outfile}libav%d.ppm
224 $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
225 do_ffmpeg_crc $file -i $file
226
227 # jpeg (we do not do md5 on image files yet)
228 file=${outfile}libav%d.jpg
229 $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
230 do_ffmpeg_crc $file -i $file
231
232 ####################
233 # audio only
234
235 # wav
236 file=${outfile}libav.wav
237 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
238 do_ffmpeg_crc $file -i $file
239
240 # alaw
241 file=${outfile}libav.al
242 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
243 do_ffmpeg_crc $file -i $file
244
245 # mulaw
246 file=${outfile}libav.ul
247 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
248 do_ffmpeg_crc $file -i $file
249
250 # au
251 file=${outfile}libav.au
252 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
253 do_ffmpeg_crc $file -i $file
254
255 fi
256
257
258
259 if diff -u $logfile $reffile ; then
260     echo 
261     echo Regression test succeeded.
262     exit 0
263 else
264     echo 
265     echo Regression test: Error.
266     exit 1
267 fi