Statistics
| Branch: | Revision:

ffmpeg / tests / regression.sh @ 83dddc4a

History | View | Annotate | Download (12.7 KB)

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
elif [ "$1" = "ac3" ] ; then
28
    do_ac3=y
29
elif [ "$1" = "libavtest" ] ; then
30
    do_libav=y
31
    logfile="$datadir/libav.regression"
32
    outfile="$datadir/b-"
33
else
34
    do_mpeg=y
35
    do_mpeg2=y
36
    do_msmpeg4v2=y
37
    do_msmpeg4=y
38
    do_wmv1=y
39
    do_wmv2=y
40
    do_h263=y
41
    do_h263p=y
42
    do_mpeg4=y
43
    do_huffyuv=y
44
    do_mjpeg=y
45
    do_ljpeg=y
46
    do_rv10=y
47
    do_mp2=y
48
    do_ac3=y
49
    do_rc=y
50
    do_mpeg4adv=y
51
    do_mpeg1b=y
52
    do_asv1=y
53
    do_asv2=y
54
    do_flv=y
55
    do_ffv1=y
56
fi
57

    
58

    
59
# various files
60
ffmpeg="../ffmpeg_g"
61
tiny_psnr="./tiny_psnr"
62
reffile="$2"
63
benchfile="$datadir/ffmpeg.bench"
64
raw_src="$3/%d.pgm"
65
raw_dst="$datadir/out.yuv"
66
raw_ref="$datadir/ref.yuv"
67
pcm_src="asynth1.sw"
68
pcm_dst="$datadir/out.wav"
69

    
70
# create the data directory if it does not exists
71
mkdir -p $datadir
72

    
73
do_ffmpeg()
74
{
75
    f="$1"
76
    shift
77
    echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $*
78
    $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp 2> /tmp/ffmpeg$$
79
    egrep -v "^(Stream|Press|Input|Output|frame|  Stream|  Duration)" /tmp/ffmpeg$$ || true
80
    rm -f /tmp/ffmpeg$$
81
    md5sum -b $f >> $logfile
82
    if [ $f = $raw_dst ] ; then
83
        $tiny_psnr $f $raw_ref >> $logfile
84
    fi
85
    expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
86
    echo `cat $datadir/bench2.tmp` $f >> $benchfile
87
}
88

    
89
do_ffmpeg_crc()
90
{
91
    f="$1"
92
    shift
93
    echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
94
    $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc > /tmp/ffmpeg$$ 2>&1
95
    egrep -v "^(Stream|Press|Input|Output|frame|  Stream|  Duration)" /tmp/ffmpeg$$ || true
96
    rm -f /tmp/ffmpeg$$ 
97
    echo "$f `cat $datadir/ffmpeg.crc`" >> $logfile
98
}
99

    
100
do_ffmpeg_nocheck()
101
{
102
    f="$1"
103
    shift
104
    echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $*
105
    $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp 2> /tmp/ffmpeg$$
106
    egrep -v "^(Stream|Press|Input|Output|frame|  Stream|  Duration)" /tmp/ffmpeg$$ || true
107
    rm -f /tmp/ffmpeg$$
108
    expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
109
    echo `cat $datadir/bench2.tmp` $f >> $benchfile
110
}
111

    
112
echo "ffmpeg regression test" > $logfile
113
echo "ffmpeg benchmarks" > $benchfile
114

    
115
###################################
116
# generate reference for quality check
117
do_ffmpeg_nocheck $raw_ref -y -f pgmyuv -i $raw_src -an -f rawvideo $raw_ref
118

    
119
###################################
120
if [ -n "$do_mpeg" ] ; then
121
# mpeg1 encoding
122
file=${outfile}mpeg1.mpg
123
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpeg1video $file 
124

    
125
# mpeg1 decoding
126
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
127
fi
128

    
129
###################################
130
if [ -n "$do_mpeg2" ] ; then
131
# mpeg2 encoding
132
file=${outfile}mpeg2.mpg
133
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video $file 
134

    
135
# mpeg2 decoding
136
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
137

    
138
# mpeg2 encoding interlaced
139
file=${outfile}mpeg2i.mpg
140
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video -interlace $file 
141

    
142
# mpeg2 decoding
143
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
144
fi
145

    
146
###################################
147
if [ -n "$do_msmpeg4v2" ] ; then
148
# msmpeg4 encoding
149
file=${outfile}msmpeg4v2.avi
150
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4v2 $file
151

    
152
# msmpeg4v2 decoding
153
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
154
fi
155

    
156
###################################
157
if [ -n "$do_msmpeg4" ] ; then
158
# msmpeg4 encoding
159
file=${outfile}msmpeg4.avi
160
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
161

    
162
# msmpeg4 decoding
163
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
164
fi
165

    
166
###################################
167
if [ -n "$do_wmv1" ] ; then
168
# wmv1 encoding
169
file=${outfile}wmv1.avi
170
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv1 $file
171

    
172
# wmv1 decoding
173
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
174
fi
175

    
176
###################################
177
if [ -n "$do_wmv2" ] ; then
178
# wmv2 encoding
179
file=${outfile}wmv2.avi
180
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv2 $file
181

    
182
# wmv2 decoding
183
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
184
fi
185

    
186
###################################
187
if [ -n "$do_h263" ] ; then
188
# h263 encoding
189
file=${outfile}h263.avi
190
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
191

    
192
# h263 decoding
193
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
194
fi
195

    
196
###################################
197
if [ -n "$do_h263p" ] ; then
198
# h263p encoding
199
file=${outfile}h263p.avi
200
do_ffmpeg $file -y -qscale 2 -umv -aiv -aic -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263p -ps 300 $file
201

    
202
# h263p decoding
203
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
204
fi
205

    
206
###################################
207
if [ -n "$do_mpeg4" ] ; then
208
# mpeg4
209
file=${outfile}odivx.mp4
210
do_ffmpeg $file -y -4mv -hq -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
211

    
212
# mpeg4 decoding
213
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
214
fi
215

    
216
###################################
217
if [ -n "$do_huffyuv" ] ; then
218
# huffyuv
219
file=${outfile}huffyuv.avi
220
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec huffyuv -strict -1 $file
221

    
222
# huffyuv decoding
223
do_ffmpeg $raw_dst -y -i $file -f rawvideo -strict -1 $raw_dst
224
fi
225

    
226
###################################
227
if [ -n "$do_rc" ] ; then
228
# mpeg4 rate control
229
file=${outfile}mpeg4-rc.avi
230
do_ffmpeg $file -y -b 400 -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
231

    
232
# mpeg4 rate control decoding
233
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
234
fi
235

    
236
###################################
237
if [ -n "$do_mpeg4adv" ] ; then
238
# mpeg4
239
file=${outfile}mpeg4-adv.avi
240
do_ffmpeg $file -y -qscale 9 -4mv -hq -part -ps 200 -aic -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
241

    
242
# mpeg4 decoding
243
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
244
fi
245

    
246
###################################
247
if [ -n "$do_mpeg1b" ] ; then
248
# mpeg1
249
file=${outfile}mpeg1b.mpg
250
do_ffmpeg $file -y -qscale 8 -bf 3 -ps 200 -f pgmyuv -i $raw_src -an -vcodec mpeg1video -f mpeg1video $file
251

    
252
# mpeg1 decoding
253
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
254
fi
255

    
256
###################################
257
if [ -n "$do_mjpeg" ] ; then
258
# mjpeg
259
file=${outfile}mjpeg.avi
260
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
261

    
262
# mjpeg decoding
263
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
264
fi
265

    
266
###################################
267
if [ -n "$do_ljpeg" ] ; then
268
# ljpeg
269
file=${outfile}ljpeg.avi
270
do_ffmpeg $file -y -f pgmyuv -i $raw_src -an -vcodec ljpeg $file
271

    
272
# ljpeg decoding
273
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
274
fi
275

    
276
###################################
277
if [ -n "$do_rv10" ] ; then
278
# rv10 encoding
279
file=${outfile}rv10.rm
280
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file 
281

    
282
# rv10 decoding
283
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
284
fi
285

    
286
###################################
287
if [ -n "$do_asv1" ] ; then
288
# asv1 encoding
289
file=${outfile}asv1.avi
290
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv1 $file
291

    
292
# asv1 decoding
293
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
294
fi
295

    
296
###################################
297
if [ -n "$do_asv2" ] ; then
298
# asv2 encoding
299
file=${outfile}asv2.avi
300
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv2 $file
301

    
302
# asv2 decoding
303
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
304
fi
305

    
306
###################################
307
if [ -n "$do_flv" ] ; then
308
# flv encoding
309
file=${outfile}flv.flv
310
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec flv $file
311

    
312
# flv decoding
313
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
314
fi
315

    
316
###################################
317
if [ -n "$do_ffv1" ] ; then
318
# ffv1 encoding
319
file=${outfile}ffv1.avi
320
do_ffmpeg $file -y -strict -1 -f pgmyuv -i $raw_src -an -vcodec ffv1 $file
321

    
322
# ffv1 decoding
323
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
324
fi
325

    
326
###################################
327
if [ -n "$do_mp2" ] ; then
328
# mp2 encoding
329
file=${outfile}mp2.mp2
330
do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file 
331

    
332
# mp2 decoding
333
do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst 
334
fi
335

    
336
###################################
337
if [ -n "$do_ac3" ] ; then
338
# ac3 encoding
339
file=${outfile}ac3.rm
340
do_ffmpeg $file -y -ab 128 -ac 2 -f s16le  -i $pcm_src -vn $file 
341

    
342
# ac3 decoding
343
#do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst 
344
fi
345

    
346
###################################
347
# libav testing
348
###################################
349

    
350
if [ -n "$do_libav" ] ; then
351

    
352
# avi
353
file=${outfile}libav.avi
354
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
355
do_ffmpeg_crc $file -i $file
356

    
357
# asf
358
file=${outfile}libav.asf
359
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
360
do_ffmpeg_crc $file -i $file
361

    
362
# rm
363
file=${outfile}libav.rm
364
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
365
# broken
366
#do_ffmpeg_crc $file -i $file
367

    
368
# mpegps
369
file=${outfile}libav.mpg
370
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
371
do_ffmpeg_crc $file -i $file
372

    
373
# swf (decode audio only)
374
file=${outfile}libav.swf
375
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
376
do_ffmpeg_crc $file -i $file
377

    
378
# ffm
379
file=${outfile}libav.ffm
380
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
381
do_ffmpeg_crc $file -i $file
382

    
383
# flv
384
file=${outfile}libav.flv
385
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
386
do_ffmpeg_crc $file -i $file
387

    
388
# mov
389
#file=${outfile}libav.mov
390
#do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
391
#do_ffmpeg_crc $file -i $file
392

    
393
# nut
394
file=${outfile}libav.nut
395
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
396
do_ffmpeg_crc $file -i $file
397

    
398
# XXX: need mpegts tests (add bitstreams or add output capability in ffmpeg)
399

    
400
####################
401
# streamed images
402
# mjpeg
403
#file=${outfile}libav.mjpeg
404
#do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
405
#do_ffmpeg_crc $file -i $file
406

    
407
# pbmpipe
408
file=${outfile}libav.pbm
409
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
410
do_ffmpeg_crc $file -f imagepipe -i $file
411

    
412
# pgmpipe
413
file=${outfile}libav.pgm
414
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
415
do_ffmpeg_crc $file -f imagepipe -i $file
416

    
417
# ppmpipe
418
file=${outfile}libav.ppm
419
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
420
do_ffmpeg_crc $file -f imagepipe -i $file
421

    
422
# gif
423
file=${outfile}libav.gif
424
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
425
#do_ffmpeg_crc $file -i $file
426

    
427
# yuv4mpeg
428
file=${outfile}libav.yuv4mpeg
429
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
430
#do_ffmpeg_crc $file -i $file
431

    
432
####################
433
# image formats
434
# pgm (we do not do md5 on image files yet)
435
file=${outfile}libav%d.pgm
436
$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
437
do_ffmpeg_crc $file -i $file
438

    
439
# ppm (we do not do md5 on image files yet)
440
file=${outfile}libav%d.ppm
441
$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
442
do_ffmpeg_crc $file -i $file
443

    
444
# jpeg (we do not do md5 on image files yet)
445
#file=${outfile}libav%d.jpg
446
#$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
447
#do_ffmpeg_crc $file -i $file
448

    
449
####################
450
# audio only
451

    
452
# wav
453
file=${outfile}libav.wav
454
do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
455
do_ffmpeg_crc $file -i $file
456

    
457
# alaw
458
file=${outfile}libav.al
459
do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
460
do_ffmpeg_crc $file -i $file
461

    
462
# mulaw
463
file=${outfile}libav.ul
464
do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
465
do_ffmpeg_crc $file -i $file
466

    
467
# au
468
file=${outfile}libav.au
469
do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
470
do_ffmpeg_crc $file -i $file
471

    
472
####################
473
# pix_fmt conversions
474
conversions="yuv420p yuv422p yuv444p yuv422 yuv410p yuv411p yuvj420p \
475
             yuvj422p yuvj444p rgb24 bgr24 rgba32 rgb565 rgb555 gray monow \
476
	     monob pal8"
477
for pix_fmt in $conversions ; do
478
    file=${outfile}libav-${pix_fmt}.yuv
479
    do_ffmpeg_nocheck $file -r 1 -t 1 -y -f pgmyuv -i $raw_src \
480
                            -f rawvideo -s 352x288 -pix_fmt $pix_fmt $raw_dst
481
    do_ffmpeg $file -f rawvideo -s 352x288 -pix_fmt $pix_fmt -i $raw_dst \
482
                    -f rawvideo -s 352x288 -pix_fmt yuv444p $file
483
done
484

    
485
fi
486

    
487

    
488

    
489
if $diff_cmd $logfile $reffile ; then
490
    echo 
491
    echo Regression test succeeded.
492
    exit 0
493
else
494
    echo 
495
    echo Regression test: Error.
496
    exit 1
497
fi