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.

261 lines
6.0KB

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