Created
September 6, 2017 15:30
-
-
Save Ragmaanir/9c9b7daa4b078b2a459153b6380e4f82 to your computer and use it in GitHub Desktop.
LMMS/ffmpeg export script (crystal)
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
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