åèã«ãããµã¤ã
中村円眞堂 CD archive (1)
Linux で音楽ファイルの cue シート作成 - 暇つぶし【Linux/いろいろ】
ヒコウリツチュウ: Linuxでlameコマンド使ってwavからmp3へエンコード
注æ
以ä¸ã®ã³ãã³ãã使ã£ã¦ããã®ã§ç¡ããã°ã§ãã¾ãã
cdrdao, cueconvert, sox, flac, metaflac, shnsplit, lame, eyeD3
ã·ã§ã«ã¹ã¯ãªããã«ã¾ã¨ãããã®
â»æ°è¦ã®ãã£ã¬ã¯ããªã«ç§»åãã¦ããå®è¡ãã¦ãã ãã
â»ã¨ã©ã¼ãèµ·ããå ´åã®å¦çã¯æ¸ãã¦ãªãã§ããæ°ãåãããæ¸ãã¦ã©ããã§å
¬éãã¦ããã¾ã
é³æ¥½CDããflacã«ããã·ã§ã«ã¹ã¯ãªãã
#!/bin/sh cddb_server='freedbtest.dyndns.org:80:/~cddb/cddbutf8.cgi' sudo cdrdao read-cd --device /dev/cdrom --with-cddb --cddb-servers "${cddb_server}" --datafile CDImage.bin CDImage.toc cueconvert -i toc -o cue CDImage.toc CDImage.cue printf "`cat CDImage.cue`\n"|sed 's/CDImage\.bin/CDImage\.wav/g' > CDImage.cue.tmp mv CDImage.cue.tmp CDImage.cue sox -t cdda CDImage.bin CDImage.wav flac CDImage.wav metaflac --set-tag-from-file="CUESHEET=CDImage.cue" CDImage.flac
å¼æ°ã¯ããã¾ãã
追è¨:2013/01/05 19æé
ããfreedbããã¨ã£ã¦ããæ²æ å ±ãæ°ã«å ¥ããªãå ´åãªã©ã§cueãç·¨éãããå ´åã¯ã¾ãã¯.cueãããã£ã¦ãã
% metaflac --remove-tag="CUESHEET" CDImage.flac % metaflac --set-tag-from-file="CUESHEET=CDImage.cue" CDImage.flac
ãããã¾ããæåã«remove-tagããã¦ãããªãã¨åã®cuesheetã®å¾ãã«è¿½è¨ããããã¨ã«ãªãã®ã§æ¶ãã¦ããè¡ãã¾ããã
flacããæ²ãã¨ã«mp3ãçæããã·ã§ã«ã¹ã¯ãªãã
#!/bin/sh if [ "${#}" != '1' ];then echo "å¼æ°ã«flacãã¡ã¤ã«ãæå®ãã¦ãã ãã" exit 1 fi cue='CDImage.cue' metaflac --show-tag="CUESHEET" "${1}"|sed -e '1s/^CUESHEET=//' > "${cue}" shnsplit "${1}" -f "${cue}" -o 'cust ext=mp3 lame --add-id3v2 -b 320 --quiet - %f' -t '%n. %t' information=`cat "${cue}"|sed -n "1,/FILE/p"` album=`echo "${information}"|grep '^TITLE'|sed -e 's/^TITLE[^"]*"//' -e 's/"$//'` year=`echo "${information}"|grep '^MESSAGE'|grep -o '[0-9]*'` track_total=`cat "${cue}"|grep '^TRACK'|wc -l` IFS=$'\n' for i in `find . -type f -name '*.mp3'`;do filename=${i##*/} track=${filename%%.*} information=`cat "${cue}"|sed -n "/TRACK ${track}/,/INDEX/p"` title=`echo "${information}"|grep '^TITLE'|sed -e 's/^TITLE[^"]*"//' -e 's/"$//'` artist=`echo "${information}"|grep '^PERFORMER'|sed -e 's/^PERFORMER[^"]*"//' -e 's/"$//'` eyeD3 --to-v2.3 \ --set-encoding=utf16-LE \ --artist="${artist}" \ --album="${album}" \ --title="${title}" \ --track="${track}" \ --track-total="${track_total}" \ --year="${year}" \ "${i}" done
å¼æ°ã«flacãã¡ã¤ã«ãæå®ãã¦å®è¡ãã¾ã
flacã«åãè¾¼ã¿cueããããã¨ãåæã«æ¸ããã¦ãã¾ããå¤é¨ã«ããcueã使ãããå ´åã¯
metaflac --show-tag="CUESHEET" "${1}"|sed -e '1s/^CUESHEET=//' > "${cue}"
ãããã³ã¡ã³ãã¢ã¦ããããªããã¦cueå¤æ°ã«å¤é¨cueã®ãã¹ãæ¸ãã°å¤ååãã¾ã
以ä¸ããã¡ãã¡ã³ãã³ãã«ãããã®
é³æ¥½CDããflacã«ããæé
ã¾ãã¯é¢åãªãã¨ãé¿ããããã«é©å½ã«ä½ã£ããã£ã¬ã¯ããªã«ç§»åãã¦ããè¡ãªã£ã¦ãã ãã
cdãããã¡ã¤ã«ãçæããã®ã¨åæã«freedbtestããæ²åãªã©ã®æ å ±ãã¨ã£ã¦ãã
# cdrdao read-cd --device /dev/cdrom --with-cddb --cddb-servers 'freedbtest.dyndns.org:80:/~cddb/cddbutf8.cgi' --datafile CDImage.bin CDImage.toc
.tocãã.cueã«å¤æ
% cueconvert -i toc -o cue CDImage.toc CDImage.cue
æååãä¿®æ£ã¨ãã¡ã¤ã«åã®å¤æ´ç®æãããã
% printf "`cat CDImage.cue`\n"|sed 's/CDImage\.bin/CDImage\.wav/g' > CDImage.cue.tmp % mv CDImage.cue.tmp CDImage.cue
ãã¤ããªãã.wavãçæ
% sox -t cdda CDImage.bin CDImage.wav
.wavãã.flacã«å¤æ
% flac CDImage.wav
.flacã«.cueãåãè¾¼ã
% metaflac --set-tag-from-file="CUESHEET=CDImage.cue" CDImage.flac
ããã§cueãåãè¾¼ã¾ããflacã®çæãã§ãã¾ã
åçã¯deadbeefã¨ããé³æ¥½ãã¬ã¤ã¤ã¼ã§è©¦ãã¾ãã
flacããæ²ãã¨ã«mp3ãçæããæé
次ã¯shnsplitã³ãã³ãã使ç¨ããã®ã§ãã
flacã®åãè¾¼ã¿ã«ä½¿ã£ãå
ã®cueãã¡ã¤ã«ããªããã°
å¿
è¦ãªã®ã§flacã«åãè¾¼ã¾ãã¦ããcueãåãåºãã¾ã
% metaflac --show-tag="CUESHEET" CDImage.flac|sed -e '1s/^CUESHEET=//' > CDImage.cue
flacãåå²ãã¦mp3ã«ãã¾ãããã®æã«åºåããããã¡ã¤ã«å㯠ããã©ãã¯çªå·. æ²å.mp3ã ã«ãªãã¾ã
ããã¯ãªãã·ã§ã³ã®-t "%n. %t"ã§å®ç¾©ããã¦ããããã
% shnsplit CDImage.flac -f CDImage.cue -o 'cust ext=mp3 lame --add-id3v2 -b 320 --quiet - %f' -t '%n. %t'
å¥ã«ãã®ã¾ã¾ã§ãããã®ã§ããid3tagã使ãããã®ã§ (使ããªã人ã¯å
ç¨ã®ãªãã·ã§ã³ã®--add-id3v2ã¯ãããªã)
ãã¡ã¤ã«åã®åã«ã¤ãããã©ãã¯çªå·ãå©ç¨ãã¦
cueããè²ã
ã¨æ
å ±ãæãåãã¨ãã¾ããã³ãã³ãã®1è¡ã2è¡ã§ã¯æ¸ã¾ãªãã®ã§ã·ã§ã«ã¹ã¯ãªããã§æ¸ãã¾ã
#!/bin/sh cue='CDImage.cue' information=`cat "${cue}"|sed -n "1,/FILE/p"` album=`echo "${information}"|grep '^TITLE'|sed -e 's/^TITLE[^"]*"//' -e 's/"$//'` year=`echo "${information}"|grep '^MESSAGE'|grep -o '[0-9]*'` track_total=`cat "${cue}"|grep '^TRACK'|wc -l` IFS=$'\n' for i in `find . -type f -name '*.mp3'`;do filename=${i##*/} track=${filename%%.*} information=`cat "${cue}"|sed -n "/TRACK ${track}/,/INDEX/p"` title=`echo "${information}"|grep '^TITLE'|sed -e 's/^TITLE[^"]*"//' -e 's/"$//'` artist=`echo "${information}"|grep '^PERFORMER'|sed -e 's/^PERFORMER[^"]*"//' -e 's/"$//'` eyeD3 --to-v2.3 \ --set-encoding=utf16-LE \ --artist="${artist}" \ --album="${album}" \ --title="${title}" \ --track="${track}" \ --track-total="${track_total}" \ --year="${year}" \ "${i}" done
ãããªæãã®ã·ã§ã«ã¹ã¯ãªãããå®è¡ããã°
ã¢ã¼ãã£ã¹ãã¨ã¢ã«ãã åã¨æ²åã¨ãã©ãã¯çªå·ã¨åè¨ãã©ãã¯æ°ã¨å¹´ä»£ã
id3tagã¨ãã¦mp3ã«æ¸ãè¾¼ã¾ãã¾ã
ã¡ãªã¿ã«cueã®ä»æ§ã¯ç¢ºèªããããã¦ãªãã®ã§å¤ãªæåãããããããã¾ãããããã¹ãã«ä½¿ã£ãcueã¯
CATALOG 4580226569643 TITLE "ä¸å®å ¨çç¼/ã¹ã¤ãããå ¥ã£ãã" PERFORMER "ç³å·æºæ¶" MESSAGE " YEAR: 2011" FILE "CDImage.wav" WAVE TRACK 01 AUDIO TITLE "ä¸å®å ¨çç¼" PERFORMER "ç³å·æºæ¶" MESSAGE "" ISRC JPG751100248 INDEX 01 00:00:00 TRACK 02 AUDIO TITLE "ã¹ã¤ãããå ¥ã£ãã" PERFORMER "ç³å·æºæ¶" MESSAGE "" ISRC JPG751100248 INDEX 00 04:08:30 INDEX 01 04:08:34 TRACK 03 AUDIO TITLE "ä¸å®å ¨çç¼ (without vocal)" PERFORMER "ç³å·æºæ¶" MESSAGE "" ISRC JPG751100249 INDEX 00 08:40:14 INDEX 01 08:40:32 TRACK 04 AUDIO TITLE "ã¹ã¤ãããå ¥ã£ãã (without vocal)" PERFORMER "ç³å·æºæ¶" MESSAGE "" ISRC JPG751100250 INDEX 00 12:48:21 INDEX 01 12:48:25
ãããªæãã«ãªã£ã¦ã¾ã
å¾æ¸ã
id3tagã«ã¸ã£ã³ã«ãæå®ãããã£ããã©cueã«æ¸ãã¦ãªãã£ãã®ã§æ¸ãã¦ã¾ãã
ããã¨ã¢ã«ãã åã«/ãæ··ãã£ã¦ãå ´åãããã®ã§flacã®ãã¡ã¤ã«åãã¢ã«ãã åã«å¤ããå¦çãæ¸ãã¦ããªã
ããããã£ã¦ãã¾ãã°æ²åããã®å¯è½æ§ããããã©shnsplitãåæã«ã/ããã-ãã«ç½®æãã¦ãããã®ã§ç¡è¦ãããã¨ã«ãã¾ãã
(ã©ããã£ã¦å¯¾å¿ãããâ¦ã¨ã¹ã±ã¼ãããã®ãæçµæ段ããªãâ¦)
mplayerã§ã©ããã£ã¦åãè¾¼ã¿cueãåçãããã â¦ããããã¦å¯¾å¿ãã¦ããªãï¼