3 # automatic regression test for ffmpeg
7 # Even in the 21st century some diffs are not supporting -u.
8 diff -u "$0" "$0" > /dev/null 2>&1
15 diff -w "$0" "$0" > /dev/null 2>&1
17 diff_cmd="$diff_cmd -w"
24 logfile="$datadir/ffmpeg.regression"
28 if [ "$1" = "mpeg4" ] ; then
30 elif [ "$1" = "mpeg" ] ; then
33 elif [ "$1" = "ac3" ] ; then
35 elif [ "$1" = "huffyuv" ] ; then
37 elif [ "$1" = "mpeg2thread" ] ; then
39 elif [ "$1" = "snow" ] ; then
41 elif [ "$1" = "libavtest" ] ; then
43 logfile="$datadir/libav.regression"
84 tiny_psnr="./tiny_psnr"
86 benchfile="$datadir/ffmpeg.bench"
88 raw_dst="$datadir/out.yuv"
89 raw_ref="$datadir/ref.yuv"
91 pcm_dst="$datadir/out.wav"
92 pcm_ref="$datadir/ref.wav"
93 if [ X"`echo | md5sum 2> /dev/null`" != X ]; then
94 do_md5sum() { md5sum -b $1; }
95 elif [ -x /sbin/md5 ]; then
96 do_md5sum() { /sbin/md5 -r $1 | sed 's# \**\./# *./#'; }
98 do_md5sum() { echo No md5sum program found; }
101 # create the data directory if it does not exists
108 echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $*
109 $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp 2> /tmp/ffmpeg$$
110 egrep -v "^(Stream|Press|Input|Output|frame| Stream| Duration|video:)" /tmp/ffmpeg$$ || true
112 do_md5sum $f >> $logfile
113 if [ $f = $raw_dst ] ; then
114 $tiny_psnr $f $raw_ref >> $logfile
115 elif [ $f = $pcm_dst ] ; then
116 $tiny_psnr $f $pcm_ref 2 >> $logfile
120 expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
121 echo `cat $datadir/bench2.tmp` $f >> $benchfile
128 echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
129 $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc > /tmp/ffmpeg$$ 2>&1
130 egrep -v "^(Stream|Press|Input|Output|frame| Stream| Duration|video:|ffmpeg version| configuration| built)" /tmp/ffmpeg$$ || true
132 echo "$f `cat $datadir/ffmpeg.crc`" >> $logfile
139 echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $*
140 $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp 2> /tmp/ffmpeg$$
141 egrep -v "^(Stream|Press|Input|Output|frame| Stream| Duration|video:)" /tmp/ffmpeg$$ || true
143 expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
144 echo `cat $datadir/bench2.tmp` $f >> $benchfile
147 echo "ffmpeg regression test" > $logfile
148 echo "ffmpeg benchmarks" > $benchfile
150 ###################################
151 # generate reference for quality check
152 do_ffmpeg_nocheck $raw_ref -y -f pgmyuv -i $raw_src -an -f rawvideo $raw_ref
153 do_ffmpeg_nocheck $pcm_ref -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src -f wav $pcm_ref
155 ###################################
156 if [ -n "$do_mpeg" ] ; then
158 file=${outfile}mpeg1.mpg
159 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpeg1video $file
162 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
165 ###################################
166 if [ -n "$do_mpeg2" ] ; then
168 file=${outfile}mpeg2.mpg
169 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video $file
172 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
175 file=${outfile}mpeg2.mpg
176 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -idct_algo 1 -dct_algo 2 -f mpeg1video $file
179 do_ffmpeg $raw_dst -y -idct_algo 1 -i $file -f rawvideo $raw_dst
181 # mpeg2 encoding interlaced
182 file=${outfile}mpeg2i.mpg
183 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video -ildct -ilme $file
186 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
189 ###################################
190 if [ -n "$do_mpeg2thread" ] ; then
191 # mpeg2 encoding interlaced
192 file=${outfile}mpeg2thread.mpg
193 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video -bf 2 -ildct -ilme -threads 2 $file
196 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
198 # mpeg2 encoding interlaced
199 file=${outfile}mpeg2reuse.mpg
200 do_ffmpeg $file -y -sameq -me_threshold 256 -mb_threshold 1024 -i ${outfile}mpeg2thread.mpg -vcodec mpeg2video -f mpeg1video -bf 2 -ildct -ilme -threads 4 $file
203 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
206 ###################################
207 if [ -n "$do_msmpeg4v2" ] ; then
209 file=${outfile}msmpeg4v2.avi
210 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4v2 $file
213 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
216 ###################################
217 if [ -n "$do_msmpeg4" ] ; then
219 file=${outfile}msmpeg4.avi
220 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
223 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
226 ###################################
227 if [ -n "$do_wmv1" ] ; then
229 file=${outfile}wmv1.avi
230 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv1 $file
233 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
236 ###################################
237 if [ -n "$do_wmv2" ] ; then
239 file=${outfile}wmv2.avi
240 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv2 $file
243 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
246 ###################################
247 if [ -n "$do_h261" ] ; then
249 file=${outfile}h261.avi
250 do_ffmpeg $file -y -qscale 11 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h261 $file
253 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
256 ###################################
257 if [ -n "$do_h263" ] ; then
259 file=${outfile}h263.avi
260 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
263 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
266 ###################################
267 if [ -n "$do_h263p" ] ; then
269 file=${outfile}h263p.avi
270 do_ffmpeg $file -y -qscale 2 -umv -aiv -aic -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263p -ps 300 $file
273 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
276 ###################################
277 if [ -n "$do_mpeg4" ] ; then
279 file=${outfile}odivx.mp4
280 do_ffmpeg $file -y -4mv -hq -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
283 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
286 ###################################
287 if [ -n "$do_huffyuv" ] ; then
289 file=${outfile}huffyuv.avi
290 do_ffmpeg $file -y -f pgmyuv -i $raw_src -an -vcodec huffyuv -pix_fmt yuv422p $file
293 do_ffmpeg $raw_dst -y -i $file -f rawvideo -strict -1 $raw_dst
296 ###################################
297 if [ -n "$do_rc" ] ; then
299 file=${outfile}mpeg4-rc.avi
300 do_ffmpeg $file -y -b 400 -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
302 # mpeg4 rate control decoding
303 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
306 ###################################
307 if [ -n "$do_mpeg4adv" ] ; then
309 file=${outfile}mpeg4-adv.avi
310 do_ffmpeg $file -y -qscale 9 -4mv -hq -part -ps 200 -aic -trell -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
313 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
316 ###################################
317 if [ -n "$do_mpeg4thread" ] ; then
319 file=${outfile}mpeg4-thread.avi
320 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
323 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
326 ###################################
327 if [ -n "$do_mpeg4adv" ] ; then
329 file=${outfile}mpeg4-Q.avi
330 do_ffmpeg $file -y -qscale 7 -4mv -mbd 2 -qpel -bf 2 -cmp 1 -subcmp 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
333 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
336 ###################################
337 if [ -n "$do_error" ] ; then
339 file=${outfile}error-mpeg4-adv.avi
340 do_ffmpeg $file -y -qscale 7 -4mv -mbd 2 -part -ps 250 -error 10 -aic -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
342 # damaged mpeg4 decoding
343 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
346 ###################################
347 if [ -n "$do_mpeg4nr" ] ; then
349 file=${outfile}mpeg4-nr.avi
350 do_ffmpeg $file -y -qscale 8 -4mv -mbd 2 -nr 200 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
353 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
356 ###################################
357 if [ -n "$do_mpeg1b" ] ; then
359 file=${outfile}mpeg1b.mpg
360 do_ffmpeg $file -y -qscale 8 -bf 3 -ps 200 -f pgmyuv -i $raw_src -an -vcodec mpeg1video -f mpeg1video $file
363 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
366 ###################################
367 if [ -n "$do_mjpeg" ] ; then
369 file=${outfile}mjpeg.avi
370 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg -pix_fmt yuvj420p $file
373 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
376 ###################################
377 if [ -n "$do_ljpeg" ] ; then
379 file=${outfile}ljpeg.avi
380 do_ffmpeg $file -y -f pgmyuv -i $raw_src -an -vcodec ljpeg -strict -1 $file
383 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
386 ###################################
387 if [ -n "$do_rv10" ] ; then
389 file=${outfile}rv10.rm
390 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file
393 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
396 ###################################
397 if [ -n "$do_rv20" ] ; then
399 file=${outfile}rv20.rm
400 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec rv20 -an $file
403 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
406 ###################################
407 if [ -n "$do_asv1" ] ; then
409 file=${outfile}asv1.avi
410 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv1 $file
413 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
416 ###################################
417 if [ -n "$do_asv2" ] ; then
419 file=${outfile}asv2.avi
420 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv2 $file
423 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
426 ###################################
427 if [ -n "$do_flv" ] ; then
429 file=${outfile}flv.flv
430 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec flv $file
433 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
436 ###################################
437 if [ -n "$do_ffv1" ] ; then
439 file=${outfile}ffv1.avi
440 do_ffmpeg $file -y -strict -1 -f pgmyuv -i $raw_src -an -vcodec ffv1 $file
443 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
446 ###################################
447 if [ -n "$do_snow" ] ; then
449 file=${outfile}snow.avi
450 do_ffmpeg $file -y -strict -1 -f pgmyuv -i $raw_src -an -vcodec snow -qscale 2 $file
453 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
456 file=${outfile}snow53.avi
457 do_ffmpeg $file -y -strict -1 -f pgmyuv -i $raw_src -an -vcodec snow -pred 1 -qpel -4mv $file
460 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
463 ###################################
464 if [ -n "$do_svq1" ] ; then
466 file=${outfile}svq1.mov
467 do_ffmpeg $file -y -f pgmyuv -i $raw_src -an -vcodec svq1 -qscale 3 -pix_fmt yuv410p $file
470 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
473 ###################################
474 if [ -n "$do_mp2" ] ; then
476 file=${outfile}mp2.mp2
477 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file
480 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
481 $tiny_psnr $pcm_dst $pcm_ref 2 1924 >> $logfile
484 ###################################
485 if [ -n "$do_ac3" ] ; then
487 file=${outfile}ac3.rm
488 do_ffmpeg $file -y -ab 128 -ac 2 -f s16le -i $pcm_src -vn $file
491 #do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
494 ###################################
495 if [ -n "$do_g726" ] ; then
497 file=${outfile}g726.wav
498 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src -ab 32 -ac 1 -ar 8000 -acodec g726 $file
501 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
504 ###################################
505 if [ -n "$do_adpcm_ima_wav" ] ; then
507 file=${outfile}adpcm_ima.wav
508 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src -acodec adpcm_ima_wav $file
511 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
514 ###################################
515 if [ -n "$do_adpcm_ms" ] ; then
517 file=${outfile}adpcm_ms.wav
518 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src -acodec adpcm_ms $file
521 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
524 ###################################
526 ###################################
528 if [ -n "$do_libav" ] ; then
531 file=${outfile}libav.avi
532 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
533 do_ffmpeg_crc $file -i $file
536 file=${outfile}libav.asf
537 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -acodec mp2 $file
538 do_ffmpeg_crc $file -i $file -r 25
541 file=${outfile}libav.rm
542 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
544 #do_ffmpeg_crc $file -i $file
547 file=${outfile}libav.mpg
548 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
549 do_ffmpeg_crc $file -i $file
551 # swf (decode audio only)
552 file=${outfile}libav.swf
553 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -acodec mp2 $file
554 do_ffmpeg_crc $file -i $file
557 file=${outfile}libav.ffm
558 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
559 do_ffmpeg_crc $file -i $file
562 file=${outfile}libav.flv
563 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -an $file
564 do_ffmpeg_crc $file -i $file
567 file=${outfile}libav.mov
568 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -acodec pcm_alaw $file
569 do_ffmpeg_crc $file -i $file
572 file=${outfile}libav.nut
573 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -acodec mp2 $file
574 do_ffmpeg_crc $file -i $file
577 file=${outfile}libav.dv
578 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -ar 48000 -r 25 -s pal -ac 2 $file
579 do_ffmpeg_crc $file -i $file
581 # XXX: need mpegts tests (add bitstreams or add output capability in ffmpeg)
586 #file=${outfile}libav.mjpeg
587 #do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
588 #do_ffmpeg_crc $file -i $file
591 file=${outfile}libav.pbm
592 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f image2pipe $file
593 do_ffmpeg_crc $file -f image2pipe -i $file
596 file=${outfile}libav.pgm
597 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f image2pipe $file
598 do_ffmpeg_crc $file -f image2pipe -i $file
601 file=${outfile}libav.ppm
602 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f image2pipe $file
603 do_ffmpeg_crc $file -f image2pipe -i $file
606 file=${outfile}libav.gif
607 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
608 #do_ffmpeg_crc $file -i $file
611 file=${outfile}libav.yuv4mpeg
612 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
613 #do_ffmpeg_crc $file -i $file
617 # pgm (we do not do md5 on image files yet)
618 file=${outfile}libav%d.pgm
619 $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
620 do_ffmpeg_crc $file -i $file
622 # ppm (we do not do md5 on image files yet)
623 file=${outfile}libav%d.ppm
624 $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
625 do_ffmpeg_crc $file -i $file
627 # jpeg (we do not do md5 on image files yet)
628 file=${outfile}libav%d.jpg
629 $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src -bitexact -dct_algo 1 -idct_algo 2 -pix_fmt yuvj420p -f image2 $file
630 do_ffmpeg_crc $file -f image2 -i $file
636 file=${outfile}libav.wav
637 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
638 do_ffmpeg_crc $file -i $file
641 file=${outfile}libav.al
642 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
643 do_ffmpeg_crc $file -i $file
646 file=${outfile}libav.ul
647 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
648 do_ffmpeg_crc $file -i $file
651 file=${outfile}libav.au
652 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
653 do_ffmpeg_crc $file -i $file
656 # pix_fmt conversions
657 conversions="yuv420p yuv422p yuv444p yuv422 yuv410p yuv411p yuvj420p \
658 yuvj422p yuvj444p rgb24 bgr24 rgba32 rgb565 rgb555 gray monow \
660 for pix_fmt in $conversions ; do
661 file=${outfile}libav-${pix_fmt}.yuv
662 do_ffmpeg_nocheck $file -r 1 -t 1 -y -f pgmyuv -i $raw_src \
663 -f rawvideo -s 352x288 -pix_fmt $pix_fmt $raw_dst
664 do_ffmpeg $file -f rawvideo -s 352x288 -pix_fmt $pix_fmt -i $raw_dst \
665 -f rawvideo -s 352x288 -pix_fmt yuv444p $file
672 if $diff_cmd "$logfile" "$reffile" ; then
674 echo Regression test succeeded.
678 echo Regression test: Error.