summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2010-09-02 17:59:43 +0200
committerJonas Smedegaard <dr@jones.dk>2010-09-02 17:59:43 +0200
commit8440867cc4fcbe371f9868cf76c9be213a334a4c (patch)
treeb4a8d9c97e95568c0b218f367dd3801f86315640
parentaa95dd51dc1ca1f3bbada79053c886e092ca8488 (diff)
Misc. improvements to localvideowebencode.
-rwxr-xr-xlocalvideowebencode47
1 files changed, 30 insertions, 17 deletions
diff --git a/localvideowebencode b/localvideowebencode
index 65b8384..5b4d429 100755
--- a/localvideowebencode
+++ b/localvideowebencode
@@ -1,7 +1,8 @@
#!/bin/sh
-# Origin: http://diveintohtml5.org/video.html
-# See also: http://camendesign.com/code/video_for_everybody
+# Origins:
+# http://diveintohtml5.org/video.html
+# http://camendesign.com/code/video_for_everybody
set -e
@@ -13,29 +14,41 @@ filebase=$(echo "$infile" | perl -pe 's/\.[^.]*//')
size=${1:-320x200}
width=$(echo "$size" | perl -pe 's/[^x]*x//')
height=$(echo "$size" | perl -pe 's/x[^x]*//')
+heightplus=${height:+$(($height+4))}
## Theora/Vorbis/Ogg
ffmpeg2theora --videobitrate 200 --max_size "$size" --output "$filebase.ogv" "$infile"
## H.264/AAC/MP4
-#HandBrakeCLI --preset "iPhone & iPod Touch" --vb 200 ${width:+--width "$width"} --two-pass --turbo --optimize --input "$infile" --output "$filebase.mp4"
HandBrakeCLI --preset "iPhone & iPod Touch" --vb 200 ${width:+--maxWidth "$width"} ${height:+--maxHeight "$height"} --two-pass --turbo --optimize --input "$infile" --output "$filebase.mp4"
## VP8/Vorbis/WebM
-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
-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"
+! ffmpeg -codecs | grep -iw vp8 || webm=yes
+[ -z "$webm" ] || 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
+[ -z "$webm" ] || 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"
+
+## JPEG preview
+ffmpegthumbnailer -s0 -i "$filebase.ogv" -o "$filebase.jpg"
+
+## TODO: resolve flash player to use
+[ -z "$flashplayer" ] || flash=yes
cat >"$filebase.html" <<EOF
-<video id="movie" width="$width" height="$height" preload controls>
- <source src="$filebase.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
- <source src="$filebase.webm" type='video/webm; codecs="vp8, vorbis"' />
- <source src="$filebase.ogv" type='video/ogg; codecs="theora, vorbis"' />
- <object width="$width" height="$height" type="application/x-shockwave-flash"
- data="flowplayer-3.2.1.swf">
- <param name="movie" value="flowplayer-3.2.1.swf" />
- <param name="allowfullscreen" value="true" />
- <param name="flashvars" value='config={"clip": {"url": "http://wearehugh.com/dih5/good/bbb_480p.mp4", "autoPlay":false, "autoBuffering":true}}' />
- <p>Download video as <a href="$filebase.mp4">MP4</a>, <a href="$filebase.webm">WebM</a>, or <a href="$filebase.ogv">Ogg</a>.</p>
- </object>
-</video>
+<!-- Video for Everybody, Kroc Camen of Camen Design -->
+<video width="$width" height="$height" preload controls>
+<source src="$filebase.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
+<source src="$filebase.ogv" type='video/ogg; codecs="theora, vorbis"' />
+${webm:+<source src="$filebase.webm" type='video/webm; codecs="vp8, vorbis"' />
+}${flash:+<object width="$width" height="$heightplus" type="application/x-shockwave-flash" data="$flashplayer.swf">
+<param name="movie" value="$flashplayer.swf" />
+<param name="flashvars" value="image=$filebase.jpg&amp;file=$filebase.mp4" />
+}<img src="$filebase.jpg" width="$width" height="$height" ${title:+alt="$title"}
+ title="No video playback capabilities, please download the video below" />
+${flash:+</object>
+}</video>
+<p><strong>Download Video:</strong>
+open classic Format:<a href="$filebase.ogv">"Ogg"</a>,
+${webm:+open modern Format:<a href="$filebase.webm">"WebM"</a>,}
+closed Format:<a href="$filebase.mp4">"MP4"</a>.
+</p>
EOF