]> git.sesse.net Git - ffmpeg/blob - tests/regression.sh
No more HTML in Changelog
[ffmpeg] / tests / regression.sh
1 #!/bin/sh
2 #
3 # automatic regression test for ffmpeg
4 #
5 #
6 #set -x
7 # Even in the 21st century some diffs are not supporting -u.
8 diff -u $0 $0 > /dev/null 2>&1
9 if [ $? -eq 0 ]; then
10   diff_cmd="diff -u"
11 else
12   diff_cmd="diff"
13 fi
14
15 set -e
16
17 datadir="./data"
18
19 logfile="$datadir/ffmpeg.regression"
20
21 # tests to do
22 if [ "$1" = "mpeg4" ] ; then
23     do_mpeg4=y
24 elif [ "$1" = "mpeg" ] ; then
25     do_mpeg=y
26 elif [ "$1" = "ac3" ] ; then
27     do_ac3=y
28 elif [ "$1" = "libavtest" ] ; then
29     do_libav=y
30     logfile="$datadir/libav.regression"
31 else
32     do_mpeg=y
33     do_msmpeg4v2=y
34     do_msmpeg4=y
35     do_wmv1=y
36     do_wmv2=y
37     do_h263=y
38     do_h263p=y
39     do_mpeg4=y
40     do_huffyuv=y
41     do_mjpeg=y
42     do_rv10=y
43     do_mp2=y
44     do_ac3=y
45     do_rc=y
46     do_mpeg4adv=y
47     do_mpeg1b=y
48     do_asv1=y
49 fi
50
51
52 # various files
53 ffmpeg="../ffmpeg_g"
54 tiny_psnr="./tiny_psnr"
55 outfile="$datadir/a-"
56 reffile="$2"
57 benchfile="$datadir/ffmpeg.bench"
58 raw_src="$3/%d.pgm"
59 raw_dst="$datadir/out.yuv"
60 raw_ref="$datadir/ref.yuv"
61 pcm_src="asynth1.sw"
62 pcm_dst="$datadir/out.wav"
63
64 # create the data directory if it does not exists
65 mkdir -p $datadir
66
67 do_ffmpeg()
68 {
69     f="$1"
70     shift
71     echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $*
72     $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp 2> /tmp/ffmpeg$$
73     egrep -v "^(Stream|Press|Input|Output|frame|  Stream)" /tmp/ffmpeg$$ || true
74     rm -f /tmp/ffmpeg$$
75     md5sum -b $f >> $logfile
76     if [ $f = $raw_dst ] ; then
77         $tiny_psnr $f $raw_ref >> $logfile
78     fi
79     expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
80     echo `cat $datadir/bench2.tmp` $f >> $benchfile
81 }
82
83 do_ffmpeg_crc()
84 {
85     f="$1"
86     shift
87     echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
88     $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc > /tmp/ffmpeg$$ 2>&1
89     egrep -v "^(Stream|Press|Input|Output|frame|  Stream)" /tmp/ffmpeg$$ || true
90     rm -f /tmp/ffmpeg$$ 
91     echo "$f `cat $datadir/ffmpeg.crc`" >> $logfile
92 }
93
94 do_ffmpeg_nocheck()
95 {
96     f="$1"
97     shift
98     echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $*
99     $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp 2> /tmp/ffmpeg$$
100     egrep -v "^(Stream|Press|Input|Output|frame|  Stream)" /tmp/ffmpeg$$ || true
101     rm -f /tmp/ffmpeg$$
102     expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
103     echo `cat $datadir/bench2.tmp` $f >> $benchfile
104 }
105
106 echo "ffmpeg regression test" > $logfile
107 echo "ffmpeg benchmarks" > $benchfile
108
109 ###################################
110 # generate reference for quality check
111 do_ffmpeg_nocheck $raw_ref -y -f pgmyuv -i $raw_src -an -f rawvideo $raw_ref
112
113 ###################################
114 if [ -n "$do_mpeg" ] ; then
115 # mpeg1 encoding
116 file=${outfile}mpeg1.mpg
117 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpeg1video $file 
118
119 # mpeg1 decoding
120 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
121
122 # mpeg2 decoding
123 #do_ffmpeg /tmp/out-mpeg2.yuv -y -f mpegvideo -i a.vob \
124 #          -f rawvideo /tmp/out-mpeg2.yuv
125 fi
126
127 ###################################
128 if [ -n "$do_msmpeg4v2" ] ; then
129 # msmpeg4 encoding
130 file=${outfile}msmpeg4v2.avi
131 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4v2 $file
132
133 # msmpeg4v2 decoding
134 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
135 fi
136
137 ###################################
138 if [ -n "$do_msmpeg4" ] ; then
139 # msmpeg4 encoding
140 file=${outfile}msmpeg4.avi
141 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
142
143 # msmpeg4 decoding
144 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
145 fi
146
147 ###################################
148 if [ -n "$do_wmv1" ] ; then
149 # wmv1 encoding
150 file=${outfile}wmv1.avi
151 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv1 $file
152
153 # wmv1 decoding
154 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
155 fi
156
157 ###################################
158 if [ -n "$do_wmv2" ] ; then
159 # wmv2 encoding
160 file=${outfile}wmv2.avi
161 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv2 $file
162
163 # wmv2 decoding
164 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
165 fi
166
167 ###################################
168 if [ -n "$do_h263" ] ; then
169 # h263 encoding
170 file=${outfile}h263.avi
171 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
172
173 # h263 decoding
174 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
175 fi
176
177 ###################################
178 if [ -n "$do_h263p" ] ; then
179 # h263p encoding
180 file=${outfile}h263p.avi
181 do_ffmpeg $file -y -qscale 2 -umv -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263p -ps 300 $file
182
183 # h263p decoding
184 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
185 fi
186
187 ###################################
188 if [ -n "$do_mpeg4" ] ; then
189 # mpeg4
190 file=${outfile}odivx.avi
191 do_ffmpeg $file -y -4mv -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
192
193 # mpeg4 decoding
194 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
195 fi
196
197 ###################################
198 if [ -n "$do_huffyuv" ] ; then
199 # huffyuv
200 file=${outfile}huffyuv.avi
201 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec huffyuv -strict -1 $file
202
203 # huffyuv decoding
204 do_ffmpeg $raw_dst -y -i $file -f rawvideo -strict -1 $raw_dst
205 fi
206
207 ###################################
208 if [ -n "$do_rc" ] ; then
209 # mpeg4 rate control
210 file=${outfile}mpeg4-rc.avi
211 do_ffmpeg $file -y -b 400 -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
212
213 # mpeg4 rate control decoding
214 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
215 fi
216
217 ###################################
218 if [ -n "$do_mpeg4adv" ] ; then
219 # mpeg4
220 file=${outfile}mpeg4-adv.avi
221 do_ffmpeg $file -y -qscale 9 -4mv -hq -part -ps 200 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
222
223 # mpeg4 decoding
224 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
225 fi
226
227 ###################################
228 if [ -n "$do_mpeg1b" ] ; then
229 # mpeg1
230 file=${outfile}mpeg1b.mpg
231 do_ffmpeg $file -y -qscale 8 -bf 3 -ps 200 -f pgmyuv -i $raw_src -an -vcodec mpeg1video $file
232
233 # mpeg1 decoding
234 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
235 fi
236
237 ###################################
238 if [ -n "$do_mjpeg" ] ; then
239 # mjpeg
240 file=${outfile}mjpeg.avi
241 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
242
243 # mjpeg decoding
244 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
245 fi
246
247 ###################################
248 if [ -n "$do_rv10" ] ; then
249 # rv10 encoding
250 file=${outfile}rv10.rm
251 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file 
252
253 # rv10 decoding
254 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
255 fi
256
257 ###################################
258 if [ -n "$do_asv1" ] ; then
259 # asv1 encoding
260 file=${outfile}asv1.avi
261 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv1 $file
262
263 # asv1 decoding
264 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
265 fi
266
267 ###################################
268 if [ -n "$do_mp2" ] ; then
269 # mp2 encoding
270 file=${outfile}mp2.mp2
271 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file 
272
273 # mp2 decoding
274 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst 
275 fi
276
277 ###################################
278 if [ -n "$do_ac3" ] ; then
279 # ac3 encoding
280 file=${outfile}ac3.rm
281 do_ffmpeg $file -y -ab 128 -ac 2 -f s16le  -i $pcm_src -vn $file 
282
283 # ac3 decoding
284 #do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst 
285 fi
286
287 ###################################
288 # libav testing
289 ###################################
290
291 if [ -n "$do_libav" ] ; then
292
293 # avi
294 file=${outfile}libav.avi
295 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
296 do_ffmpeg_crc $file -i $file
297
298 # asf
299 file=${outfile}libav.asf
300 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
301 do_ffmpeg_crc $file -i $file
302
303 # rm
304 file=${outfile}libav.rm
305 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
306 # broken
307 #do_ffmpeg_crc $file -i $file
308
309 # mpegps
310 file=${outfile}libav.mpg
311 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
312 do_ffmpeg_crc $file -i $file
313
314 # swf (decode audio only)
315 file=${outfile}libav.swf
316 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
317 do_ffmpeg_crc $file -i $file
318
319 # ffm
320 file=${outfile}libav.ffm
321 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
322 do_ffmpeg_crc $file -i $file
323
324 # XXX: need mov and mpegts tests (add bitstreams or add output capability in ffmpeg)
325
326 ####################
327 # streamed images
328 # mjpeg
329 #file=${outfile}libav.mjpeg
330 #do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
331 #do_ffmpeg_crc $file -i $file
332
333 # pbmpipe
334 file=${outfile}libav.pbm
335 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
336 do_ffmpeg_crc $file -f imagepipe -i $file
337
338 # pgmpipe
339 file=${outfile}libav.pgm
340 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
341 do_ffmpeg_crc $file -f imagepipe -i $file
342
343 # ppmpipe
344 file=${outfile}libav.ppm
345 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
346 do_ffmpeg_crc $file -f imagepipe -i $file
347
348 # gif
349 file=${outfile}libav.gif
350 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
351 #do_ffmpeg_crc $file -i $file
352
353 # yuv4mpeg
354 file=${outfile}libav.yuv4mpeg
355 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
356 #do_ffmpeg_crc $file -i $file
357
358 ####################
359 # image formats
360 # pgm (we do not do md5 on image files yet)
361 file=${outfile}libav%d.pgm
362 $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
363 do_ffmpeg_crc $file -i $file
364
365 # ppm (we do not do md5 on image files yet)
366 file=${outfile}libav%d.ppm
367 $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
368 do_ffmpeg_crc $file -i $file
369
370 # jpeg (we do not do md5 on image files yet)
371 #file=${outfile}libav%d.jpg
372 #$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
373 #do_ffmpeg_crc $file -i $file
374
375 ####################
376 # audio only
377
378 # wav
379 file=${outfile}libav.wav
380 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
381 do_ffmpeg_crc $file -i $file
382
383 # alaw
384 file=${outfile}libav.al
385 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
386 do_ffmpeg_crc $file -i $file
387
388 # mulaw
389 file=${outfile}libav.ul
390 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
391 do_ffmpeg_crc $file -i $file
392
393 # au
394 file=${outfile}libav.au
395 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
396 do_ffmpeg_crc $file -i $file
397
398 ####################
399 # pix_fmt conversions
400 conversions="yuv420p yuv422p yuv444p yuv422 yuv410p yuv411p yuvj420p \
401              yuvj422p yuvj444p rgb24 bgr24 rgba32 rgb565 rgb555 gray monow \
402              monob pal8"
403 for pix_fmt in $conversions ; do
404     file=${outfile}libav-${pix_fmt}.yuv
405     do_ffmpeg_nocheck $file -r 1 -t 1 -y -f pgmyuv -i $raw_src \
406                             -f rawvideo -s 352x288 -pix_fmt $pix_fmt $raw_dst
407     do_ffmpeg $file -f rawvideo -s 352x288 -pix_fmt $pix_fmt -i $raw_dst \
408                     -f rawvideo -s 352x288 -pix_fmt yuv444p $file
409 done
410
411 fi
412
413
414
415 if $diff_cmd $logfile $reffile ; then
416     echo 
417     echo Regression test succeeded.
418     exit 0
419 else
420     echo 
421     echo Regression test: Error.
422     exit 1
423 fi