summaryrefslogtreecommitdiff
path: root/localvideowebencode
blob: 65b83847906c48117b96c3bf95ee57758c5e3ca3 (plain)
  1. #!/bin/sh
  2. # Origin: http://diveintohtml5.org/video.html
  3. # See also: http://camendesign.com/code/video_for_everybody
  4. set -e
  5. # input filename (mandatory)
  6. infile="$1"; shift
  7. filebase=$(echo "$infile" | perl -pe 's/\.[^.]*//')
  8. # output size in WIDTHxHEIGHT (optional, default: 320x200)
  9. size=${1:-320x200}
  10. width=$(echo "$size" | perl -pe 's/[^x]*x//')
  11. height=$(echo "$size" | perl -pe 's/x[^x]*//')
  12. ## Theora/Vorbis/Ogg
  13. ffmpeg2theora --videobitrate 200 --max_size "$size" --output "$filebase.ogv" "$infile"
  14. ## H.264/AAC/MP4
  15. #HandBrakeCLI --preset "iPhone & iPod Touch" --vb 200 ${width:+--width "$width"} --two-pass --turbo --optimize --input "$infile" --output "$filebase.mp4"
  16. HandBrakeCLI --preset "iPhone & iPod Touch" --vb 200 ${width:+--maxWidth "$width"} ${height:+--maxHeight "$height"} --two-pass --turbo --optimize --input "$infile" --output "$filebase.mp4"
  17. ## VP8/Vorbis/WebM
  18. ffmpeg -pass 1 -passlogfile "$infile" -threads 16 -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -i "$infile" -vcodec libvpx -b 204800 -s "$size" -aspect 4:3 -an -f webm -y NUL
  19. ffmpeg -pass 2 -passlogfile "$infile" -threads 16 -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -i "$infile" -vcodec libvpx -b 204800 -s "$size" -aspect 4:3 -acodec libvorbis -ac 2 -y "$filebase.webm"
  20. cat >"$filebase.html" <<EOF
  21. <video id="movie" width="$width" height="$height" preload controls>
  22. <source src="$filebase.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
  23. <source src="$filebase.webm" type='video/webm; codecs="vp8, vorbis"' />
  24. <source src="$filebase.ogv" type='video/ogg; codecs="theora, vorbis"' />
  25. <object width="$width" height="$height" type="application/x-shockwave-flash"
  26. data="flowplayer-3.2.1.swf">
  27. <param name="movie" value="flowplayer-3.2.1.swf" />
  28. <param name="allowfullscreen" value="true" />
  29. <param name="flashvars" value='config={"clip": {"url": "http://wearehugh.com/dih5/good/bbb_480p.mp4", "autoPlay":false, "autoBuffering":true}}' />
  30. <p>Download video as <a href="$filebase.mp4">MP4</a>, <a href="$filebase.webm">WebM</a>, or <a href="$filebase.ogv">Ogg</a>.</p>
  31. </object>
  32. </video>
  33. EOF