我目前在 Windows 8 的 VirtualBox 中运行 iTunes,以便将 CD 翻录为 ALAC 或 AIFF。这是由于历史原因,我从 OSX 迁移到 Ubuntu,但仍然喜欢我的 iPod Classic。
但是我希望开始从 Ubuntu 本身翻录 CD。有人能建议最好的方法来做到这一点并继续翻录到 ALAC 和 AIFF 吗?
答案1
网上流传了两年的脚本应该可以满足你的需求。它可以做以下事情:
自动检查并安装 sound-juicer、ffmpeg 和 metaflac,无需对它们进行进一步配置;
运行 sound-juicer 并让您从数据库中选择 cd 元数据,然后单击“提取”进行提取;
提取所有 CD 后关闭声音榨汁机以进行转换;
从 FLAC 文件中捕获元数据并将其提取出来以用于 ALAC 格式;
使用 ffmpeg 和元数据执行 FLAC 到 ALAC 的转换;
将处理好的FLAC文件移到处理好的目录中;
删除已经处理完的源目录。
以下是如何通过 5 个步骤实现该脚本:
1)创建一个 bash 脚本‘CDRip’:
cd /usr/local/bin && gedit /usr/local/bin/CDRip
2)从下面粘贴 bash 脚本,基本目录行应编辑到您的文件路径中:
##############################
### SET YOUR PARAMETERS ###
##############################
#Set the base directory
sBASEDIR="/DATA/Music/"
#Set directory sound juicer rips to
sIN="Ripped"
#Set directory ALAC files are placed in
sOUTALAC="Automatically Add to iTunes"
#Set directory converted FLAC files are placed in
sOUTFLAC="Processed"
###################################
### DO NOT EDIT BELOWTHIS LINE ###
###################################
#Check and install flac
problem=$(dpkg -s flac|grep installed)
echo "Checking for flac: $problem"
if [ "" == "$problem" ]; then
echo "No flac. Setting up flac"
sudo apt-get --force-yes --yes install flac
fi
#Check and install ffmpeg
problem=$(dpkg -s ffmpeg|grep installed)
echo "Checking for ffmpeg: $problem"
if [ "" == "$problem" ]; then
echo "No ffmpeg. Setting up ffmpeg"
sudo apt-get --force-yes --yes install ffmpeg
fi
#Check and install sound-juicer
problem=$(dpkg -s sound-juicer|grep installed)
echo "Checking for sound-juicer: $problem"
if [ "" == "$problem" ]; then
echo "No sound-juicer. Setting up sound-juicer"
sudo apt-get --force-yes --yes install sound-juicer
fi
#Start sound-juicer
sound-juicer
###############################
### START ALAC CONVERSION ###
###############################
#Set up some directory paths based on the variables
sINPATH="$sBASEDIR""$sIN"
sOUTALACPATH="$sBASEDIR""$sOUTALAC"
sOUTFLACPATH="$sBASEDIR""$sOUTFLAC"
echo "Variables set"
#Create ALAC output directory structure
find $sINPATH -type d | sed "s/$sIN/$sOUTALAC/" | xargs -d'\n' mkdir
#Create processed FLAC directory structure, prevents future reprocessing
find $sINPATH -type d | sed "s/$sIN/$sOUTFLAC/" | xargs -d'\n' mkdir
#Capture the FLAC meta data for conversion to ALAC metadata
for i in "$sINPATH"/*/*/*.flac
do
ARTIST=`metaflac "$i" --show-tag=ARTIST | sed s/.*=//g`
TITLE=`metaflac "$i" --show-tag=TITLE | sed s/.*=//g`
ALBUM=`metaflac "$i" --show-tag=ALBUM | sed s/.*=//g`
GENRE=`metaflac "$i" --show-tag=GENRE | sed s/.*=//g`
TRACKTOTAL=`metaflac "$i" --show-tag=TRACKTOTAL | sed s/.*=//g`
DATE=`metaflac "$i" --show-tag=DATE | sed s/.*=//g`
TRACKNUMBER=`metaflac "$i" --show-tag=TRACKNUMBER | sed s/.*=//g`
#Meta data options source:
#http://multimedia.cx/eggs/supplying-ffmpeg-with-metadata/
#Code to echo the metadata for debugging
#echo $ARTIST
#echo $TITLE
#echo $ALBUM
#echo $GENRE
#echo $TRACKTOTAL
#echo $DATE
#echo $TRACKNUMBER
#Set the array of files to process along with their output path
o="${i/$sIN/$sOUTALAC}"
#Set the array of files to process along with their new files extension
o=""${o/.flac/.m4a}""
#Echo the files that will be processed to check in debugging
o=""$(echo $o | sed 's/_//g')""
#Construct the filepath for the first file in the array to process
filepath=${i%/*}
#Construct the filename for the first file in the array to process
filename=${i##*/}
#Echo the path and file name to the terminal for debugging
echo $i
echo $o
#Start the convrsion of file i in the array to ALAC with the metadata
echo "n" | ffmpeg -i "$i" -metadata title="$TITLE" -metadata author="$ARTIST" -metadata album="$ALBUM" -metadata year="$DATE" -metadata track="$TRACKNUMBER" -acodec alac "$o"
#Move the ripped file that has been processed to the coverted file directory to stop ffmpeg trying to process the file again in future
d="${i/$sIN/$sOUTFLAC}"
mv "$i" "$d"
done
#Finally after all files have been processed delete the empty source ripped directories of the files which have been processed, which now reside in the converted folder and ALAC folder
for FOLDER in $sINPATH/*
do
rm -r "$FOLDER"
done
exit;
3)保存脚本并设置为可执行
sudo chmod 555 /usr/local/bin/CDRip
4)首次手动测试脚本,这将确保你已安装所有软件包
CDRip
5) 如果您想将脚本设置为插入音频 CD 时的默认操作,则在 Nautilus(至少适用于 10.04 的 Ubuntu 文件浏览器)中选择:
Edit > Preferences > File Manager Preferences > Media > CD Audio
指向此处打开您的 CDRip 脚本!大功告成。
答案2
使用RubyRipper并ffmpeg -i %i -acodec alac -metadata artist=%a -metadata album=%b -metadata title=%t -metadata genre=%g -metadata track=%n -metadata year=%y %o.m4a
输入优先->编解码器->其他
答案3
披露:作为 abcde 的前开发人员,我负责为 abcde 添加 Alac 和 AIFF 支持。此外,下面提供的网页和配置文件来自我自己的个人网站。
最近,命令行破解程序 abcde 的一些发展意味着您现在可以使用 FFmpeg、qaac 或 refalac 将 cd 转换为 Alac。您还可以使用 abcde 和 FFmpeg 生成 AIFF 格式。Linux 下 qaac 的安装可以在我自己的网站上看到:
在 Linux 下使用 qaac...
https://www.andrews-corner.org/qaac.html
我提供了以下 2 个配置文件,用于将 abcde 翻录到 Alac,以及将第 1 个配置文件翻录到 AIFF:
1. 使用 FFmpeg 的 Alac 的 abcde conf 文件:
# -----------------$HOME/.abcde.conf----------------- #
#
# A sample configuration file to convert music cds to
# Apple Lossless Audio Codec (alac) using FFmpeg's
# native encoder and abcde version 2.9.3
#
# https://andrews-corner.org/abcde/
# -------------------------------------------------- #
# Encode tracks immediately after reading. Saves disk space, gives
# better reading of 'scratchy' disks and better troubleshooting of
# encoding process but slows the operation of abcde quite a bit:
LOWDISK=y
# Specify the method to use to retrieve the track information,
# the alternative is to specify 'musicbrainz':
CDDBMETHOD=cddb
# With the demise of freedb (thanks for the years of service!)
# we move to an alternative:
CDDBURL="http://gnudb.gnudb.org/~cddb/cddb.cgi"
# Make a local cache of cddb entries and then volunteer to use
# these entries when and if they match the cd:
CDDBCOPYLOCAL="y"
CDDBLOCALDIR="$HOME/.cddb"
CDDBLOCALRECURSIVE="y"
CDDBUSELOCAL="y"
# Specify the encoder to use for Apple Lossless Audio Codec (alac):
AACENCODERSYNTAX=ffmpeg
# Specify the path to the selected encoder. In most cases the encoder
# should be in your $PATH as I illustrate below, otherwise you will
# need to specify the full path. For example: /usr/bin/ffmpeg
FFMPEG=ffmpeg
# Specify your required encoding options here, these options
# give Apple Lossless Audio Codec (alac) encoding, there are
# no other useful options as far as I know:
FFMPEGENCOPTS="-c:a alac"
# Output type for alac:
OUTPUTTYPE="m4a"
# The cd ripping program to use. There are a few choices here: cdda2wav,
# dagrab, cddafs (Mac OS X only) and flac. New to abcde 2.7 is 'libcdio'.
CDROMREADERSYNTAX=cdparanoia
# Give the location of the ripping program and pass any extra options,
# if using libcdio set 'CD_PARANOIA=cd-paranoia'.
CDPARANOIA=cdparanoia
CDPARANOIAOPTS="--never-skip=40"
# Give the location of the CD identification program:
CDDISCID=cd-discid
# Give the base location here for the encoded music files.
OUTPUTDIR="$HOME/Music"
# The default actions that abcde will take.
ACTIONS=cddb,playlist,read,encode,tag,move,clean
OUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
VAOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'
ONETRACKOUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}'
VAONETRACKOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}'
# Create playlists for single and various-artist encodes. I would suggest
# commenting these out for single-track encoding.
PLAYLISTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}.m3u'
VAPLAYLISTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}.m3u'
# This function takes out dots preceding the album name, and removes a grab
# bag of illegal characters. It allows spaces, if you do not wish spaces add
# in -e 's/ /_/g' after the first sed command.
mungefilename ()
{
echo "$@" | sed -e 's/^\.*//' | tr -d ":><|*/\"'?[:cntrl:]"
}
# What extra options?
MAXPROCS=2 # Run a few encoders simultaneously
PADTRACKS=y # Makes tracks 01 02 not 1 2
EXTRAVERBOSE=2 # Useful for debugging
COMMENT='abcde version 2.9.3' # Place a comment...
EJECTCD=y # Please eject cd when finished :-)
2.带有 qaac 的 Alac 的 abcde conf 文件:
# -----------------$HOME/.abcde.conf----------------- #
#
# A sample configuration file to convert music cds to
# Apple Lossless Audio Codec (alac) using either qaac
# or refalac and abcde version 2.9.3
#
# https://andrews-corner.org/abcde/
# -------------------------------------------------- #
# Encode tracks immediately after reading. Saves disk space, gives
# better reading of 'scratchy' disks and better troubleshooting of
# encoding process but slows the operation of abcde quite a bit:
LOWDISK=y
# Specify the method to use to retrieve the track information,
# the alternative is to specify 'musicbrainz':
CDDBMETHOD=cddb
# With the demise of freedb (thanks for the years of service!)
# we move to an alternative:
CDDBURL="http://gnudb.gnudb.org/~cddb/cddb.cgi"
# Make a local cache of cddb entries and then volunteer to use
# these entries when and if they match the cd:
CDDBCOPYLOCAL="y"
CDDBLOCALDIR="$HOME/.cddb"
CDDBLOCALRECURSIVE="y"
CDDBUSELOCAL="y"
# Specify the encoder to use for AAC or in our case
# Apple Lossless Audio Codec (alac):
AACENCODERSYNTAX=qaac
# The path for qaac can be problematic as abcde cannot cope
# with the 'standard' Wine location with spaces:
# "$HOME/.wine/drive_c/Program\ Files/qaac/qaac.exe"
# However the following works well:
QAAC="$HOME/.wine/drive_c/qaac/qaac.exe"
# Or use the Open Source alac encoder 'refalac' with this small hack:
# QAAC="$HOME/.wine/drive_c/qaac/refalac.exe"
# Specify your required encoding options here, these options
# give Apple Lossless Audio Codec (alac) encoding:
QAACENCOPTS="--alac --threading --verbose"
# Output type for alac:
OUTPUTTYPE="m4a"
# The cd ripping program to use. There are a few choices here: cdda2wav,
# dagrab, cddafs (Mac OS X only) and flac. New to abcde 2.7 is 'libcdio'.
CDROMREADERSYNTAX=cdparanoia
# Give the location of the ripping program and pass any extra options,
# if using libcdio set 'CD_PARANOIA=cd-paranoia'.
CDPARANOIA=cdparanoia
CDPARANOIAOPTS="--never-skip=40"
# Give the location of the CD identification program:
CDDISCID=cd-discid
# Give the location for the 'compatibility layer software application'
# known as Wine:
WINE=wine
# Give the base location here for the encoded music files.
OUTPUTDIR="$HOME/Music"
# The default actions that abcde will take.
ACTIONS=cddb,playlist,read,encode,tag,move,clean
OUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
VAOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'
ONETRACKOUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}'
VAONETRACKOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}'
# Create playlists for single and various-artist encodes. I would suggest
# commenting these out for single-track encoding.
PLAYLISTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}.m3u'
VAPLAYLISTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}.m3u'
# This function takes out dots preceding the album name, and removes a grab
# bag of illegal characters. It allows spaces, if you do not wish spaces add
# in -e 's/ /_/g' after the first sed command.
mungefilename ()
{
echo "$@" | sed -e 's/^\.*//' | tr -d ":><|*/\"'?[:cntrl:]"
}
# What extra options?
MAXPROCS=2 # Run a few encoders simultaneously
PADTRACKS=y # Makes tracks 01 02 not 1 2
EXTRAVERBOSE=2 # Useful for debugging
COMMENT='abcde version 2.9.3' # Place a comment...
EJECTCD=y # Please eject cd when finished :-)
1. 使用 FFmpeg 的 AIFF 的 abcde conf 文件:
# -----------------$HOME/.abcde.conf----------------- #
#
# A sample configuration file to convert music cds to
# Audio Interchange File Format (AIFF). This requires
# abcde version 2.9.3 and a recent copy of FFmpeg
#
# https://andrews-corner.org/abcde/
# -------------------------------------------------- #
# Encode tracks immediately after reading. Saves disk space, gives
# better reading of 'scratchy' disks and better troubleshooting of
# encoding process but slows the operation of abcde quite a bit:
LOWDISK=y
# Specify the method to use to retrieve the track information,
# the alternative is to specify 'musicbrainz':
CDDBMETHOD=cddb
# With the demise of freedb (thanks for the years of service!)
# we move to an alternative:
CDDBURL="http://gnudb.gnudb.org/~cddb/cddb.cgi"
# Make a local cache of cddb entries and then volunteer to use
# these entries when and if they match the cd:
CDDBCOPYLOCAL="y"
CDDBLOCALDIR="$HOME/.cddb"
CDDBLOCALRECURSIVE="y"
CDDBUSELOCAL="y"
# Specify the encoder to use for Audio Interchange File Format (AIFF):
AIFFENCODERSYNTAX=ffmpeg
# Specify the path to the selected encoder. In most cases the encoder
# should be in your $PATH as I illustrate below, otherwise you will
# need to specify the full path. For example: /usr/bin/ffmpeg
FFMPEG=ffmpeg
# Specify your required AIFF encoding options here. These options are
# needed by FFmpeg for tagging and selection of id3v2 version:
# 1. '-write_id3v2 1' allows id3v2 tagging while '-write_id3v2 0' disables tagging
# 2. '-id3v2_version 4' gives version id3v2.4 while '3' gives id3v2.3
AIFFENCOPTS="-write_id3v2 1 -id3v2_version 4"
# Output type for AIFF:
OUTPUTTYPE="aiff"
# The cd ripping program to use. There are a few choices here: cdda2wav,
# dagrab, cddafs (Mac OS X only) and flac. New to abcde 2.7 is 'libcdio'.
CDROMREADERSYNTAX=cdparanoia
# Give the location of the ripping program and pass any extra options,
# if using libcdio set 'CD_PARANOIA=cd-paranoia'.
CDPARANOIA=cdparanoia
CDPARANOIAOPTS="--never-skip=40"
# Give the location of the CD identification program:
CDDISCID=cd-discid
# Give the base location here for the encoded music files.
OUTPUTDIR="$HOME/Music"
# The default actions that abcde will take.
ACTIONS=cddb,playlist,read,encode,tag,move,clean
OUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
VAOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'
ONETRACKOUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}'
VAONETRACKOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}'
# Create playlists for single and various-artist encodes. I would suggest
# commenting these out for single-track encoding.
PLAYLISTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}.m3u'
VAPLAYLISTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}.m3u'
# This function takes out dots preceding the album name, and removes a grab
# bag of illegal characters. It allows spaces, if you do not wish spaces add
# in -e 's/ /_/g' after the first sed command.
mungefilename ()
{
echo "$@" | sed -e 's/^\.*//' | tr -d ":><|*/\"'?[:cntrl:]"
}
# What extra options?
MAXPROCS=2 # Run a few encoders simultaneously
PADTRACKS=y # Makes tracks 01 02 not 1 2
EXTRAVERBOSE=2 # Useful for debugging
COMMENT='abcde version 2.9.3' # Place a comment...
EJECTCD=y # Please eject cd when finished :-)