Created
April 18, 2014 14:22
-
-
Save paigeruten/11046717 to your computer and use it in GitHub Desktop.
wrapper for a messy avconv command to concatenate audio files.
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
#!/usr/bin/env ruby | |
# | |
# Concatenates audio files together using avconv. | |
# | |
# Usage: avconcat -o <output> <inputs...> | |
# | |
output = nil | |
output_arg = false | |
files = ARGV.map do |arg| | |
if arg == "-o" | |
if output_arg | |
puts "Error: output file specified more than once!" | |
exit | |
else | |
output_arg = true | |
nil | |
end | |
elsif output_arg | |
output = arg | |
output_arg = false | |
nil | |
else | |
arg | |
end | |
end.compact | |
def usage | |
puts "Usage: avconcat -o <output> <inputs...>" | |
end | |
if output.nil? | |
puts "Error: no output specified." | |
usage | |
exit | |
elsif files.empty? | |
puts "Error: no inputs specified." | |
usage | |
exit | |
else | |
exec("avconv", "-i", "concat:" + files.join("|"), output) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment