Statistics
| Branch: | Revision:

ffmpeg / tests / regression.sh @ 28c70622

History | View | Annotate | Download (12.4 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.vob
133
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video $file 
134

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

    
139
###################################
140
if [ -n "$do_msmpeg4v2" ] ; then
141
# msmpeg4 encoding
142
file=${outfile}msmpeg4v2.avi
143
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4v2 $file
144

    
145
# msmpeg4v2 decoding
146
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
147
fi
148

    
149
###################################
150
if [ -n "$do_msmpeg4" ] ; then
151
# msmpeg4 encoding
152
file=${outfile}msmpeg4.avi
153
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
154

    
155
# msmpeg4 decoding
156
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
157
fi
158

    
159
###################################
160
if [ -n "$do_wmv1" ] ; then
161
# wmv1 encoding
162
file=${outfile}wmv1.avi
163
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv1 $file
164

    
165
# wmv1 decoding
166
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
167
fi
168

    
169
###################################
170
if [ -n "$do_wmv2" ] ; then
171
# wmv2 encoding
172
file=${outfile}wmv2.avi
173
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv2 $file
174

    
175
# wmv2 decoding
176
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
177
fi
178

    
179
###################################
180
if [ -n "$do_h263" ] ; then
181
# h263 encoding
182
file=${outfile}h263.avi
183
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
184

    
185
# h263 decoding
186
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
187
fi
188

    
189
###################################
190
if [ -n "$do_h263p" ] ; then
191
# h263p encoding
192
file=${outfile}h263p.avi
193
do_ffmpeg $file -y -qscale 2 -umv -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263p -ps 300 $file
194

    
195
# h263p decoding
196
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
197
fi
198

    
199
###################################
200
if [ -n "$do_mpeg4" ] ; then
201
# mpeg4
202
file=${outfile}odivx.mp4
203
do_ffmpeg $file -y -4mv -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
204

    
205
# mpeg4 decoding
206
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
207
fi
208

    
209
###################################
210
if [ -n "$do_huffyuv" ] ; then
211
# huffyuv
212
file=${outfile}huffyuv.avi
213
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec huffyuv -strict -1 $file
214

    
215
# huffyuv decoding
216
do_ffmpeg $raw_dst -y -i $file -f rawvideo -strict -1 $raw_dst
217
fi
218

    
219
###################################
220
if [ -n "$do_rc" ] ; then
221
# mpeg4 rate control
222
file=${outfile}mpeg4-rc.avi
223
do_ffmpeg $file -y -b 400 -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
224

    
225
# mpeg4 rate control decoding
226
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
227
fi
228

    
229
###################################
230
if [ -n "$do_mpeg4adv" ] ; then
231
# mpeg4
232
file=${outfile}mpeg4-adv.avi
233
do_ffmpeg $file -y -qscale 9 -4mv -hq -part -ps 200 -aic -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
234

    
235
# mpeg4 decoding
236
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
237
fi
238

    
239
###################################
240
if [ -n "$do_mpeg1b" ] ; then
241
# mpeg1
242
file=${outfile}mpeg1b.mpg
243
do_ffmpeg $file -y -qscale 8 -bf 3 -ps 200 -f pgmyuv -i $raw_src -an -vcodec mpeg1video $file
244

    
245
# mpeg1 decoding
246
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
247
fi
248

    
249
###################################
250
if [ -n "$do_mjpeg" ] ; then
251
# mjpeg
252
file=${outfile}mjpeg.avi
253
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
254

    
255
# mjpeg decoding
256
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
257
fi
258

    
259
###################################
260
if [ -n "$do_ljpeg" ] ; then
261
# ljpeg
262
file=${outfile}ljpeg.avi
263
do_ffmpeg $file -y -f pgmyuv -i $raw_src -an -vcodec ljpeg $file
264

    
265
# ljpeg decoding
266
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
267
fi
268

    
269
###################################
270
if [ -n "$do_rv10" ] ; then
271
# rv10 encoding
272
file=${outfile}rv10.rm
273
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file 
274

    
275
# rv10 decoding
276
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
277
fi
278

    
279
###################################
280
if [ -n "$do_asv1" ] ; then
281
# asv1 encoding
282
file=${outfile}asv1.avi
283
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv1 $file
284

    
285
# asv1 decoding
286
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
287
fi
288

    
289
###################################
290
if [ -n "$do_asv2" ] ; then
291
# asv2 encoding
292
file=${outfile}asv2.avi
293
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec asv2 $file
294

    
295
# asv2 decoding
296
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
297
fi
298

    
299
###################################
300
if [ -n "$do_flv" ] ; then
301
# flv encoding
302
file=${outfile}flv.flv
303
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec flv $file
304

    
305
# flv decoding
306
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
307
fi
308

    
309
###################################
310
if [ -n "$do_ffv1" ] ; then
311
# ffv1 encoding
312
file=${outfile}ffv1.avi
313
do_ffmpeg $file -y -strict -1 -f pgmyuv -i $raw_src -an -vcodec ffv1 $file
314

    
315
# ffv1 decoding
316
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst 
317
fi
318

    
319
###################################
320
if [ -n "$do_mp2" ] ; then
321
# mp2 encoding
322
file=${outfile}mp2.mp2
323
do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file 
324

    
325
# mp2 decoding
326
do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst 
327
fi
328

    
329
###################################
330
if [ -n "$do_ac3" ] ; then
331
# ac3 encoding
332
file=${outfile}ac3.rm
333
do_ffmpeg $file -y -ab 128 -ac 2 -f s16le  -i $pcm_src -vn $file 
334

    
335
# ac3 decoding
336
#do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst 
337
fi
338

    
339
###################################
340
# libav testing
341
###################################
342

    
343
if [ -n "$do_libav" ] ; then
344

    
345
# avi
346
file=${outfile}libav.avi
347
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
348
do_ffmpeg_crc $file -i $file
349

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

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

    
361
# mpegps
362
file=${outfile}libav.mpg
363
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
364
do_ffmpeg_crc $file -i $file
365

    
366
# swf (decode audio only)
367
file=${outfile}libav.swf
368
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
369
do_ffmpeg_crc $file -i $file
370

    
371
# ffm
372
file=${outfile}libav.ffm
373
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
374
do_ffmpeg_crc $file -i $file
375

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

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

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

    
391
# XXX: need mpegts tests (add bitstreams or add output capability in ffmpeg)
392

    
393
####################
394
# streamed images
395
# mjpeg
396
#file=${outfile}libav.mjpeg
397
#do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
398
#do_ffmpeg_crc $file -i $file
399

    
400
# pbmpipe
401
file=${outfile}libav.pbm
402
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
403
do_ffmpeg_crc $file -f imagepipe -i $file
404

    
405
# pgmpipe
406
file=${outfile}libav.pgm
407
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
408
do_ffmpeg_crc $file -f imagepipe -i $file
409

    
410
# ppmpipe
411
file=${outfile}libav.ppm
412
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
413
do_ffmpeg_crc $file -f imagepipe -i $file
414

    
415
# gif
416
file=${outfile}libav.gif
417
do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
418
#do_ffmpeg_crc $file -i $file
419

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

    
425
####################
426
# image formats
427
# pgm (we do not do md5 on image files yet)
428
file=${outfile}libav%d.pgm
429
$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
430
do_ffmpeg_crc $file -i $file
431

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

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

    
442
####################
443
# audio only
444

    
445
# wav
446
file=${outfile}libav.wav
447
do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
448
do_ffmpeg_crc $file -i $file
449

    
450
# alaw
451
file=${outfile}libav.al
452
do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
453
do_ffmpeg_crc $file -i $file
454

    
455
# mulaw
456
file=${outfile}libav.ul
457
do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
458
do_ffmpeg_crc $file -i $file
459

    
460
# au
461
file=${outfile}libav.au
462
do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
463
do_ffmpeg_crc $file -i $file
464

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

    
478
fi
479

    
480

    
481

    
482
if $diff_cmd $logfile $reffile ; then
483
    echo 
484
    echo Regression test succeeded.
485
    exit 0
486
else
487
    echo 
488
    echo Regression test: Error.
489
    exit 1
490
fi