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.

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