]> git.sesse.net Git - ffmpeg/blob - tests/regression.sh
count > thread_count for execute()
[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 outfile="$datadir/a-"
21
22 # tests to do
23 if [ "$1" = "mpeg4" ] ; then
24     do_mpeg4=y
25 elif [ "$1" = "mpeg" ] ; then
26     do_mpeg=y
27     do_mpeg2=y
28 elif [ "$1" = "ac3" ] ; then
29     do_ac3=y
30 elif [ "$1" = "libavtest" ] ; then
31     do_libav=y
32     logfile="$datadir/libav.regression"
33     outfile="$datadir/b-"
34 else
35     do_mpeg=y
36     do_mpeg2=y
37     do_mpeg2thread=y
38     do_msmpeg4v2=y
39     do_msmpeg4=y
40     do_wmv1=y
41     do_wmv2=y
42     do_h263=y
43     do_h263p=y
44     do_mpeg4=y
45     do_huffyuv=y
46     do_mjpeg=y
47     do_ljpeg=y
48     do_rv10=y
49     do_mp2=y
50     do_ac3=y
51     do_g726=y
52     do_adpcm_ima_wav=y
53     do_adpcm_ms=y
54     do_rc=y
55     do_mpeg4adv=y
56     do_mpeg4thread=y
57     do_mpeg4nr=y
58     do_mpeg1b=y
59     do_asv1=y
60     do_asv2=y
61     do_flv=y
62     do_ffv1=y
63     do_error=y
64 fi
65
66
67 # various files
68 ffmpeg="../ffmpeg_g"
69 tiny_psnr="./tiny_psnr"
70 reffile="$2"
71 benchfile="$datadir/ffmpeg.bench"
72 raw_src="$3/%d.pgm"
73 raw_dst="$datadir/out.yuv"
74 raw_ref="$datadir/ref.yuv"
75 pcm_src="asynth1.sw"
76 pcm_dst="$datadir/out.wav"
77 if [ X"`echo | md5sum 2> /dev/null`" != X ]; then
78     do_md5sum() { md5sum -b $1; }
79 elif [ -x /sbin/md5 ]; then
80     do_md5sum() { /sbin/md5 -r $1 | sed 's# \**\./# *./#'; }
81 else
82     do_md5sum() { echo No md5sum program found; }
83 fi
84
85 # create the data directory if it does not exists
86 mkdir -p $datadir
87
88 do_ffmpeg()
89 {
90     f="$1"
91     shift
92     echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $*
93     $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp 2> /tmp/ffmpeg$$
94     egrep -v "^(Stream|Press|Input|Output|frame|  Stream|  Duration)" /tmp/ffmpeg$$ || true
95     rm -f /tmp/ffmpeg$$
96     do_md5sum $f >> $logfile
97     if [ $f = $raw_dst ] ; then
98         $tiny_psnr $f $raw_ref >> $logfile
99     fi
100     expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
101     echo `cat $datadir/bench2.tmp` $f >> $benchfile
102 }
103
104 do_ffmpeg_crc()
105 {
106     f="$1"
107     shift
108     echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
109     $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc > /tmp/ffmpeg$$ 2>&1
110     egrep -v "^(Stream|Press|Input|Output|frame|  Stream|  Duration)" /tmp/ffmpeg$$ || true
111     rm -f /tmp/ffmpeg$$ 
112     echo "$f `cat $datadir/ffmpeg.crc`" >> $logfile
113 }
114
115 do_ffmpeg_nocheck()
116 {
117     f="$1"
118     shift
119     echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $*
120     $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp 2> /tmp/ffmpeg$$
121     egrep -v "^(Stream|Press|Input|Output|frame|  Stream|  Duration)" /tmp/ffmpeg$$ || true
122     rm -f /tmp/ffmpeg$$
123     expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
124     echo `cat $datadir/bench2.tmp` $f >> $benchfile
125 }
126
127 echo "ffmpeg regression test" > $logfile
128 echo "ffmpeg benchmarks" > $benchfile
129
130 ###################################
131 # generate reference for quality check
132 do_ffmpeg_nocheck $raw_ref -y -f pgmyuv -i $raw_src -an -f rawvideo $raw_ref
133
134 ###################################
135 if [ -n "$do_mpeg" ] ; then
136 # mpeg1 encoding
137 file=${outfile}mpeg1.mpg
138 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpeg1video $file 
139
140 # mpeg1 decoding
141 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
142 fi
143
144 ###################################
145 if [ -n "$do_mpeg2" ] ; then
146 # mpeg2 encoding
147 file=${outfile}mpeg2.mpg
148 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video $file 
149
150 # mpeg2 decoding
151 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
152
153 # mpeg2 encoding interlaced
154 file=${outfile}mpeg2i.mpg
155 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video -ildct -ilme $file 
156
157 # mpeg2 decoding
158 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
159 fi
160
161 ###################################
162 if [ -n "$do_mpeg2thread" ] ; then
163 # mpeg2 encoding interlaced
164 file=${outfile}mpeg2thread.mpg
165 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video -bf 2 -ildct -ilme -threads 2 $file 
166
167 # mpeg2 decoding
168 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
169 fi
170
171 ###################################
172 if [ -n "$do_msmpeg4v2" ] ; then
173 # msmpeg4 encoding
174 file=${outfile}msmpeg4v2.avi
175 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4v2 $file
176
177 # msmpeg4v2 decoding
178 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
179 fi
180
181 ###################################
182 if [ -n "$do_msmpeg4" ] ; then
183 # msmpeg4 encoding
184 file=${outfile}msmpeg4.avi
185 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
186
187 # msmpeg4 decoding
188 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
189 fi
190
191 ###################################
192 if [ -n "$do_wmv1" ] ; then
193 # wmv1 encoding
194 file=${outfile}wmv1.avi
195 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv1 $file
196
197 # wmv1 decoding
198 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
199 fi
200
201 ###################################
202 if [ -n "$do_wmv2" ] ; then
203 # wmv2 encoding
204 file=${outfile}wmv2.avi
205 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv2 $file
206
207 # wmv2 decoding
208 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
209 fi
210
211 ###################################
212 if [ -n "$do_h263" ] ; then
213 # h263 encoding
214 file=${outfile}h263.avi
215 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
216
217 # h263 decoding
218 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
219 fi
220
221 ###################################
222 if [ -n "$do_h263p" ] ; then
223 # h263p encoding
224 file=${outfile}h263p.avi
225 do_ffmpeg $file -y -qscale 2 -umv -aiv -aic -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263p -ps 300 $file
226
227 # h263p decoding
228 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
229 fi
230
231 ###################################
232 if [ -n "$do_mpeg4" ] ; then
233 # mpeg4
234 file=${outfile}odivx.mp4
235 do_ffmpeg $file -y -4mv -hq -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
236
237 # mpeg4 decoding
238 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
239 fi
240
241 ###################################
242 if [ -n "$do_huffyuv" ] ; then
243 # huffyuv
244 file=${outfile}huffyuv.avi
245 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec huffyuv -strict -1 $file
246
247 # huffyuv decoding
248 do_ffmpeg $raw_dst -y -i $file -f rawvideo -strict -1 $raw_dst
249 fi
250
251 ###################################
252 if [ -n "$do_rc" ] ; then
253 # mpeg4 rate control
254 file=${outfile}mpeg4-rc.avi
255 do_ffmpeg $file -y -b 400 -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
256
257 # mpeg4 rate control decoding
258 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
259 fi
260
261 ###################################
262 if [ -n "$do_mpeg4adv" ] ; then
263 # mpeg4
264 file=${outfile}mpeg4-adv.avi
265 do_ffmpeg $file -y -qscale 9 -4mv -hq -part -ps 200 -aic -trell -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
266
267 # mpeg4 decoding
268 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
269 fi
270
271 ###################################
272 if [ -n "$do_mpeg4thread" ] ; then
273 # mpeg4
274 file=${outfile}mpeg4-thread.avi
275 do_ffmpeg $file -y -b 500 -4mv -hq -part -ps 200 -aic -trell -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 -threads 2 $file
276
277 # mpeg4 decoding
278 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
279 fi
280
281 ###################################
282 if [ -n "$do_error" ] ; then
283 # damaged mpeg4
284 file=${outfile}error-mpeg4-adv.avi
285 do_ffmpeg $file -y -qscale 7 -4mv -mbd 2 -part -ps 250 -error 10 -aic -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
286
287 # damaged mpeg4 decoding
288 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
289 fi
290
291 ###################################
292 if [ -n "$do_mpeg4nr" ] ; then
293 # noise reduction
294 file=${outfile}mpeg4-nr.avi
295 do_ffmpeg $file -y -qscale 8 -4mv -mbd 2 -nr 200 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
296
297 # mpeg4 decoding
298 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
299 fi
300
301 ###################################
302 if [ -n "$do_mpeg1b" ] ; then
303 # mpeg1
304 file=${outfile}mpeg1b.mpg
305 do_ffmpeg $file -y -qscale 8 -bf 3 -ps 200 -f pgmyuv -i $raw_src -an -vcodec mpeg1video -f mpeg1video $file
306
307 # mpeg1 decoding
308 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
309 fi
310
311 ###################################
312 if [ -n "$do_mjpeg" ] ; then
313 # mjpeg
314 file=${outfile}mjpeg.avi
315 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
316
317 # mjpeg decoding
318 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
319 fi
320
321 ###################################
322 if [ -n "$do_ljpeg" ] ; then
323 # ljpeg
324 file=${outfile}ljpeg.avi
325 do_ffmpeg $file -y -f pgmyuv -i $raw_src -an -vcodec ljpeg $file
326
327 # ljpeg decoding
328 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
329 fi
330
331 ###################################
332 if [ -n "$do_rv10" ] ; then
333 # rv10 encoding
334 file=${outfile}rv10.rm
335 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file 
336
337 # rv10 decoding
338 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
339 fi
340
341 ###################################
342 if [ -n "$do_asv1" ] ; then
343 # asv1 encoding
344 file=${outfile}asv1.avi
345 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv1 $file
346
347 # asv1 decoding
348 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
349 fi
350
351 ###################################
352 if [ -n "$do_asv2" ] ; then
353 # asv2 encoding
354 file=${outfile}asv2.avi
355 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv2 $file
356
357 # asv2 decoding
358 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
359 fi
360
361 ###################################
362 if [ -n "$do_flv" ] ; then
363 # flv encoding
364 file=${outfile}flv.flv
365 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec flv $file
366
367 # flv decoding
368 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
369 fi
370
371 ###################################
372 if [ -n "$do_ffv1" ] ; then
373 # ffv1 encoding
374 file=${outfile}ffv1.avi
375 do_ffmpeg $file -y -strict -1 -f pgmyuv -i $raw_src -an -vcodec ffv1 $file
376
377 # ffv1 decoding
378 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
379 fi
380
381 ###################################
382 if [ -n "$do_mp2" ] ; then
383 # mp2 encoding
384 file=${outfile}mp2.mp2
385 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file 
386
387 # mp2 decoding
388 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst 
389 fi
390
391 ###################################
392 if [ -n "$do_ac3" ] ; then
393 # ac3 encoding
394 file=${outfile}ac3.rm
395 do_ffmpeg $file -y -ab 128 -ac 2 -f s16le  -i $pcm_src -vn $file 
396
397 # ac3 decoding
398 #do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst 
399 fi
400
401 ###################################
402 if [ -n "$do_g726" ] ; then
403 # g726 encoding
404 file=${outfile}g726.wav
405 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src -ab 32 -ac 1 -ar 8000 -acodec g726 $file 
406
407 # g726 decoding
408 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst 
409 fi
410
411 ###################################
412 if [ -n "$do_adpcm_ima_wav" ] ; then
413 # encoding
414 file=${outfile}adpcm_ima.wav
415 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src -acodec adpcm_ima_wav $file 
416
417 # decoding
418 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst 
419 fi
420
421 ###################################
422 if [ -n "$do_adpcm_ms" ] ; then
423 # encoding
424 file=${outfile}adpcm_ms.wav
425 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src -acodec adpcm_ms $file 
426
427 # decoding
428 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst 
429 fi
430
431 ###################################
432 # libav testing
433 ###################################
434
435 if [ -n "$do_libav" ] ; then
436
437 # avi
438 file=${outfile}libav.avi
439 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
440 do_ffmpeg_crc $file -i $file
441
442 # asf
443 file=${outfile}libav.asf
444 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
445 do_ffmpeg_crc $file -i $file
446
447 # rm
448 file=${outfile}libav.rm
449 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
450 # broken
451 #do_ffmpeg_crc $file -i $file
452
453 # mpegps
454 file=${outfile}libav.mpg
455 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
456 do_ffmpeg_crc $file -i $file
457
458 # swf (decode audio only)
459 file=${outfile}libav.swf
460 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -acodec mp2 $file
461 do_ffmpeg_crc $file -i $file
462
463 # ffm
464 #file=${outfile}libav.ffm
465 #do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
466 #do_ffmpeg_crc $file -i $file
467
468 # flv
469 file=${outfile}libav.flv
470 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
471 do_ffmpeg_crc $file -i $file
472
473 # mov
474 file=${outfile}libav.mov
475 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -acodec pcm_alaw $file
476 do_ffmpeg_crc $file -i $file
477
478 # nut
479 file=${outfile}libav.nut
480 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
481 do_ffmpeg_crc $file -i $file
482
483 # XXX: need mpegts tests (add bitstreams or add output capability in ffmpeg)
484
485 ####################
486 # streamed images
487 # mjpeg
488 #file=${outfile}libav.mjpeg
489 #do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
490 #do_ffmpeg_crc $file -i $file
491
492 # pbmpipe
493 file=${outfile}libav.pbm
494 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
495 do_ffmpeg_crc $file -f imagepipe -i $file
496
497 # pgmpipe
498 file=${outfile}libav.pgm
499 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
500 do_ffmpeg_crc $file -f imagepipe -i $file
501
502 # ppmpipe
503 file=${outfile}libav.ppm
504 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
505 do_ffmpeg_crc $file -f imagepipe -i $file
506
507 # gif
508 file=${outfile}libav.gif
509 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
510 #do_ffmpeg_crc $file -i $file
511
512 # yuv4mpeg
513 file=${outfile}libav.yuv4mpeg
514 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
515 #do_ffmpeg_crc $file -i $file
516
517 ####################
518 # image formats
519 # pgm (we do not do md5 on image files yet)
520 file=${outfile}libav%d.pgm
521 $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
522 do_ffmpeg_crc $file -i $file
523
524 # ppm (we do not do md5 on image files yet)
525 file=${outfile}libav%d.ppm
526 $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
527 do_ffmpeg_crc $file -i $file
528
529 # jpeg (we do not do md5 on image files yet)
530 #file=${outfile}libav%d.jpg
531 #$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
532 #do_ffmpeg_crc $file -i $file
533
534 ####################
535 # audio only
536
537 # wav
538 file=${outfile}libav.wav
539 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
540 do_ffmpeg_crc $file -i $file
541
542 # alaw
543 file=${outfile}libav.al
544 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
545 do_ffmpeg_crc $file -i $file
546
547 # mulaw
548 file=${outfile}libav.ul
549 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
550 do_ffmpeg_crc $file -i $file
551
552 # au
553 file=${outfile}libav.au
554 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
555 do_ffmpeg_crc $file -i $file
556
557 ####################
558 # pix_fmt conversions
559 conversions="yuv420p yuv422p yuv444p yuv422 yuv410p yuv411p yuvj420p \
560              yuvj422p yuvj444p rgb24 bgr24 rgba32 rgb565 rgb555 gray monow \
561              monob pal8"
562 for pix_fmt in $conversions ; do
563     file=${outfile}libav-${pix_fmt}.yuv
564     do_ffmpeg_nocheck $file -r 1 -t 1 -y -f pgmyuv -i $raw_src \
565                             -f rawvideo -s 352x288 -pix_fmt $pix_fmt $raw_dst
566     do_ffmpeg $file -f rawvideo -s 352x288 -pix_fmt $pix_fmt -i $raw_dst \
567                     -f rawvideo -s 352x288 -pix_fmt yuv444p $file
568 done
569
570 fi
571
572
573
574 if $diff_cmd $logfile $reffile ; then
575     echo 
576     echo Regression test succeeded.
577     exit 0
578 else
579     echo 
580     echo Regression test: Error.
581     exit 1
582 fi