You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

346 lines
8.3KB

  1. #!/bin/sh
  2. #
  3. # automatic regression test for ffmpeg
  4. #
  5. #
  6. #set -x
  7. set -e
  8. datadir="./data"
  9. logfile="$datadir/ffmpeg.regression"
  10. # tests to do
  11. if [ "$1" = "mpeg4" ] ; then
  12. do_mpeg4=y
  13. elif [ "$1" = "mpeg" ] ; then
  14. do_mpeg=y
  15. elif [ "$1" = "ac3" ] ; then
  16. do_ac3=y
  17. elif [ "$1" = "libavtest" ] ; then
  18. do_libav=y
  19. logfile="$datadir/libav.regression"
  20. else
  21. do_mpeg=y
  22. do_msmpeg4v2=y
  23. do_msmpeg4=y
  24. do_wmv1=y
  25. do_h263=y
  26. do_h263p=y
  27. do_mpeg4=y
  28. # do_huffyuv=y
  29. do_mjpeg=y
  30. do_rv10=y
  31. do_mp2=y
  32. do_ac3=y
  33. do_rc=y
  34. do_mpeg4adv=y
  35. fi
  36. # various files
  37. ffmpeg="../ffmpeg_g"
  38. outfile="$datadir/a-"
  39. reffile="$2"
  40. benchfile="$datadir/ffmpeg.bench"
  41. raw_src="vsynth1/%d.pgm"
  42. raw_dst="$datadir/out.yuv"
  43. pcm_src="asynth1.sw"
  44. pcm_dst="$datadir/out.wav"
  45. # create the data directory if it does not exists
  46. mkdir -p $datadir
  47. do_ffmpeg()
  48. {
  49. f="$1"
  50. shift
  51. echo $ffmpeg -bitexact -dct_algo 1 -idct_algo 2 $*
  52. $ffmpeg -bitexact -dct_algo 1 -idct_algo 2 -benchmark $* > $datadir/bench.tmp
  53. md5sum -b $f >> $logfile
  54. expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
  55. echo `cat $datadir/bench2.tmp` $f >> $benchfile
  56. }
  57. do_ffmpeg_crc()
  58. {
  59. f="$1"
  60. shift
  61. echo $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
  62. $ffmpeg -y -bitexact -dct_algo 1 -idct_algo 2 $* -f crc $datadir/ffmpeg.crc
  63. echo -n "$f " >> $logfile
  64. cat $datadir/ffmpeg.crc >> $logfile
  65. }
  66. echo "ffmpeg regression test" > $logfile
  67. echo "ffmpeg benchmarks" > $benchfile
  68. ###################################
  69. if [ -n "$do_mpeg" ] ; then
  70. # mpeg1 encoding
  71. file=${outfile}mpeg1.mpg
  72. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -f mpeg1video $file
  73. # mpeg1 decoding
  74. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  75. # mpeg2 decoding
  76. #do_ffmpeg /tmp/out-mpeg2.yuv -y -f mpegvideo -i a.vob \
  77. # -f rawvideo /tmp/out-mpeg2.yuv
  78. fi
  79. ###################################
  80. if [ -n "$do_msmpeg4v2" ] ; then
  81. # msmpeg4 encoding
  82. file=${outfile}msmpeg4v2.avi
  83. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4v2 $file
  84. # msmpeg4v2 decoding
  85. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  86. fi
  87. ###################################
  88. if [ -n "$do_msmpeg4" ] ; then
  89. # msmpeg4 encoding
  90. file=${outfile}msmpeg4.avi
  91. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec msmpeg4 $file
  92. # msmpeg4 decoding
  93. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  94. fi
  95. ###################################
  96. if [ -n "$do_wmv1" ] ; then
  97. # wmv1 encoding
  98. file=${outfile}wmv1.avi
  99. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec wmv1 $file
  100. # wmv1 decoding
  101. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  102. fi
  103. ###################################
  104. if [ -n "$do_h263" ] ; then
  105. # h263 encoding
  106. file=${outfile}h263.avi
  107. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263 $file
  108. # h263 decoding
  109. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  110. fi
  111. ###################################
  112. if [ -n "$do_h263p" ] ; then
  113. # h263p encoding
  114. file=${outfile}h263p.avi
  115. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -s 352x288 -an -vcodec h263p -ps 1000 $file
  116. # h263p decoding
  117. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  118. fi
  119. ###################################
  120. if [ -n "$do_mpeg4" ] ; then
  121. # mpeg4
  122. file=${outfile}odivx.avi
  123. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  124. # mpeg4 decoding
  125. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  126. fi
  127. ###################################
  128. if [ -n "$do_huffyuv" ] ; then
  129. # huffyuv
  130. file=${outfile}huffyuv.avi
  131. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec huffyuv -strict -1 $file
  132. # huffyuv decoding
  133. do_ffmpeg $raw_dst -y -i $file -f rawvideo -strict -1 $raw_dst
  134. fi
  135. ###################################
  136. if [ -n "$do_rc" ] ; then
  137. # mpeg4 rate control
  138. file=${outfile}mpeg4-rc.avi
  139. do_ffmpeg $file -y -b 400 -bf 2 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  140. # mpeg4 rate control decoding
  141. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  142. fi
  143. ###################################
  144. if [ -n "$do_mpeg4adv" ] ; then
  145. # mpeg4
  146. file=${outfile}mpeg4-adv.avi
  147. do_ffmpeg $file -y -qscale 9 -4mv -hq -part -ps 1000 -f pgmyuv -i $raw_src -an -vcodec mpeg4 $file
  148. # mpeg4 decoding
  149. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  150. fi
  151. ###################################
  152. if [ -n "$do_mjpeg" ] ; then
  153. # mjpeg
  154. file=${outfile}mjpeg.avi
  155. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
  156. # mjpeg decoding
  157. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  158. fi
  159. ###################################
  160. if [ -n "$do_rv10" ] ; then
  161. # rv10 encoding
  162. file=${outfile}rv10.rm
  163. do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an $file
  164. # rv10 decoding
  165. do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
  166. fi
  167. ###################################
  168. if [ -n "$do_mp2" ] ; then
  169. # mp2 encoding
  170. file=${outfile}mp2.mp2
  171. do_ffmpeg $file -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src $file
  172. # mp2 decoding
  173. do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
  174. fi
  175. ###################################
  176. if [ -n "$do_ac3" ] ; then
  177. # ac3 encoding
  178. file=${outfile}ac3.rm
  179. do_ffmpeg $file -y -ab 128 -ac 2 -f s16le -i $pcm_src -vn $file
  180. # ac3 decoding
  181. do_ffmpeg $pcm_dst -y -i $file -f wav $pcm_dst
  182. fi
  183. ###################################
  184. # libav testing
  185. ###################################
  186. if [ -n "$do_libav" ] ; then
  187. # avi
  188. file=${outfile}libav.avi
  189. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  190. do_ffmpeg_crc $file -i $file
  191. # asf
  192. file=${outfile}libav.asf
  193. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  194. do_ffmpeg_crc $file -i $file
  195. # rm
  196. file=${outfile}libav.rm
  197. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  198. # broken
  199. #do_ffmpeg_crc $file -i $file
  200. # mpegps
  201. file=${outfile}libav.mpg
  202. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  203. do_ffmpeg_crc $file -i $file
  204. # swf (decode audio only)
  205. file=${outfile}libav.swf
  206. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  207. do_ffmpeg_crc $file -i $file
  208. # ffm
  209. file=${outfile}libav.ffm
  210. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f s16le -i $pcm_src $file
  211. do_ffmpeg_crc $file -i $file
  212. # XXX: need mov and mpegts tests (add bitstreams or add output capability in ffmpeg)
  213. ####################
  214. # streamed images
  215. # mjpeg
  216. file=${outfile}libav.mjpeg
  217. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  218. do_ffmpeg_crc $file -i $file
  219. # pbmpipe
  220. file=${outfile}libav.pbm
  221. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  222. do_ffmpeg_crc $file -f imagepipe -i $file
  223. # pgmpipe
  224. file=${outfile}libav.pgm
  225. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  226. do_ffmpeg_crc $file -f imagepipe -i $file
  227. # ppmpipe
  228. file=${outfile}libav.ppm
  229. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src -f imagepipe $file
  230. do_ffmpeg_crc $file -f imagepipe -i $file
  231. # gif
  232. file=${outfile}libav.gif
  233. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  234. #do_ffmpeg_crc $file -i $file
  235. # yuv4mpeg
  236. file=${outfile}libav.yuv4mpeg
  237. do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
  238. #do_ffmpeg_crc $file -i $file
  239. ####################
  240. # image formats
  241. # pgm (we do not do md5 on image files yet)
  242. file=${outfile}libav%d.pgm
  243. $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  244. do_ffmpeg_crc $file -i $file
  245. # ppm (we do not do md5 on image files yet)
  246. file=${outfile}libav%d.ppm
  247. $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  248. do_ffmpeg_crc $file -i $file
  249. # jpeg (we do not do md5 on image files yet)
  250. file=${outfile}libav%d.jpg
  251. $ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $file
  252. do_ffmpeg_crc $file -i $file
  253. ####################
  254. # audio only
  255. # wav
  256. file=${outfile}libav.wav
  257. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  258. do_ffmpeg_crc $file -i $file
  259. # alaw
  260. file=${outfile}libav.al
  261. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  262. do_ffmpeg_crc $file -i $file
  263. # mulaw
  264. file=${outfile}libav.ul
  265. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  266. do_ffmpeg_crc $file -i $file
  267. # au
  268. file=${outfile}libav.au
  269. do_ffmpeg $file -t 1 -y -qscale 10 -f s16le -i $pcm_src $file
  270. do_ffmpeg_crc $file -i $file
  271. fi
  272. if diff -u $logfile $reffile ; then
  273. echo
  274. echo Regression test succeeded.
  275. exit 0
  276. else
  277. echo
  278. echo Regression test: Error.
  279. exit 1
  280. fi