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.

368 lines
8.8KB

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