Created
April 27, 2012 21:57
-
-
Save manuelmorales/2513709 to your computer and use it in GitHub Desktop.
Reencode audio of an AVI to MP3
This file contains hidden or 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
#!/usr/bin/ruby | |
ARGV.each do |input_f| | |
everything_ok = true | |
# Escapes single quotes | |
input_f = input_f.split("'").join("\'\\'\'") | |
# Extracts the file name without extension | |
file_name = input_f.split(".")[0..-2].join(".") | |
# Output file | |
output_f = file_name + ".mp3.avi" | |
puts "\nConverting \'#{input_f}\' into \'#{output_f}\':" | |
command = "ffmpeg -i '#{input_f}' -ac 2 -ab 192 -vcodec copy -acodec libmp3lame '#{output_f}'" # -t 20 | |
puts command | |
everything_ok = system command | |
if !everything_ok | |
puts "There were errors encoding #{input_f}, aborting." | |
break | |
end | |
puts "File succesfully encoded as \'#{output_f}\'" if everything_ok | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment