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" = "libavtest" ] ; then
37 logfile="$datadir/libav.regression"
76 tiny_psnr="./tiny_psnr"
78 benchfile="$datadir/ffmpeg.bench"
80 raw_dst="$datadir/out.yuv"
81 raw_ref="$datadir/ref.yuv"
83 pcm_dst="$datadir/out.wav"
84 if [ X"`echo | md5sum 2> /dev/null`" != X ]; then
85 do_md5sum() { md5sum -b $1; }
86 elif [ -x /sbin/md5 ]; then
87 do_md5sum() { /sbin/md5 -r $1 | sed 's# \**\./# *./#'; }
89 do_md5sum() { echo No md5sum program found; }
92 # create the data directory if it does not exists
99 echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $*
100 $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp 2> /tmp/ffmpeg$$
101 egrep -v "^(Stream|Press|Input|Output|frame| Stream| Duration|video:)" /tmp/ffmpeg$$ || true
103 do_md5sum $f >> $logfile
104 if [ $f = $raw_dst ] ; then
105 $tiny_psnr $f $raw_ref >> $logfile
109 expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
110 echo `cat $datadir/bench2.tmp` $f >> $benchfile
117 echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
118 $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc > /tmp/ffmpeg$$ 2>&1
119 egrep -v "^(Stream|Press|Input|Output|frame| Stream| Duration|video:|ffmpeg version| configuration| built)" /tmp/ffmpeg$$ || true
121 echo "$f `cat $datadir/ffmpeg.crc`" >> $logfile
128 echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $*
129 $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp 2> /tmp/ffmpeg$$
130 egrep -v "^(Stream|Press|Input|Output|frame| Stream| Duration|video:)" /tmp/ffmpeg$$ || true
132 expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
133 echo `cat $datadir/bench2.tmp` $f >> $benchfile
136 echo "ffmpeg regression test" > $logfile
137 echo "ffmpeg benchmarks" > $benchfile
139 ###################################
140 # generate reference for quality check
141 do_ffmpeg_nocheck $raw_ref -y -f pgmyuv -i $raw_src -an -f rawvideo $raw_ref
143 ###################################
144 if [ -n "$do_mpeg" ] ; then
146 file=${outfile}mpeg1.mpg
147 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpeg1video $file
150 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
153 ###################################
154 if [ -n "$do_mpeg2" ] ; then
156 file=${outfile}mpeg2.mpg
157 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video $file
160 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
163 file=${outfile}mpeg2.mpg
164 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -idct_algo 1 -dct_algo 2 -f mpeg1video $file
167 do_ffmpeg $raw_dst -y -idct_algo 1 -i $file -f rawvideo $raw_dst
169 # mpeg2 encoding interlaced
170 file=${outfile}mpeg2i.mpg
171 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video -ildct -ilme $file
174 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
177 ###################################
178 if [ -n "$do_mpeg2thread" ] ; then
179 # mpeg2 encoding interlaced
180 file=${outfile}mpeg2thread.mpg
181 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video -bf 2 -ildct -ilme -threads 2 $file
184 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
187 ###################################
188 if [ -n "$do_msmpeg4v2" ] ; then
190 file=${outfile}msmpeg4v2.avi
191 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4v2 $file
194 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
197 ###################################
198 if [ -n "$do_msmpeg4" ] ; then
200 file=${outfile}msmpeg4.avi
201 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
204 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
207 ###################################
208 if [ -n "$do_wmv1" ] ; then
210 file=${outfile}wmv1.avi
211 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv1 $file
214 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
217 ###################################
218 if [ -n "$do_wmv2" ] ; then
220 file=${outfile}wmv2.avi
221 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv2 $file
224 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
227 ###################################
228 if [ -n "$do_h261" ] ; then
230 file=${outfile}h261.avi
231 do_ffmpeg $file -y -qscale 11 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h261 $file
234 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
237 ###################################
238 if [ -n "$do_h263" ] ; then
240 file=${outfile}h263.avi
241 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
244 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
247 ###################################
248 if [ -n "$do_h263p" ] ; then
250 file=${outfile}h263p.avi
251 do_ffmpeg $file -y -qscale 2 -umv -aiv -aic -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263p -ps 300 $file
254 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
257 ###################################
258 if [ -n "$do_mpeg4" ] ; then
260 file=${outfile}odivx.mp4
261 do_ffmpeg $file -y -4mv -hq -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
264 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
267 ###################################
268 if [ -n "$do_huffyuv" ] ; then
270 file=${outfile}huffyuv.avi
271 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec huffyuv -strict -1 $file
274 do_ffmpeg $raw_dst -y -i $file -f rawvideo -strict -1 $raw_dst
277 ###################################
278 if [ -n "$do_rc" ] ; then
280 file=${outfile}mpeg4-rc.avi
281 do_ffmpeg $file -y -b 400 -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
283 # mpeg4 rate control decoding
284 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
287 ###################################
288 if [ -n "$do_mpeg4adv" ] ; then
290 file=${outfile}mpeg4-adv.avi
291 do_ffmpeg $file -y -qscale 9 -4mv -hq -part -ps 200 -aic -trell -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
294 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
297 ###################################
298 if [ -n "$do_mpeg4thread" ] ; then
300 file=${outfile}mpeg4-thread.avi
301 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
304 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
307 ###################################
308 if [ -n "$do_mpeg4adv" ] ; then
310 file=${outfile}mpeg4-Q.avi
311 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
314 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
317 ###################################
318 if [ -n "$do_error" ] ; then
320 file=${outfile}error-mpeg4-adv.avi
321 do_ffmpeg $file -y -qscale 7 -4mv -mbd 2 -part -ps 250 -error 10 -aic -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
323 # damaged mpeg4 decoding
324 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
327 ###################################
328 if [ -n "$do_mpeg4nr" ] ; then
330 file=${outfile}mpeg4-nr.avi
331 do_ffmpeg $file -y -qscale 8 -4mv -mbd 2 -nr 200 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
334 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
337 ###################################
338 if [ -n "$do_mpeg1b" ] ; then
340 file=${outfile}mpeg1b.mpg
341 do_ffmpeg $file -y -qscale 8 -bf 3 -ps 200 -f pgmyuv -i $raw_src -an -vcodec mpeg1video -f mpeg1video $file
344 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
347 ###################################
348 if [ -n "$do_mjpeg" ] ; then
350 file=${outfile}mjpeg.avi
351 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
354 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
357 ###################################
358 if [ -n "$do_ljpeg" ] ; then
360 file=${outfile}ljpeg.avi
361 do_ffmpeg $file -y -f pgmyuv -i $raw_src -an -vcodec ljpeg $file
364 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
367 ###################################
368 if [ -n "$do_rv10" ] ; then
370 file=${outfile}rv10.rm
371 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file
374 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
377 ###################################
378 if [ -n "$do_asv1" ] ; then
380 file=${outfile}asv1.avi
381 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv1 $file
384 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
387 ###################################
388 if [ -n "$do_asv2" ] ; then
390 file=${outfile}asv2.avi
391 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv2 $file
394 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
397 ###################################
398 if [ -n "$do_flv" ] ; then
400 file=${outfile}flv.flv
401 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec flv $file
404 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
407 ###################################
408 if [ -n "$do_ffv1" ] ; then
410 file=${outfile}ffv1.avi
411 do_ffmpeg $file -y -strict -1 -f pgmyuv -i $raw_src -an -vcodec ffv1 $file
414 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
417 ###################################
418 if [ -n "$do_svq1" ] ; then
420 file=${outfile}svq1.mov
421 do_ffmpeg $file -y -f pgmyuv -i $raw_src -an -vcodec svq1 -qscale 3 -pix_fmt yuv410p $file
424 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
427 ###################################
428 if [ -n "$do_mp2" ] ; then
430 file=${outfile}mp2.mp2
431 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file
434 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
437 ###################################
438 if [ -n "$do_ac3" ] ; then
440 file=${outfile}ac3.rm
441 do_ffmpeg $file -y -ab 128 -ac 2 -f s16le -i $pcm_src -vn $file
444 #do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
447 ###################################
448 if [ -n "$do_g726" ] ; then
450 file=${outfile}g726.wav
451 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src -ab 32 -ac 1 -ar 8000 -acodec g726 $file
454 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
457 ###################################
458 if [ -n "$do_adpcm_ima_wav" ] ; then
460 file=${outfile}adpcm_ima.wav
461 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src -acodec adpcm_ima_wav $file
464 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
467 ###################################
468 if [ -n "$do_adpcm_ms" ] ; then
470 file=${outfile}adpcm_ms.wav
471 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src -acodec adpcm_ms $file
474 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
477 ###################################
479 ###################################
481 if [ -n "$do_libav" ] ; then
484 file=${outfile}libav.avi
485 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
486 do_ffmpeg_crc $file -i $file
489 file=${outfile}libav.asf
490 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -acodec mp2 $file
491 do_ffmpeg_crc $file -i $file -r 25
494 file=${outfile}libav.rm
495 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
497 #do_ffmpeg_crc $file -i $file
500 file=${outfile}libav.mpg
501 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
502 do_ffmpeg_crc $file -i $file
504 # swf (decode audio only)
505 file=${outfile}libav.swf
506 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -acodec mp2 $file
507 do_ffmpeg_crc $file -i $file
510 file=${outfile}libav.ffm
511 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
512 do_ffmpeg_crc $file -i $file
515 file=${outfile}libav.flv
516 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -an $file
517 do_ffmpeg_crc $file -i $file
520 file=${outfile}libav.mov
521 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -acodec pcm_alaw $file
522 do_ffmpeg_crc $file -i $file
525 file=${outfile}libav.nut
526 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src -acodec mp2 $file
527 do_ffmpeg_crc $file -i $file
530 file=${outfile}libav.dv
531 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
532 do_ffmpeg_crc $file -i $file
534 # XXX: need mpegts tests (add bitstreams or add output capability in ffmpeg)
539 #file=${outfile}libav.mjpeg
540 #do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
541 #do_ffmpeg_crc $file -i $file
544 file=${outfile}libav.pbm
545 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
546 do_ffmpeg_crc $file -f imagepipe -i $file
549 file=${outfile}libav.pgm
550 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
551 do_ffmpeg_crc $file -f imagepipe -i $file
554 file=${outfile}libav.ppm
555 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
556 do_ffmpeg_crc $file -f imagepipe -i $file
559 file=${outfile}libav.gif
560 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
561 #do_ffmpeg_crc $file -i $file
564 file=${outfile}libav.yuv4mpeg
565 do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
566 #do_ffmpeg_crc $file -i $file
570 # pgm (we do not do md5 on image files yet)
571 file=${outfile}libav%d.pgm
572 $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
573 do_ffmpeg_crc $file -i $file
575 # ppm (we do not do md5 on image files yet)
576 file=${outfile}libav%d.ppm
577 $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
578 do_ffmpeg_crc $file -i $file
580 # jpeg (we do not do md5 on image files yet)
581 file=${outfile}libav%d.jpg
582 $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src -f image2 $file
583 do_ffmpeg_crc $file -f image2 -i $file
589 file=${outfile}libav.wav
590 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
591 do_ffmpeg_crc $file -i $file
594 file=${outfile}libav.al
595 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
596 do_ffmpeg_crc $file -i $file
599 file=${outfile}libav.ul
600 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
601 do_ffmpeg_crc $file -i $file
604 file=${outfile}libav.au
605 do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
606 do_ffmpeg_crc $file -i $file
609 # pix_fmt conversions
610 conversions="yuv420p yuv422p yuv444p yuv422 yuv410p yuv411p yuvj420p \
611 yuvj422p yuvj444p rgb24 bgr24 rgba32 rgb565 rgb555 gray monow \
613 for pix_fmt in $conversions ; do
614 file=${outfile}libav-${pix_fmt}.yuv
615 do_ffmpeg_nocheck $file -r 1 -t 1 -y -f pgmyuv -i $raw_src \
616 -f rawvideo -s 352x288 -pix_fmt $pix_fmt $raw_dst
617 do_ffmpeg $file -f rawvideo -s 352x288 -pix_fmt $pix_fmt -i $raw_dst \
618 -f rawvideo -s 352x288 -pix_fmt yuv444p $file
625 if $diff_cmd $logfile $reffile ; then
627 echo Regression test succeeded.
631 echo Regression test: Error.