Use the cue file in Ubuntu to automatically track ape and wav Files

Source: Internet
Author: User

Use the cue file in Ubuntu to automatically track ape and wav Files

Many music CD image files contain cue-format track separation files. In Ubuntu Linux, you can use some tools to achieve automatic track separation.

1. Tools to be installed in Ubuntu include flac and shntool.

$ Sudo apt-get install flac shntool

To directly split ape rails, you must compile and install mac codecs for linux. Alternatively, you must first convert the ape file to wav or falc format.

Ii. flac segmentation for cue indexes:

$ Shntool split-t "% n. % p-% t"-f example. cue-o flac music.flac-d outputdir

-D specifies the output directory of the falc file after the track separation. If not specified, it is generated in the current directory.

-T specifies the file name format of the output file. % n indicates the audio track number, % p indicates the player/artist, and % t indicates the title.

Similar to ape track Separation

$ Shntool split-t "% n. % p-% t"-f example. cue-o ape example. ape-d outputdir

At present, it seems that an error cannot be processed when ape is divided into multiple ape, but the ape is then transcoded to another format (flac, mp3 ...) There is no problem. There is no problem between flac and other formats.

The character set of the cue file should be the same as the character set currently used by the system. Otherwise, it is better to use iconv for transcoding. Otherwise, the generated file name may be garbled.
$ Iconv-f gb18030-t utf8 CDImage. cue-o CDImage-linux.cue
$ Dos2unix CDImage-linux.cue.

3. Convert ape to wav or flac format

$ Avconv-I CDImage. ape CDImage.flac/ape -----> flac. Previously, ffmpeg was used, and now avconv is used.
$ Avconv-I CDImage.wav CDImage.flac // wav -----> flac
$ Avconv-I CDImage. ape CDImage.wav // ape ----> wav

Iv. Conversion of other formats

$ Flac CDImage.wav CDImage.flac // wav ----> flac
$ Shnconv-I ape-o flac CDImage. ape // ape -----> flac
$ Shnconv-I flac-o ape CDImage.flac // flac -----> ape

V. Script audio-cue-split.sh

#/Bin/bash

If [$ #-ne 2]
Then

Echo-e "Usage: audio-cue-split.sh [AUDIO_FILE_NAME] [DECODE_MODULE]"
Echo "example: audio-cue-split.sh CDImage.wav"
Echo "Note: The cue file must has the same name with the audio file ."
Echo-e "Note: DECODE_MODULE: wav, flac, etc"
Exit

Fi

 

AUDIO_FILE = $1
DECODE_MODULE = $2
FILE_PREFIX = 'echo $ AUDIO_FILE | sed "s/. $ DECODE_MODULE $ //"'

If ["$ DECODE_MODULE" = "ape"]
Then

Echo-e "First, convert ape format to flac format, waite a minute ..."
Pai_file1_1_file_prefix.flac
# Ffmpeg-I "$ AUDIO_FILE" "$ pai_file"
Avconv-I "$ AUDIO_FILE" "$ pai_file"
AUDIO_FILE = $ pai_file
DECODE_MODULE = 'flac'
CONVERT = "true"

Fi

 

CUE_FILE = $ FILE_PREFIX.cue
CUE_FILE_LINUX =$ FILE_PREFIX-linux.cue
# Echo AUDIO_FILE = $ AUDIO_FILE
# Echo DECODE_MODULE = $ DECODE_MODULE
# Echo FILE_PREFIX = $ FILE_PREFIX
# Echo CUE_FILE = $ CUE_FILE

Iconv-f gb18030-t utf8 "$ CUE_FILE"-o "$ CUE_FILE_LINUX"
Dos2unix "$ CUE_FILE_LINUX"
Shntool split-t "% n-% t"-f "$ CUE_FILE_LINUX"-o $ DECODE_MODULE "$ AUDIO_FILE"

If ["$ CONVERT" = "true"-a "$ __file "! = ""]
Then

Echo-e "Remove temporary flac file: $ pai_file"
Rm-f "$ pai_file"

Fi

Note: The above script is successfully tested in Ubuntu Kylin 14.04.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.