Last active
May 19, 2016 10:45
-
-
Save marianposaceanu/bbdd7794bbeec036fae67c9b120d2786 to your computer and use it in GitHub Desktop.
Convert videos to H.264 mkv easily (using ffmpeg)
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
# _ _ _ | |
# | | (_)| | | |
# _ __ ___ | | ____ __ ______ _ | |_ | |
# | '_ ` _ \ | |/ /\ \ / /|______|| || __| | |
# | | | | | || < \ V / | || |_ | |
# |_| |_| |_||_|\_\ \_/ |_| \__| | |
# | |
# Simple script to convert your old video files to H.264 mantaining their quality | |
# | |
# Usage: | |
# ruby mkvit.rb [extension] | |
# this will convert all the videos with the provided ext. in the current dir | |
# | |
# Notes: | |
# uses: https://trac.ffmpeg.org/wiki/Encode/H.264 | |
# | |
ext = ARGV[0] | |
files_to_convert = Dir["*.#{ext}"] | |
files_to_convert.each do |file_name| | |
puts "Started encoding to h264 #{file_name}" | |
output = `ffmpeg -i "#{file_name}" -c:v libx264 -preset slow -crf 22 -c:a copy "#{file_name.gsub(/\.(.*)/, '.mkv')}"` | |
puts output | |
puts "File encoded" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment