Skip to content

Instantly share code, notes, and snippets.

@otofu-square
Last active October 28, 2015 17:49
Show Gist options
  • Save otofu-square/cacfa509e13988d19687 to your computer and use it in GitHub Desktop.
Save otofu-square/cacfa509e13988d19687 to your computer and use it in GitHub Desktop.
Apple Loss Less → MP3 translation
require 'streamio-ffmpeg'
require 'yaml'
INPUT_PATH = "~/変換元ディレクトリ"
OUTPUT_PATH = "~/変換後のファイルを保存するディレクトリ"
# YAMLから変換する曲のアーティスト一覧を取得
# example: artists.yml
# - Bireli\ Lagrene
# - John\ Pizzarreli
# - ... etc
artists = YAML.load_file("./artists.yml")
artists.each do |artist|
artist_path = INPUT_PATH+artist
output_path = OUTPUT_PATH+artist
# アーティストのディレクトリを作成
Dir.mkdir(output_path.gsub("\\", ""))
Dir.glob(artist_path+"/*").each do |album|
# アルバムのディレクトリを作成
Dir.mkdir(album.sub(INPUT_PATH, OUTPUT_PATH))
Dir.glob(album+"/*").each do |music|
FFMPEG::Movie.new(music).transcode(music.gsub(INPUT_PATH, OUTPUT_PATH).gsub(".m4a", ".mp3"))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment