CueProc

download

Download: cueproc-1.10_win32.zip
Version: 1.10
Updated: 2008/2/23 Saturday
Size: 3.51 MB

Powered by Drain Hole

Introduction

Cuesheet Processor (CueProc) is a command-line tool for converting audio CD images into another format such as WAV, MP3, Ogg Vorbis, MP4, MPC, WMA, etc. The functions of this tool can be summarized as follows:

  • Parse a cuesheet (a .cue or audio file with the cuesheet embedded). Field values in a cuesheet (e.g., TITLE, PERFORMER, REM DATE, etc) will be used by the latter job.
  • Read audio data in a CD image (supported format: FLAC, Monkey’s Audio, WavPack, and WAVE).
  • Extract tracks in a CD image to individual WAVE files.
  • Execute an external encoder with predefined command-line arguments for each track. CueProc sets appropriate command-line arguments (e.g., naming for output files, tagging, etc) automatically by specifying an output plugin
  • Execute an external encoder with configurable command-line arguments.
  • Send audio stream of each track to STDIN of the external encoder.
  • Enumerate cuesheets recursively under a directory.
  • Process multiple cuesheets at a time, which is useful for converting an audio collection into a lossy format.
  • Skip encoding when the corresponding output file exists, which is useful for converting new CD images only.

CueProc is the successor tool to Audio CD Image Reader (ACDIR) and LAME with cuesheet input.

Audio CD image and cuesheet

An audio CD can be represented by an audio CD image that usually consists of a single audio file (e.g., CDImage.wav for an uncompressed image; CDImage.ape for an image compressed losslessly by Monkey’s Audio) and cuesheet (e.g., CDImage.cue). The portion of an audio file stores the audio data of the entire CD. A cuesheet (e.g., CDImage.cue) describes a track layout and supplementary meta-data (e.g., CD-TEXT). Being free from C1/C2 errors and the ambiguity of pre-gaps, audio CD image is an ideal solution to archive audio CDs without quality loss.

An audio CD image can be generated by Exact Audio Copy with a menu item, "Action" - "Copy Image & Create CUE Sheet". A number of CD writing software such as CDRWin, Nero, burnatonce can reproduce the original audio CD from an image. Some software audio players such as foobar 2000 and Soud Player Lilith can play CD images. A network audio solution, SqueezeBox combined with SlimServer, turns audio CD images in a HDD into a posh music jukebox with huge amount of CDs.

However, audio CD image is not suitable for portable audio players since the size per an image is far from portable (ca. 300-700MB). Thus, we need a method to convert audio CD images to another portable format, e.g., MP3, Ogg Vorbis, MP4. Nowadays, a number of tools can perform this job:

Please consider these tools if you prefer GUI. If you want a command-line tool for this job, CueProc is what you’ve been looking for.

Simple usage

This section describes a simple but sufficient usage of CueProc for converting audio CD images to lossy files.

Prerequisite for directory structure

This tutorial assumes that you manage audio CD images with a folder structure. The folder structure is straightforward but practical enough to construct a music collection in a confortable way.

Suppose that we have a root directory for the music collection. Although you can choose any directory for the root directory, this tutorial uses "Z:\" for simplicity. The root directory has a directory "cdimage" under which audio CD images are stored with hierarchy structure of directories representing artist and album names. For example, the CD image for album "Whatever People Say I Am - That’s What I’m Not" by the Arctic Monkeys is stored in "Z:\cdimage\ArcticMonkeys\WhateverPeopleSayIAm-That’sWhatI’mNot". Suppose that we would like to convert the CD images under "Z:\cdimage" directories by LAME MP3 encoder. In order to store converted MP3 files, we create a directory "Z:\lame" and inherit the hierarchical directory-structure under "Z:\cdimage" directory. The following illustrates an example of the directory structure explained above.

Z:\
+---cdimage
|   +---ArcticMonkeys
|   |   +---WhateverPeopleSayIAm-That'sWhatI'mNot
|   |   |       CDImage.flac
|   |   |       CDImage.cue
|   |           
|   +---BonniePink
|   |   +---EverySingleDay
|   |   |       disc1.cue
|   |   |       disc1.flac
|   |   |       disc2.cue
|   |   |       disc2.flac
|   |   |       
|   |   +---Present
|   |   |       CDImage.cue
|   |   |       CDImage.flac
|   |   ...
|   ...
|
+---lame
|   +---ArcticMonkeys
|   |   +---WhateverPeopleSayIAm-That'sWhatI'mNot
|   |   |       01_the view from the afternoon.mp3
|   |   |       02_i bet you look good on the dancefloor.mp3
|   |   |       ...
|   |   |       11_when the sun goes down.mp3
|   |           
|   +---BonniePink
|   |   +---EverySingleDay
|   |   |       01_01_Heaven's Kitchen.mp3
|   |   |       01_02_Forget Me Not.mp3
|   |   |       ...
|   |   |       01_13_Evil and Flowers (piano version).mp3
|   |   |       02_01_So Wonderful.mp3
|   |   |       ...
|   |   |       02_15_Last Kiss.mp3
|   |   |       
|   |   +---Present
|   |   |       ...
|   |   ...
|   ...

The directory structure under "Z:\cdimage" is reproduced under "Z:\lame", and MP3 files are stored in the appropriate directories. Please note that the album "Every Single Day" by Bonnie Pink has two CD images in a directory and generates MP3 files with prefixes (either 01_ or 02_) for identifying the disc numbers. The trick to add the prefix is in the cuesheet for the album. I will describe the extended cuesheet specification in the following sub-section.

Prerequisite for cuesheet

Although CueProc is compatible with generic cuesheets, this tutorial assumes some extensions to the standard cuesheet specification. These extensions are backward-compatible and optional to the standard specification.

Here is a sample cuesheet:

REM GENRE Pop
REM DATE 2006
REM DISCID B80D660D
REM DISCNUMBER 01
REM COMMENT "ExactAudioCopy v0.95b4"
CATALOG 4943674064656
PERFORMER "Bonnie Pink"
TITLE "Every Single Day Disc1"
FILE "disc1.flac" WAVE
  TRACK 01 AUDIO
    TITLE "Heaven's Kitchen"

    PERFORMER "Bonnie Pink"
    ISRC JPPC09641250
    INDEX 01 00:00:00
  TRACK 02 AUDIO
    TITLE "Forget Me Not"
    PERFORMER "Bonnie Pink"
    ISRC JPPC09717489
    INDEX 00 03:50:04
    INDEX 01 03:52:37
  TRACK 03 AUDIO
    ...

REM fields are known to describe optional values that are not defined in the standard specification. For example, the first line "REM GENRE Pop" declares that the genre is "Pop". Since REM statements are originally for describing comments, one can define any fields in principle based on their usage of cuesheets. One can use ${FIELDNAME} expression to refer to the value of a custom field, "REM FIELDNAME value" in command-line arguments for an external encoder.

At this moment, no standard defines the extended fields for cuesheet. CueProc assumes following REM fields as the extended standard so that predefined configurations of external encoders can refer to them in common:

REM fieldsDefinitionTypeEAC
REM GENREdefine the genrestringyes
REM DATEdefine the release datestringyes
REM DISCNUMBERdefine the disc number when the disc is a part of multi-disc releaseintegerno
REM COMPILATIONindicate a various-artist releaseboolean integer (1 if VA)no

Note that not all fields in this table are used by an external encoder.

Prerequisite for encoders

It is cumbersome to prepare a command-line template for an external encoder. CueProc predefines command-line templates for some encoders for the convenience.

PluginDescriptionNecessary external program
waveMicrosoft Riff-WAVENone
oggencOgg Vorbis encoderoggenc
lameLAME MP3 encoderlame
fiismp3Fraunhofer IIS MP3 Surround Commandline Encoder V1.2mp3sencoder, tag
hmp3Helix MPEG Layer III audio encoder v5.1hmp3, tag
mpcMusePack encodermppenc
wmaMicrosoft (R) Windows Media Encoder Command Line Script Utility (2006-08-25)WMCmd.vbs (via cscript.exe)
ctmp4AACPlus v2 Encoder (using Winamp 5.3 enc_aacplus.dll)enc_aacplus, mp4box, neroaactag
neromp4Nero Digital Audio Reference MPEG-4 & 3GPP Audio Encoderneroaacenc_sse2, neroaactag
extpipeGeneric external encoder with STDIN input(any)

Please install external programs that you would like to use. The path name of each encoder is configurable via -x option.

Installation

Place all files in win32bin directory, i.e., binaries (*.exe), DLLs (*.dll), Python DLLs (*.pyd), batch files (*.bat), library (library.zip) to the same directory. Have the directory registered in PATH environment. For example, I install all kinds of commane-line encoders to "C:\home\naoaki\music\tools" directory. Type the following command to register the directory in PATH environment:

set PATH=C:\home\naoaki\music\tools;%PATH

In addition, place all necessary binaries for encoders you are going to use. If you would like to Ogg Vorbis encoder, place oggene.exe in the directory registered in PATH environment.

LAME

Specify "lame" to -c argument and encoder options to -p argument, followed by the target cuesheet(s).

Z:\cdimage>cueenc -c lame -p "-V5 --vbr-new" "BonniePink\EverySingleDay\disc1.cu
e"
Cuesheet Processor (CueProc) Version 1.0 Copyright (c) 2006 by Nyaochi

CueProc: BonniePink\EverySingleDay\disc1.cue [1/13]
getaudio --begin 00:00:00 --end 03:52:37 Z:\cdimage\BonniePink\EverySingleDay\di
sc1.flac | lame --tt "Heaven's Kitchen" --ta "Bonnie Pink" --tl "Every Single Da
y Disc1" --tn 01 --tg Pop --ty 2006 --add-id3v2 -V5 --vbr-new - "..\lame\BonnieP
ink\EverySingleDay\01_01_Heaven's Kitchen.mp3"

LAME 3.97 32bits (http://www.mp3dev.org/)
CPU features: MMX (ASM used), SSE (ASM used), SSE2
Using polyphase lowpass filter, transition band: 15826 Hz - 16360 Hz
Encoding <stdin> to ..\lame\BonniePink\EverySingleDay\01_01_Heaven's Kitchen.mp3

Encoding as 44.1 kHz VBR(q=5) j-stereo MPEG-1 Layer III (ca. 11.9x) qval=3

CueProc: BonniePink\EverySingleDay\disc1.cue [2/13]
getaudio --begin 03:52:37 --end 08:00:35 Z:\cdimage\BonniePink\EverySingleDay\di
sc1.flac | lame --tt "Forget Me Not" --ta "Bonnie Pink" --tl "Every Single Day D
isc1" --tn 02 --tg Pop --ty 2006 --add-id3v2 -V5 --vbr-new - "..\lame\BonniePink
\EverySingleDay\01_02_Forget Me Not.mp3"

LAME 3.97 32bits (http://www.mp3dev.org/)
CPU features: MMX (ASM used), SSE (ASM used), SSE2
Using polyphase lowpass filter, transition band: 15826 Hz - 16360 Hz
Encoding <stdin> to ..\lame\BonniePink\EverySingleDay\01_02_Forget Me Not.mp3
Encoding as 44.1 kHz VBR(q=5) j-stereo MPEG-1 Layer III (ca. 11.9x) qval=3

Ogg Vorbis encoder

Specify "oggenc" to -c argument and encoder options to -p argument, followed by the target cuesheet(s).

Z:\cdimage>cueenc -c oggenc -p "-q4" "BonniePink\EverySingleDay\disc1.cue"

Note: if you want to use oggenc2.exe instead of oggenc.exe, use -x option to change the path name of the encoder temporarily, e.g.,

Z:\cdimage>cueenc -c oggenc -x "oggenc2" -p "-q4" 

Coding Technology MP4 encoder

Specify "ctmp4" to -c argument and encoder options to -p argument, followed by the target cuesheet(s).

Z:\cdimage>cueenc -c ctmp4 -p "--cbr 128000" "BonniePink\EverySingleDay\disc1.cue"

Windows Media Audio (WMA)

Specify "wma" to -c argument and encoder options to -p argument, followed by the target cuesheet(s).

Z:\cdimage>cueenc -c wma -p "-profile a128" "BonniePink\EverySingleDay\disc1.cue"

External encoder with pipe input

This is an example of ‘extpipe’ usage for Nero Digital Audio Reference MPEG-4 & 3GPP Audio Encoder.

Z:\cdimage>cueenc -c extpipe -m "neroaacenc -if - -of $quot${output}.mp4$quot" -
m "neroaactag $quot${output}.mp4$quot $quot-meta:title=${TITLE}$quot $quot-meta:
artist=${ARTIST}$quot $quot-meta:album=${ALBUM}$quot" "BonniePink\EverySingleDay
\disc1.cue"

Converting a number of audio CD images

Firstly, let us enumerate all cuesheet (*.cue) recursively under the "Z:\cdimage" directory and store the list of cuesheet files into "list.txt":

cueenc --find *.cue > list.txt

Encode all CD images described in the "list.txt" by using –target option. For example,

cueenc -c "lame" -p "-V5 --vbr-new" --target list.txt

If you spell the words before sleeping, the compressed audio files (*.mp3) should be ready in the next moning (depending on the total amount of CD images and CPU speed). In this way, we can convert a number of audio CD images to compressed audio or re-convert the audio CD image with higher quality or latest encoders. Let’s keep up with the rapid progress of audio compression!

Variables

Syntax

CueProc employs Python string.Template class for substituting a variable with the actual value. The following rules for variables apply:

  1. $$ is an escape; it is replaced with a single $
  2. $identifier will be substituted with the value of variable "identifier". By default, "identifier" must spell a Python identifier (only letters, digits, and ‘_’ allowed). The first non-identifier character after the $ character terminates this substitution.
  3. ${identifier} is equivalent to $identifier. It is required when valid identifier characters follow the substitution but are not part of the substitution, e.g. "${TRACKNUMBER}_$TITLE".

In addition to the variable substitution, CueProc implements conditional branching, #if{<condition>}, #elif{<condition>}, #else, and #endif, where <condition> is a condition expressed by Python code snippet. In a condition, Track variables are referable via a Python dictionary (mapping) object, track. For example,

#if{track['tracknumber'] == 1} (a) #else (b) #endif

The expression in region (a) will be evaluated only for the first track; otherwise the one in region (b) will be evlauated. To check the existence of a track variable, use has_key() method in a Python dictionary (mapping) object:

#if{track.has_key('DISCNUMBER')}${DISCNUMBER}_#endif${TRACKNUMBER}_${TITLE}

This pattern adds the value of ${DISCNUMBER} only when the variable exists, i.e., the target cuesheet has a line, "REM DISCNUMBER".

Standard names

CueProc sets following variables from a target cuesheet. `Const’ indicates whether the field value is constant in a cuesheet (yes) or can be overwritten at tracks (no). Basically, a variable whose name consists of capital letters is extracted from the content of a cuesheet.

NameDescriptionTypeCuesheet fieldConst
TITLETrack titlestrTITLEno
ARTISTTrack artiststrPERFORMERno
ALBUMAlbum titlestrTITLE (before the first TRACK)yes
ALBUMARTISTAlbum artiststrPERFORMER (before the first TRACK)yes
GENREGenre nanestrREM GENREno
DATERelease datestrREM DATEno
TRACKNUMBERTrack numberstrTRACKno
tracknumberTrack numberintTRACKno
TOTALTRACKSNumber of tracksstr(the number of TRACK)yes
DISCNUMBERDisc numberstrREM DISCNUMBERno
DISCIDCDDB disc IDstrREM DISCIDno
ISRCISRCstrREM ISRCno
COMPILATIONCompilation flagstrREM COMPILATIONno
XXXXXUser-defined fieldstrREM XXXXXno

CueProc also sets following environment variables.

VariableDescriptionConstComment
audioAudio filenamenoRelative path if: the target cuesheet is specified in a relative path; and FILE field in the cuesheet is described in a relative path
audio_baseAudio file name (with extension)no
audio_fileAudio file name (without extension)no
audio_extAudio file extensionno
audio_pathPath to ${audio}no
audio_path_dirDirectory portion of ${audio_path}no
audio_path_driveDrive portion of ${audio_path}no
audio_absolute${audio} described in absolute pathno
audio_absolute_pathPath to ${audio_absolute}no
audio_absolute_path_dirDirectory portion of ${audio_absolute_path}no
audio_absolute_path_driveDrive portion of ${audio_absolute_path}no
audio_range_beginBegin time in ${audio}noNone (Python value) for the first track
audio_range_endEnd time in ${audio}noNone (Python value) for the last track
cuesheetFilename of the current target cuesheetyes
cuesheet_baseCuesheet file name (with extension)yes
cuesheet_fileCuesheet file name (without extension)yes
cuesheet_extCuesheet file extensionyes
cuesheet_pathPath to ${cuesheet}yes
cuesheet_path_dirDirectory portion of ${cuesheet_path}yes
cuesheet_path_driveDrive portion of ${cuesheet_path}yes
cuesheet_absolute${cuesheet} converted in the absolute pathyes
cuesheet_absolute_pathPath to ${cuesheet_absolute}yes
cuesheet_absolute_path_dirDirectory portion of ${cuesheet_absolute}yes
cuesheet_absolute_path_driveDrive portion of ${cuesheet_absolute}yes
cuesheet_embeddedTrue if the cuesheet is embedded in the audio fileyes
outputCodec nameyesSpecified with -c (–outputplugin) option.
output_commandPath to the external encoderyesSpecified with -x (–outputcmd) option.
output_optionPath to the additional options to the output pluginyesSpecified with -p (–outputopt) option.
output_option_tagPath to the additional options to the output plugin for taggingyesSpecified with -p (–outputopt) option.
outputOutput filenameno${output_path}${output_base}${output_ext}
output_baseOutput base nameyesEvaluated value of that specified in -o (–outputfn) option. Any characters inappropriate for a file name will be replaced with spaces.
output_extOutput file extensionnoSet by the output plugin automatically.
output_pathOutput directory nameyesEvaluated value of that specified in -d (–outputdir) option. Any characters inappropriate for a path name will be replaced with spaces.
input_cmdlineThe command-line to extract audio data of the trackyesInternal use.
output_cmdlineThe command-line to encode audio data of the trackyesEvaluated value of that specified in -m (–outputcmdln) option. This variable exists only when a user specified -m (–outputcmdln) option and only for `extpipe’ plugin to derive the command-line for an external encoder.
quotDouble-quotation characteryesUseful to put an escaped quotation mark in a command-line.

Evaluation order

OrderVaribleCorresponding CueProc option
1Standard variables except for ${output_base}, ${output_path}, and ${output_option}
2${output_base}-o (–outputfn)
3${output_path}-d (–outputdir)
4${output_option}-p (–outputopt)
5${output_cmdln}-m (–outputcmdln)
6Any variable specified by -s (–setvar) option-s (–setvar)

Command-line options

Cuesheet Processor (CueProc) Version 1.10 Copyright (c) 2006-2008 by Nyaochi

Usage: cueproc.exe [options]  [ …]
Execute a job for each track in the target CD image(s).

Options:
  –version             show program’s version number and exit
  -h, –help            show this help message and exit
  -c PLUGIN, –output=PLUGIN
                        Specify an output plugin for the target(s).
  -x COMMAND, –outputcmd=COMMAND
                        Specify a command name for PLUGIN. An output plugin
                        uses its default command name without this option
                        specified.
  -p PATTERN, –outputopt=PATTERN
                        Specify a template pattern to pass optional arguments
                        to PLUGIN. Variable expressions ${}
                        will be replaced with the actual values for the
                        track(s). Conditional expressions such as
                        #if{}, #elif{}, #else, #endif
                        will be evaluated, where a condition  is
                        expressed by a Python code snippet.
  -e EXT, –outputext=EXT
                        Specify an extension for output files. An output
                        plugin uses its default extension without this option
                        specified.
  -o PATTERN, –outputfn=PATTERN
                        Specify a template pattern for output filenames.
                        Although the specification of template pattern is the
                        same as -p (–outputopt) option, any characters
                        invalid for a filename will be replaced with spaces.
  -d PATTERN, –outputdir=PATTERN
                        Specify a template pattern for output directory names.
                        Although the specification of template pattern is the
                        same as -p (–outputopt) option, any characters
                        invalid for a directory name will be replaced with
                        spaces.
  -m PATTERN, –outputcmdln=PATTERN
                        Specify a template pattern for ‘extpipe’ plugin. The
                        specification of template pattern is the same as -p
                        (–outputopt) option. The plugin can invoke multiple
                        processes sequencially with this option specified
                        multiple times.
  -s NAME=VALUE, –setvar=NAME=VALUE
                        Define a user-defined track variable whose name is
                        NAME and value is VALUE. This option can also
                        overwrite the value of an existing variable. NAME must
                        consist of alphanumeric and ‘_’ letters. VALUE will be
                        evaluated as a pattern similarly to the -p
                        (–outputopt) option.
  –no-auto-compilation
                        By default, CueProc sets COMPILATION flag to true for
                        all tracks in the target cuesheet with multiple
                        distinct PERFORMER names. This option disables the
                        automatic process of activating compilation flag.
  –albumart-files=ALBUMART_FILES
                        Specify the list of files for albumart images in
                        comma-separated values. CueProc sets ALBUMART variable
                        if one of these file exists in the same directory as
                        the cuesheet.  The default value of the list is,
                        ‘cover.jpg,albumart.jpg,folder.jpg’.
  –no-auto-albumart    This option disables the automatic detection of
                        albumart image based on the esistence of image files.
  –albumart-action=ALBUMART_ACTION
                        This option specifies the action when albumart images
                        are detected, embed to output files (embed), copy to
                        output directories (copy), or both (both).
  -t TRACK, –track=TRACK
                        Specify track range where the job is applicable in
                        comma separated values (CSV).
  –hidden-track1       This option assumes the first track to begin at INDEX
                        00 (or PREGAP).
  –target=TARGETS      Specify a text file describing the list of target
                        filenames. Useful for converting a number of CD images
                        at a time with a list file generated by –find option.
  -W SYSCHARSET, –syscharset=SYSCHARSET
                        Specify a charset for the current operating system.
                        The default value for this option is ‘mbcs’.
  -w CSCHARSET, –cscharset=CSCHARSET
                        Specify a charset for the target cuesheet(s). The
                        default value for this option is ‘mbcs’.
  -f, –overwrite       Force to overwrite existing output files. The default
                        behavior (not overwriting) is useful to process tracks
                        only in new CD images.
  –tempdir=TEMPDIR     Specify a directory for temporary files to which some
                        plugins create during the jobs.
  -n, –rehearsal       Do not execute the jobs but only shows command-lines
                        to be invoked by this program. Useful for debugging a
                        job without running it.
  –find=PATTERN        Find files under the current directory (including its
                        sub directories) that match the specified pattern.
  –show-variables      Show values of the track variable for each track in
                        the target(s). This option provides useful information
                        for debugging a job.
  -l, –list-plugin     List names of installed plugins.
  –help-plugin=PLUGIN  Show documentation for the specified plugin.
  –help-all-plugins    Show documentation for all installed plugins.
  –hide-cmdln          Do not display command-lines invoked by this program.