Skip to content

Instantly share code, notes, and snippets.

@soffes
Created September 4, 2012 05:01
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save soffes/3616772 to your computer and use it in GitHub Desktop.
Save soffes/3616772 to your computer and use it in GitHub Desktop.
#
# Refactor.tv Convert
#
# Before running, you will need to install FFMPEG with libvorbis and libvpx (for WebM)
# $ brew install ffmpeg --with-libvorbis --with-libvpx
#
# Now run the following to get started:
# $ ruby convert.rb Episode003-master.mov 003
#
input = ARGV[0]
episode = ARGV[1]
unless input and episode
puts 'Usage: ruby convert.rb Episode003-master.mov 003'
exit
end
# Config
threads = 4
qmin = 10
qmax = 63
# MP4 SD
output = "Episode#{episode}-480.mp4"
unless File.exist?(output)
`ffmpeg -threads #{threads} -i #{input} -i_qfactor 0.71 -qcomp 0.6 -qmin #{qmin} -qmax #{qmax} -qdiff 4 -trellis 0 -vcodec libx264 -s 640x480 -b:v 1000k -b:a 56k -ar 22050 #{output}`
end
# MP4 HD
output = "Episode#{episode}-720.mp4"
unless File.exist?(output)
`ffmpeg -threads #{threads} -i #{input} -i_qfactor 0.71 -qcomp 0.6 -qmin #{qmin} -qmax #{qmax} -qdiff 4 -trellis 0 -vcodec libx264 -s 1280x720 -b:v 1000k -b:a 56k -ar 22050 #{output}`
end
# WebM SD
output = "Episode#{episode}-480.webm"
unless File.exist?(output)
`ffmpeg -threads #{threads} -i #{input} -keyint_min 0 -g 250 -skip_threshold 0 -qmin #{qmin} -qmax #{qmax} -vcodec libvpx -b 614400 -s 640x480 -aspect 16:9 -acodec libvorbis -y #{output}`
end
# WebM HD
output = "Episode#{episode}-720.webm"
unless File.exist?(output)
`ffmpeg -threads #{threads} -i #{input} -keyint_min 0 -g 250 -skip_threshold 0 -qmin #{qmin} -qmax #{qmax} -vcodec libvpx -b 614400 -s 1280x720 -aspect 16:9 -acodec libvorbis -y #{output}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment