Created
November 16, 2010 05:53
-
-
Save cjheath/701496 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :video do | |
desc "Create a bunch of sent messages to test reporting & analytics, with random contacts" | |
task :transcode do | |
Dir["*.mov"].each do |mov| | |
# REVISIT: Get width and height from the video: | |
width = 568 | |
height = 386 | |
ogv = mov.sub(%r{.mov}i, '.ogv') | |
if !FileTest.exists?(ogv) || File.mtime(mov) >= File.mtime(ogv) | |
system "ffmpeg2theora --videoquality 5 --audioquality 1 --max_size #{width}x#{height} #{mov}" | |
end | |
mp4 = mov.sub(%r{.mov}i, '.mp4') | |
if !FileTest.exists?(mp4) || File.mtime(mov) >= File.mtime(mp4) | |
# 400kbps is about what my first screencast used in QuickTime format. Halve it, this codec is better (I hope) | |
system "HandBrakeCLI --preset 'iPhone & iPod Touch' --width #{width} --vb 200 --two-pass --turbo --input #{mov} --output #{mp4}" | |
end | |
webm = mov.sub(%r{.mov}i, '.webm') | |
if !FileTest.exists?(webm) || File.mtime(mov) >= File.mtime(webm) | |
system %Q{ | |
(ffmpeg -pass 1 -passlogfile #{mp4} -threads 16 -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -i #{mp4} -vcodec libvpx -b 409600 -s #{width}x#{height} -aspect 4:3 -an -y -f webm /dev/null && \ | |
ffmpeg -pass 2 -passlogfile #{mp4} -threads 16 -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -i #{mp4} -vcodec libvpx -b 409600 -s #{width}x#{height} -aspect 4:3 -acodec libvorbis -y -f webm #{webm}) || \ | |
rm #{webm} | |
} | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment