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
19 logfile="$datadir/ffmpeg.regression"
23 if [ "$1" = "mpeg4" ] ; then
25 elif [ "$1" = "mpeg" ] ; then
28 elif [ "$1" = "ac3" ] ; then
30 elif [ "$1" = "libavtest" ] ; then
32 logfile="$datadir/libav.regression"
69 tiny_psnr="./tiny_psnr"
71 benchfile="$datadir/ffmpeg.bench"
73 raw_dst="$datadir/out.yuv"
74 raw_ref="$datadir/ref.yuv"
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# \**\./# *./#'; }
82 do_md5sum() { echo No md5sum program found; }
85 # create the data directory if it does not exists
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
96 do_md5sum $f >> $logfile
97 if [ $f = $raw_dst ] ; then
98 $tiny_psnr $f $raw_ref >> $logfile
100 expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
101 echo `cat $datadir/bench2.tmp` $f >> $benchfile
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
112 echo "$f `cat $datadir/ffmpeg.crc`" >> $logfile
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
123 expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
124 echo `cat $datadir/bench2.tmp` $f >> $benchfile
127 echo "ffmpeg regression test" > $logfile
128 echo "ffmpeg benchmarks" > $benchfile
130 ###################################
131 # generate reference for quality check
132 do_ffmpeg_nocheck $raw_ref -y -f pgmyuv -i $raw_src -an -f rawvideo $raw_ref
134 ###################################
135 if [ -n "$do_mpeg" ] ; then
137 file=${outfile}mpeg1.mpg
138 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpeg1video $file
141 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
144 ###################################
145 if [ -n "$do_mpeg2" ] ; then
147 file=${outfile}mpeg2.mpg
148 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video $file
151 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
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
158 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
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
168 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
171 ###################################
172 if [ -n "$do_msmpeg4v2" ] ; then
174 file=${outfile}msmpeg4v2.avi
175 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4v2 $file
178 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
181 ###################################
182 if [ -n "$do_msmpeg4" ] ; then
184 file=${outfile}msmpeg4.avi
185 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
188 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
191 ###################################
192 if [ -n "$do_wmv1" ] ; then
194 file=${outfile}wmv1.avi
195 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv1 $file
198 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
201 ###################################
202 if [ -n "$do_wmv2" ] ; then
204 file=${outfile}wmv2.avi
205 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv2 $file
208 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
211 ###################################
212 if [ -n "$do_h263" ] ; then
214 file=${outfile}h263.avi
215 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
218 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
221 ###################################
222 if [ -n "$do_h263p" ] ; then
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
228 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
231 ###################################
232 if [ -n "$do_mpeg4" ] ; then
234 file=${outfile}odivx.mp4
235 do_ffmpeg $file -y -4mv -hq -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
238 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
241 ###################################
242 if [ -n "$do_huffyuv" ] ; then
244 file=${outfile}huffyuv.avi
245 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec huffyuv -strict -1 $file
248 do_ffmpeg $raw_dst -y -i $file -f rawvideo -strict -1 $raw_dst
251 ###################################
252 if [ -n "$do_rc" ] ; then
254 file=${outfile}mpeg4-rc.avi
255 do_ffmpeg $file -y -b 400 -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
257 # mpeg4 rate control decoding
258 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
261 ###################################
262 if [ -n "$do_mpeg4adv" ] ; then
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
268 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
271 ###################################
272 if [ -n "$do_mpeg4thread" ] ; then
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
278 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
281 ###################################
282 if [ -n "$do_error" ] ; then
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
287 # damaged mpeg4 decoding
288 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
291 ###################################
292 if [ -n "$do_mpeg4nr" ] ; then
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
298 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
301 ###################################
302 if [ -n "$do_mpeg1b" ] ; then
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
308 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
311 ###################################
312 if [ -n "$do_mjpeg" ] ; then
314 file=${outfile}mjpeg.avi
315 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
318 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
321 ###################################
322 if [ -n "$do_ljpeg" ] ; then
324 file=${outfile}ljpeg.avi
325 do_ffmpeg $file -y -f pgmyuv -i $raw_src -an -vcodec ljpeg $file
328 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
331 ###################################
332 if [ -n "$do_rv10" ] ; then
334 file=${outfile}rv10.rm
335 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file
338 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
341 ###################################
342 if [ -n "$do_asv1" ] ; then
344 file=${outfile}asv1.avi
345 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv1 $file
348 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
351 ###################################
352 if [ -n "$do_asv2" ] ; then
354 file=${outfile}asv2.avi
355 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv2 $file
358 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
361 ###################################
362 if [ -n "$do_flv" ] ; then
364 file=${outfile}flv.flv
365 do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec flv $file
368 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
371 ###################################
372 if [ -n "$do_ffv1" ] ; then
374 file=${outfile}ffv1.avi
375 do_ffmpeg $file -y -strict -1 -f pgmyuv -i $raw_src -an -vcodec ffv1 $file
378 do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
381 ###################################
382 if [ -n "$do_mp2" ] ; then
384 file=${outfile}mp2.mp2
385 do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file
388 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
391 ###################################
392 if [ -n "$do_ac3" ] ; then
394 file=${outfile}ac3.rm
395 do_ffmpeg $file -y -ab 128 -ac 2 -f s16le -i $pcm_src -vn $file
398 #do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
401 ###################################
402 if [ -n "$do_g726" ] ; then
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
408 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
411 ###################################
412 if [ -n "$do_adpcm_ima_wav" ] ; then
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
418 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
421 ###################################
422 if [ -n "$do_adpcm_ms" ] ; then
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
428 do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
431 ###################################
433 ###################################
435 if [ -n "$do_libav" ] ; then
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
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
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
451 #do_ffmpeg_crc $file -i $file
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
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
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
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
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
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
483 # XXX: need mpegts tests (add bitstreams or add output capability in ffmpeg)
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
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
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
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
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
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
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
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
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
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
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
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
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
558 # pix_fmt conversions
559 conversions="yuv420p yuv422p yuv444p yuv422 yuv410p yuv411p yuvj420p \
560 yuvj422p yuvj444p rgb24 bgr24 rgba32 rgb565 rgb555 gray monow \
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
574 if $diff_cmd $logfile $reffile ; then
576 echo Regression test succeeded.
580 echo Regression test: Error.