Skip to content

Instantly share code, notes, and snippets.

@Ragmaanir
Created September 6, 2017 15:30
Show Gist options
  • Save Ragmaanir/9c9b7daa4b078b2a459153b6380e4f82 to your computer and use it in GitHub Desktop.
Save Ragmaanir/9c9b7daa4b078b2a459153b6380e4f82 to your computer and use it in GitHub Desktop.
LMMS/ffmpeg export script (crystal)
full_name = ARGV[0]
puts "Input: #{full_name}"
raise "Provide name without file extension or the mmpz file" if /\.(mp3|ogg|wav)\z/ === full_name
name = full_name.sub(/\.mmpz\z/, "")
puts "MP3: #{name}.mp3"
puts "OGG: #{name}.ogg"
# channel = Channel(String).new
o = STDOUT
lmms_args = [
"-r", "#{name}.mmpz",
"-o", "#{name}.wav",
"-b", "256",
"-i", "sincbest",
]
s = Process.run("lmms", lmms_args, output: o, error: o)
raise "export of #{name}.mmpz failed" if !s.success?
ffmpeg_args = [
"-i", "#{name}.wav",
"-ar", "44100",
"-ac", "2",
"-b:a", "256k",
]
p1 = Process.fork do
Process.run("ffmpeg", ffmpeg_args + ["#{name}.mp3"], output: o, error: o)
end
p2 = Process.fork do
Process.run("ffmpeg", ffmpeg_args + ["#{name}.ogg"], output: o, error: o)
end
[p1, p2].each(&.wait)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment