Skip to content

Instantly share code, notes, and snippets.

@paigeruten
Created April 18, 2014 14:22
Show Gist options
  • Save paigeruten/11046717 to your computer and use it in GitHub Desktop.
Save paigeruten/11046717 to your computer and use it in GitHub Desktop.
wrapper for a messy avconv command to concatenate audio files.
#!/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