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.

268 lines
6.2KB

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