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.

312 lines
7.4KB

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