Skip to content

Instantly share code, notes, and snippets.

@tomisacat
Created November 23, 2016 10:30
Show Gist options
  • Save tomisacat/fac7c1aabd245723c5da2a7631b18ce5 to your computer and use it in GitHub Desktop.
Save tomisacat/fac7c1aabd245723c5da2a7631b18ce5 to your computer and use it in GitHub Desktop.
Convert mp3 to m4a with AAC codec and 128kb/s bitrate.
#!/usr/bin/env ruby
if ARGV.length < 1
puts "Please input file name."
exit
end
mp3_name = ARGV[0] + ""
m4a_name = mp3_name.split(".")[0] + ".m4a"
puts "******************************************"
puts "Converting #{mp3_name} to #{m4a_name} ..."
puts "******************************************"
command = "ffmpeg -i #{mp3_name} -c:a aac -b:a 128k #{m4a_name}"
exec command
@tomisacat
Copy link
Author

How to use?

copy this file to destination and then

$ chmod +x ./convert_mp3_to_m4a.rb

make sure that you have installed ffmpeg(which could be installed through homebrew).

then, just type the script name and the name of mp3 file like

$ ./convert_mp3_to_m4a.rb music.mp3

it will automatically convert music.mp3 to music.m4a with AAC codec and 128kb/s bitrate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment