-
-
Save florianbachmann/3618023 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
input = ARGV[0] | |
episode = ARGV[1] | |
unless input and episode | |
puts 'Usage: convert.rb Episode003-master.mov 003' | |
exit | |
end | |
# Config | |
threads = 4 | |
qmin = 10 | |
qmax = 63 | |
poster_seconds = 3 | |
# Site Poster | |
output = "Episode#{episode}-360-poster.jpg" | |
unless File.exist?(output) | |
`ffmpeg -y -i #{input} -f mjpeg -vframes 1 -ss #{poster_seconds} -s 640x360 #{output}` | |
end | |
# SD Poster | |
output = "Episode#{episode}-480-poster.jpg" | |
unless File.exist?(output) | |
`ffmpeg -y -i #{input} -f mjpeg -vframes 1 -ss #{poster_seconds} -s 853x480 #{output}` | |
end | |
# HD Poster | |
output = "Episode#{episode}-720-poster.jpg" | |
unless File.exist?(output) | |
`ffmpeg -y -i #{input} -f mjpeg -vframes 1 -ss #{poster_seconds} -s 1280x720 #{output}` | |
end | |
# TODO: MP3 | |
# 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 | |
# 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 | |
# 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 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