How 2 Split Large FLAC Files

Abstract:

sudo yum install cuetools shntool flac
cuebreakpoints cdrom.cue | shnsplit -o flac cdrom.flac
cuetag.sh cdrom.cue split-track*.flac

Problem:

Centuries ago few international artists and many Scandinavian pirates used to distribute two files (cdrom.flac and cdrom.cue) to the public, so people could use Jörg Schilling's Cdrtools to burn thousands of CDDAs with them. Nowaday with cloud computing everone uses MusicBrainz Picard‎ and Google Play Music (or equivalents like Max Kellermann's MPD) to hear music. So one has to split those stupid old fashioned burn-polycarbonate-files.

Solution, Verbose:

With Fedora operating system there are all tools on board:

sudo yum install bash cuetools flac flac-libs glibc libogg shntool
cuebreakpoints --input-format cue --append-gaps cdrom.cue | shntool split -a split -o flac cdrom.flac
cuetag.sh cdrom.cue split-track*.flac

With Red Hat Enterprise Linux 6 and CentOS 6 use cuetools-1.4.0-0.10.svn305.fc19.src.rpm and shntool-3.0.10-6.fc19.src.rpm (or newer/better).

sudo yum groupinstall "Development tools" "Fedora Packager"
rpmdev-setuptree 
wget http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/source/SRPMS/c/cuetools-1.4.0-0.10.svn305.fc19.src.rpm
rpmbuild --rebuild cuetools-1.4.0-0.10.svn305.fc19.src.rpm 
wget http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/source/SRPMS/s/shntool-3.0.10-6.fc19.src.rpm
rpmbuild --rebuild shntool-3.0.10-6.fc19.src.rpm 
sudo yum install ~/rpmbuild/RPMS/*/*rpm flac
cuebreakpoints --input-format cue --append-gaps cdrom.cue | shntool split -a split -o flac cdrom.flac
cuetag.sh cdrom.cue split-track*.flac

cuetools

$ rpm --query --info --docfiles cuetools
Name        : cuetools
Version     : 1.4.0
Release     : 0.10.svn305.fc19
Architecture: x86_64
Install Date: Fri Jul  5 14:31:55 2013
Group       : Applications/Multimedia
Size        : 160417
License     : GPLv2
Signature   : RSA/SHA256, Fri Mar 15 21:31:56 2013, Key ID 07477e65fb4b18e6
Source RPM  : cuetools-1.4.0-0.10.svn305.fc19.src.rpm
Build Date  : Thu Feb 14 06:49:30 2013
Build Host  : buildvm-02.phx2.fedoraproject.org
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://developer.berlios.de/projects/cuetools/
Summary     : Utilities to work with cue and TOC files
Description :
Cuetools is a set of utilities for working with cue files and TOC files.
It includes programs for conversion between the formats, file renaming based
on cue/TOC information, and track breakpoint printing.
/usr/share/doc/cuetools-1.4.0/COPYING
/usr/share/doc/cuetools-1.4.0/NEWS
/usr/share/doc/cuetools-1.4.0/README
/usr/share/doc/cuetools-1.4.0/TODO
/usr/share/doc/cuetools-1.4.0/formats.txt
/usr/share/man/man1/cuebreakpoints.1.gz
/usr/share/man/man1/cueconvert.1.gz
/usr/share/man/man1/cueprint.1.gz

shntool

$ rpm --query --info --docfiles shntool
Name        : shntool
Version     : 3.0.10
Release     : 6.fc19
Architecture: x86_64
Install Date: Fri Jul  5 14:40:06 2013
Group       : Applications/Multimedia
Size        : 357247
License     : GPLv2+
Signature   : RSA/SHA256, Fri Mar 15 21:54:01 2013, Key ID 07477e65fb4b18e6
Source RPM  : shntool-3.0.10-6.fc19.src.rpm
Build Date  : Mon Feb 18 09:02:47 2013
Build Host  : buildvm-08.phx2.fedoraproject.org
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://etree.org/shnutils/shntool
Summary     : A multi-purpose WAVE data processing and reporting utility
Description :
A multi-purpose WAVE data processing and reporting utility. File
formats are abstracted from its core, so it can process any file that contains
WAVE data, compressed or not - provided there exists a format module to handle
that particular file type.
/usr/share/doc/shntool-3.0.10/AUTHORS
/usr/share/doc/shntool-3.0.10/BUGS
/usr/share/doc/shntool-3.0.10/COPYING
/usr/share/doc/shntool-3.0.10/CREDITS
/usr/share/doc/shntool-3.0.10/ChangeLog
/usr/share/doc/shntool-3.0.10/NEWS
/usr/share/doc/shntool-3.0.10/README
/usr/share/doc/shntool-3.0.10/modules.howto
/usr/share/man/man1/shntool.1.gz

flac

$ rpm --query --info --docfiles flac
Name        : flac
Version     : 1.3.0
Release     : 2.fc19
Architecture: x86_64
Install Date: Wed Jul  3 03:16:21 2013
Group       : Applications/Multimedia
Size        : 1588296
License     : BSD and GPLv2+ and GFDL
Signature   : RSA/SHA256, Mon Jun  3 14:39:40 2013, Key ID 07477e65fb4b18e6
Source RPM  : flac-1.3.0-2.fc19.src.rpm
Build Date  : Mon Jun  3 13:50:10 2013
Build Host  : buildvm-19.phx2.fedoraproject.org
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://www.xiph.org/flac/
Summary     : An encoder/decoder for the Free Lossless Audio Codec
Description :
FLAC stands for Free Lossless Audio Codec. Grossly oversimplified, FLAC
is similar to Ogg Vorbis, but lossless. The FLAC project consists of
the stream format, reference encoders and decoders in library form,
flac, a command-line program to encode and decode FLAC files, metaflac,
a command-line metadata editor for FLAC files and input plugins for
various music players.

This package contains the command-line tools and documentation.
/usr/share/doc/flac-1.3.0/html/changelog.html
/usr/share/doc/flac-1.3.0/html/comparison.html
/usr/share/doc/flac-1.3.0/html/comparison__chopin_prelude_24.html
/usr/share/doc/flac-1.3.0/html/comparison__dream_theater_600.html
/usr/share/doc/flac-1.3.0/html/comparison__eddie_warner_titus.html
/usr/share/doc/flac-1.3.0/html/comparison__fanfare_de_l_eventail_de_jeanne.html
/usr/share/doc/flac-1.3.0/html/comparison__gloria_estefan_conga.html
/usr/share/doc/flac-1.3.0/html/comparison__hand_in_my_pocket.html
/usr/share/doc/flac-1.3.0/html/comparison__l_sub_raga_sivapriya.html
/usr/share/doc/flac-1.3.0/html/comparison__laetatus_sum.html
/usr/share/doc/flac-1.3.0/html/comparison__mummified_in_barbed_wire.html
/usr/share/doc/flac-1.3.0/html/comparison__prokofiev_pcon3_3.html
/usr/share/doc/flac-1.3.0/html/comparison__ravel_sq4_4.html
/usr/share/doc/flac-1.3.0/html/comparison__scarlatti_k42.html
/usr/share/doc/flac-1.3.0/html/comparison__tool_forty_six_and_2.html
/usr/share/doc/flac-1.3.0/html/comparison__white_room.html
/usr/share/doc/flac-1.3.0/html/comparison_all_cpudectime.html
/usr/share/doc/flac-1.3.0/html/comparison_all_cpuenctime.html
/usr/share/doc/flac-1.3.0/html/comparison_all_procdectime.html
/usr/share/doc/flac-1.3.0/html/comparison_all_procenctime.html
/usr/share/doc/flac-1.3.0/html/comparison_all_ratio.html
/usr/share/doc/flac-1.3.0/html/developers.html
/usr/share/doc/flac-1.3.0/html/documentation.html
/usr/share/doc/flac-1.3.0/html/documentation_bugs.html
/usr/share/doc/flac-1.3.0/html/documentation_example_code.html
/usr/share/doc/flac-1.3.0/html/documentation_format_overview.html
/usr/share/doc/flac-1.3.0/html/documentation_tasks.html
/usr/share/doc/flac-1.3.0/html/documentation_tools.html
/usr/share/doc/flac-1.3.0/html/documentation_tools_flac.html
/usr/share/doc/flac-1.3.0/html/documentation_tools_metaflac.html
/usr/share/doc/flac-1.3.0/html/documentation_tools_plugins.html
/usr/share/doc/flac-1.3.0/html/download.html
/usr/share/doc/flac-1.3.0/html/faq.html
/usr/share/doc/flac-1.3.0/html/favicon.ico
/usr/share/doc/flac-1.3.0/html/features.html
/usr/share/doc/flac-1.3.0/html/flac.css
/usr/share/doc/flac-1.3.0/html/format.html
/usr/share/doc/flac-1.3.0/html/id.html
/usr/share/doc/flac-1.3.0/html/images/1x1.gif
/usr/share/doc/flac-1.3.0/html/images/cafebug.gif
/usr/share/doc/flac-1.3.0/html/images/hw/Blackbird_Front_low3_325x87.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/MS300frontsmall_270x108.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/MediaBox_Frt_170x325.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/SB_Hero_Black_325x182.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/Sooloos-ControlOne_325x328.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/Z500_front_325x94.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/a2_01_325x252.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/arcus_325x135.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/bmp-1430_325x241.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/cs505_front_lrg_325x113.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/enus_3-4lft-hires_product_eva8000_325x127.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/escient_ProductLine_325x163.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/hifidelio_bl_front_Z_RGB_325x163.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/i-station-mini-dx_325x237.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/iwod-g10_325x257.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/knc_hr-2800_325x209.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/mediaready_prodmain_MRMCa_325x232.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/meizu_m6_325x206.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/musica_artwork_325x90.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/neodigits_x5000_325x124.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/onda-vx737_325x240.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/request_n_front_325x103.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/rio_karma_279x254.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/sonos_family_RGB_325x200.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/teclast-tl29_325x244.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/transporter_hero_grey_325x208.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/tvix-4000_325x204.jpg
/usr/share/doc/flac-1.3.0/html/images/hw/vibez_nofm_combi_black_b_325x220.jpg
/usr/share/doc/flac-1.3.0/html/images/logo100.gif
/usr/share/doc/flac-1.3.0/html/images/logo130.gif
/usr/share/doc/flac-1.3.0/html/index.html
/usr/share/doc/flac-1.3.0/html/itunes.html
/usr/share/doc/flac-1.3.0/html/license.html
/usr/share/doc/flac-1.3.0/html/links.html
/usr/share/doc/flac-1.3.0/html/news.html
/usr/share/doc/flac-1.3.0/html/ogg_mapping.html
/usr/share/doc/flac-1.3.0/html/ru/authors.html
/usr/share/doc/flac-1.3.0/html/ru/comparison.html
/usr/share/doc/flac-1.3.0/html/ru/developers.html
/usr/share/doc/flac-1.3.0/html/ru/documentation.html
/usr/share/doc/flac-1.3.0/html/ru/download.html
/usr/share/doc/flac-1.3.0/html/ru/features.html
/usr/share/doc/flac-1.3.0/html/ru/format.html
/usr/share/doc/flac-1.3.0/html/ru/goals.html
/usr/share/doc/flac-1.3.0/html/ru/id.html
/usr/share/doc/flac-1.3.0/html/ru/index.html
/usr/share/doc/flac-1.3.0/html/ru/links.html
/usr/share/doc/flac-1.3.0/html/ru/news.html
/usr/share/man/man1/flac.1.gz
/usr/share/man/man1/metaflac.1.gz

cuebreakpoints

$ man cuebreakpoints
cuebreakpoints(1)                      General Commands Manual                      cuebreakpoints(1)



NAME
       cuebreakpoints - print the breakpoints from a CUE or TOC file

SYNOPSIS
       cuebreakpoints  [  {  -i  format  | --input-format=format } { --append-gaps | --prepend-gaps |
       --split-gaps } ] [ file ... ]
       cuebreakpoints -h | --help
       cuebreakpoints -V | --version

DESCRIPTION
       cuebreakpoints reports the track breakpoints found in CUE and TOC files, which  are  typically
       created  by compact disc ripping software.  The breakpoints are in a format usable by shnsplit
       (part of the shntool package).

       Three approaches to track pregaps are availabe: append (to previous track), prepend  (to  suc‐
       ceeding track), and split (from both preceding and succeeding tracks).  The split approach can
       result in up to twice as many breakpoints being reported as there are tracks on the disc.

       The first track's pregap cannot be appended to the previous track, so it is  prefixed  to  the
       track  in  both  append  and  prepend  modes.   If  you  want  the  track  without it, use the
       --split-gaps option.

       If no filenames are specified, cuebreakpoints reads from standard input, and an  input  format
       option  must  be specified.  If one or more filenames is provided, but the input format option
       is not specified, the input format will be guessed based on each file's suffix (e.g., .cue  or
       .toc).  This heuristic is case-insensitive.

OPTIONS
       -h, --help
              displays a usage message and exits.

       -i format, --input-format=format
              sets  the  expected  format of the input file(s) to format, which must be either cue or
              toc.

       --append-gaps
              appends pregaps to the end of the previous track.  This is the default.

       --prepend-gaps
              prefixes pregaps to the beginning of each subsequent track.

       --split-gaps
              separates pregaps from both the preceding and succeeding tracks.

       -V, --version
              displays version information and exits.

       If more than one of --append-gaps, --prepend-gaps, and --split-gaps are specified, all  except
       the last encountered are ignored.

EXIT STATUS
       cuebreakpoints  exits  with  status  zero if it successfully generates a report for each input
       file, and nonzero if there were problems.

AUTHOR
       Cuetools was written by Svend Sorensen.  Branden Robinson contributed fixes  and  enhancements
       to the utilities and documentation.

SEE ALSO
       cueconvert(1), cueprint(1)

                                                                                    cuebreakpoints(1)

shnsplit

$ file $(which shnsplit) 
/usr/bin/shnsplit: symbolic link to `shntool'
$ man shntool
SHNTOOL(1)                                      local                                      SHNTOOL(1)



NAME
       shntool - a multi‐purpose WAVE data processing and reporting utility


SYNOPSIS
       shntool mode ...
       shntool [CORE OPTION]


DESCRIPTION
       shntool  is a command‐line utility to view and/or modify WAVE data and properties.  It runs in
       several different operating modes, and supports various lossless audio formats.

       shntool is comprised of three parts ‐ its core, mode modules, and format modules.  This  helps
       to  make the code easier to maintain, as well as aid other programmers in developing new func‐
       tionality.  The distribution archive contains a file named 'modules.howto' that describes  how
       to create a new mode or format module, for those so inclined.


   Mode modules
       shntool  performs various functions on WAVE data through the use of mode modules.  The core of
       shntool is simply a wrapper around the mode modules.  In fact, when  shntool  is  run  with  a
       valid  mode  as  its  first argument, it essentially runs the main procedure for the specified
       mode, and quits.  shntool comes with several built‐in modes, described below:


              len    Displays length, size and properties of PCM WAVE data

              fix    Fixes sector‐boundary problems with CD‐quality PCM WAVE data

              hash   Computes the MD5 or SHA1 fingerprint of PCM WAVE data

              pad    Pads CD(hyquality files not aligned on sector boundaries with silence

              join   Joins PCM WAVE data from multiple files into one

              split  Splits PCM WAVE data from one file into multiple files

              cat    Writes PCM WAVE data from one or more files to the terminal

              cmp    Compares PCM WAVE data in two files

              cue    Generates a CUE sheet or split points from a set of files

              conv   Converts files from one format to another

              info   Displays detailed information about PCM WAVE data

              strip  Strips extra RIFF chunks and/or writes canonical headers

              gen    Generates CD‐quality PCM WAVE data files containing silence

              trim   Trims PCM WAVE silence from the ends of files


       For more information on the meaning of the various command‐line options for each mode, see the
       MODE‐SPECIFIC OPTIONS section below.

       For  convenience,  each  mode can specify an alternate name or alias that will invoke it (this
       feature is currently only available on systems that support symbolic  or  hard  linking).   In
       particular,  each  mode is aliased to 'shn<mode>'.  For instance, running shnlen is equivalent
       to running shntool len - thus saving a few keystrokes.


   Format modules
       File formats are abstracted from shntool through the use of format modules.   They  provide  a
       means  for shntool to tranparently read and/or write different file formats.  This abstraction
       allows shntool to concentrate on its job without worrying about the details of each file  for‐
       mat.

       The following formats are currently supported:


              wav    RIFF WAVE file format

              aiff   Audio  Interchange  File  Format  (AIFF  and uncompressed/sowt AIFF-C only) (via
                     'sox'):
                     <http://sox.sourceforge.net/>

              shn    Shorten low complexity waveform coder (via 'shorten'):
                     <http://www.softsound.com/Shorten.html>
                     <http://www.etree.org/shnutils/shorten/>

              flac   Free Lossless Audio Codec (via 'flac'):
                     <http://flac.sourceforge.net/>

              ape    Monkey's Audio Compressor (via 'mac'):
                     <http://www.monkeysaudio.com/>
                     <http://supermmx.org/linux/mac/>

              alac   Apple Lossless Audio Codec (via 'alac'):
                     <http://craz.net/programs/itunes/alac.html>

              tak    (T)om's lossless (A)udio (K)ompressor (via 'takc'):
                     <http://www.thbeck.de/Tak/Tak.html>

              ofr    OptimFROG Lossless WAVE Audio Coder (via 'ofr'):
                     <http://www.losslessaudio.org/>

              tta    TTA Lossless Audio Codec (via 'ttaenc'):
                     <http://tta.sourceforge.net/>

              als    MPEG-4 Audio Lossless Coding (via 'mp4als'):
                     <http://www.nue.tu-berlin.de/forschung/projekte/ ‐
                     lossless/mp4als.html>

              wv     WavPack Hybrid Lossless Audio Compression (via 'wavpack' and 'wvunpack'):
                     <http://www.wavpack.com/>

              lpac   Lossless Predictive Audio Compression (via 'lpac'):
                     <http://www.nue.tu-berlin.de/wer/liebchen/lpac.html>

              la     Lossless Audio (via 'la'):
                     <http://www.lossless-audio.com/>

              bonk   Bonk lossy/lossless audio compressor (via 'bonk'):
                     <http://www.logarithmic.net/pfh/bonk>

              kxs    Kexis lossless WAV file compressor (via 'kexis'):
                     <http://www.sourceforge.net/projects/kexis/>

              mkw    MKW Audio Compression format (via 'mkwcon'):
                     <http://www.etree.org/shnutils/mkwcon/>

              cust   Custom output format module (output only, useful for encoding to a  format  that
                     shntool does not yet support)

              term   sends output to the terminal

              null   sends  output  to  /dev/null (output only, useful for dry‐runs in several modes,
                     such as fix mode or strip mode)


       When reading files for input, shntool automatically discovers which,  if  any,  format  module
       handles  each file.  In modes where files are created as output, you can specify what the out‐
       put format should be ‐ otherwise, shntool decides for you by selecting the first format module
       it finds that supports output (in a default installation, this will be the wav format).


CORE OPTIONS
   Modeless
       When run without a mode, shntool takes these options:

       -m     Show detailed mode module information

       -f     Show detailed format module information

       -a     Show default format module arguments

       -v     Show version information

       -h     Show a help screen


GLOBAL OPTIONS
   All modes
       All modes support the following options:

       -D     Print debugging information

       -F file
              Specify  a  file  containing  a list of filenames to process.  This overrides any files
              specified on the command line or on the terminal.

              NOTE: Most modes will accept input filenames from a single  source,  according  to  the
              following  order of precedence: file specified by the -F option, otherwise filenames on
              the command line, otherwise filenames read from the terminal.

       -H     Print times in h:mm:ss.{ff,nnn} format, instead of m:ss.{ff,nnn}

       -P type
              Specify progress indicator type.  type is one of: {pct, dot, spin,  face,  none}.   pct
              shows  the  completion  percentage  of  each operation.  dot shows the progress of each
              operation by displaying a '.' after each 10% step  toward  completion.   spin  shows  a
              spinning  progress  indicator.  face shows the progress of each operation by displaying
              six emoticons that become increasingly happy as the operation nears  completion.   none
              prevents any progress completion information from being displayed.  The default is pct.

       -h     Show the help screen for this mode

       -i fmt Specify  input file format decoder and/or arguments.  The format is: "fmt decoder [arg1
              ... argN]", and must be surrounded by quotes.  If arguments are given, then one of them
              must contain "%f", which will be replaced with the input filename.  Examples:

              -i  'shn  shorten-2.3b'  (use  official  shorten-2.3b  instead of later versions; leave
              default arguments untouched)

              -i 'shn shorten -x -d 2048 %f -' (force shorten to skip the first 2048  bytes  of  each
              file)


       -q     Suppress  non‐critical  output  (quiet mode).  Output that normally goes to stderr will
              not be displayed, other than errors or debugging information (if specified).

       -r val Reorder input files?  val is one of: {ask, ascii, natural, none}.  The default is natu‐
              ral.

       -v     Show version information

       -w     Suppress warnings

       --     Indicates that everything following it is a filename

   Output modes
       Additionally, any mode that creates output files supports the the following options:

       -O val Overwrite existing files?  val is one of: {ask, always, never}.  The default is ask.

       -a str Prefix str to base part of output filenames

       -d dir Specify output directory

       -o str Specify  output  file  format  extension,  encoder  and/or arguments.  Format is:  "fmt
              [ext=abc] [encoder [arg1 ... argN (%f = filename)]]", and must be surrounded by quotes.
              If arguments are given, then one of them must contain "%f", which will be replaced with
              the output filename.  Examples:

              -o 'shn shorten -v2 - %f' (create shorten files without seek tables)

              -o 'flac flake - %f' (use alternate flac encoder)

              -o 'aiff ext=aif' (override default aiff extension of 'aiff' with 'aif')

              -o 'cust ext=mp3 lame --quiet - %f' (create mp3 files using lame)


       -z str Postfix str to base part of output filenames


MODE‐SPECIFIC OPTIONS
   len mode options
       -U unit
              Specifies the unit in which the totals will be printed.  unit is one of:  {b,  kb,  mb,
              gb, tb}.  The default is b.

       -c     Do not show column names

       -t     Do not show totals line

       -u unit
              Specifies the unit in which each file will be printed.  unit is one of: {b, kb, mb, gb,
              tb}.  The default is b.

       len mode output

              The output of len mode may seem cryptic at first, because it attempts to convey  a  lot
              of  information  in  just a little bit of space.  But it is quite easy to read once you
              know what the columns represent; and in certain columns, what  each  character  in  the
              column means.  Each column is explained below.

              length Shows  the  length  of  the WAVE data, in m:ss.nnn (millisecond) format.  If the
                     data is CD‐quality, then m:ss.ff is shown instead, where ff is a number from  00
                     to  74  that best approximates the number of frames (2352‐byte blocks) remaining
                     after m:ss.  If all files are CD‐quality, the total  length  will  be  shown  in
                     m:ss.ff format; otherwise it will be in m:ss.nnn format.  NOTE: CD‐quality files
                     are rounded to the nearest frame; all other files are  rounded  to  the  nearest
                     millisecond.

              expanded size
                     Shows  the  total  size of all WAVE chunks within the file (header, data and any
                     extra RIFF chunks).  Essentially this is the size that the file would be  if  it
                     were converted to .wav format, e.g.  with shntool conv.

                     NOTE:  Do not rely on this field for audio size!  If you simply want to know how
                     many bytes of audio are in a file, run it through info mode,  and  look  at  the
                     "data size" field in its output.

              cdr    Shows properties related to CD‐quality files.  A 'c' in the first slot indicates
                     that the WAVE data is not [C]D‐quality.  A 'b' in the second slot indicates that
                     the CD‐quality WAVE data is not cut on a sector [b]oundary.  An 's' in the third
                     slot indicates that the CD‐quality WAVE data is too [s]hort to be burned.

                     A '-' in any of these slots indicates that the particular property is OK or nor‐
                     mal.   An  'x' in any of these slots indicates that the particular property does
                     not apply to this file, or cannot be determined.

              WAVE   Shows properties of the WAVE data.  An 'h' in the first slot indicates that  the
                     WAVE  [h]eader  is  not canonical.  An 'e' in the second slot indicates that the
                     WAVE file contains [e]xtra RIFF chunks.

                     A '-' in any of these slots indicates that the particular property is OK or nor‐
                     mal.   An  'x' in any of these slots indicates that the particular property does
                     not apply to this file, or cannot be determined.

              problems
                     Shows problems detected with the WAVE header, WAVE data, or the file itself.   A
                     '3'  in  the  first slot indicates that the file contains an ID[3]v2 header.  An
                     'a' in the second slot indicates that the audio data is not block‐[a]ligned.  An
                     'i'  in  the  third  slot indicates that the WAVE header is [i]nconsistent about
                     data size and/or file size.  A 't' in the fourth slot indicates  that  the  WAVE
                     file  seems  to be [t]runcated.  A 'j' in the fifth slot indicates that the WAVE
                     file seems to have [j]unk appended to it.

                     A '-' in any of these slots  indicates  that  the  particular  problem  was  not
                     detected.   An  'x'  in any of these slots indicates that the particular problem
                     does not apply to this file, or cannot be determined.

              fmt    Shows which file format handled this file.

              ratio  Shows the compression ratio for this file.

              filename
                     Shows the name of the file that's being inspected.


   fix mode options
       NOTE: file names for files created in fix mode will be based on the input file name  with  the
       string  '-fixed' appended to it, and the extension will be the default extension of the output
       file format.  For example, with an output file format of shn the file 'foo.wav'  would  become
       'foo-fixed.shn'.  This can be overridden with the -a and/or -z global options described above.

       -b     Shift track breaks backward to the previous sector boundary.  This is the default.

       -c     Check  whether  fixing  is needed, without actually fixing anything.  shntool will exit
              with status 0 if fixing is needed, and status 1 otherwise.  This can be useful in shell
              scripts, e.g.: "if shntool fix -c *; then shntool fix *; else ...; fi"

       -f     Shift track breaks forward to the next sector boundary.

       -k     Specifies  that  all  files  should  be  processed,  even  if the first several of them
              wouldn't be altered, aside from a possible file format change.  The default is to  skip
              the  first  N  files  that wouldn't be changed from a WAVE data perspective in order to
              avoid unnecessary work.

       -n     Specifies that the last file created should not be padded with silence to make its WAVE
              data size a multiple of 2352 bytes.  The default is to pad the last file.

       -u     Round track breaks to the nearest sector boundary.


   hash mode options
       -c     Specifies  that  the  composite  fingerprint  for  all input files should be generated,
              instead of the default of one fingerprint per file.  The composite fingerprint is  sim‐
              ply the fingerprint of the WAVE data from all input files taken as a whole in the order
              given, and is identical to the one that would be generated from the joined file if  the
              same  files were joined into one large file, with no padding added.  This option can be
              used to fingerprint file sets, or to identify file sets in which track breaks have been
              moved  around,  but  no  audio  has been modified in any way (e.g. no padding added, no
              resampling done, etc.).

       -m     Generate MD5 fingerprints.  This is the default.

       -s     Generate SHA1 fingerprints.


   pad mode options
       NOTE: file names for files created in pad mode will be based on the input file name  with  the
       string  '-prepadded'  or  '-postpadded'  appended to it, and the extension will be the default
       extension of the output file format.  For example, with an output file format of shn and  pre‐
       padding  specified  on  the command line, the file 'foo.wav' would become 'foo-prepadded.shn'.
       This can be overridden with the -a and/or -z global options described above.

       Be aware that some output format encoders (e.g. flac, ape) automatically strip headers  and/or
       extra RIFF chunks.

       -b     Specifies  that the file created should be padded at the beginning with silence to make
              its WAVE data size a multiple of 2352 bytes.

       -e     Specifies that the file created should be padded at the end with silence  to  make  its
              WAVE data size a multiple of 2352 bytes.  This is the default action.


   join mode options
       NOTE:  file  names  for  files  created  in join mode will be prefixed with 'joined.', and the
       extension will be the default extension of the output file format.  For example, with an  out‐
       put file format of wav the files 'files*.wav' would become 'joined.wav'.  This can be overrid‐
       den with the -a and/or -z global options described above.

       -b     Specifies that the file created should be padded at the beginning with silence to  make
              its  WAVE  data size a multiple of 2352 bytes.  Note that this option does not apply if
              the input files are not CD‐quality, since padding is undefined in that case.

       -e     Specifies that the file created should be padded at the end with silence  to  make  its
              WAVE  data  size a multiple of 2352 bytes.  This is the default action.  Note that this
              option does not apply if the input files are not CD‐quality, since padding is undefined
              in that case.

       -n     Specifies that the file created should not be padded with silence to make its WAVE data
              size a multiple of 2352 bytes.  Note that this option does not apply if the input files
              are not CD‐quality, since padding is undefined in that case.


   split mode options
       NOTE:  file  names for files created in split mode are of the form prefixNNN.ext, where NNN is
       the output file number, and 'ext' is the default extension of the output file format.   If  an
       output file format of 'wav' is used, and the prefix is not altered via the -n switch described
       below, then the output file names will be "split-track01.wav", "split-track02.wav", etc.  This
       can be overridden with the -a and/or -z global options described above.

       For information on specifying split points, see the Specifying split points section below.

       -c num Specifies  the  number to start counting from when naming output files.  The default is
              1.

       -e len Prefix each track with len amount of lead‐in taken from the previous track.   len  must
              be given in bytes, m:ss, m:ss.ff or m:ss.nnn format.

       -f file
              Specifies  a file from which to read split point data.  If not given, then split points
              are read from the terminal.

       -l len Specifies that the input file should be split into smaller files based on multiples  of
              the len time interval.  len must be given in bytes, m:ss, m:ss.ff or m:ss.nnn format.

       -m str Specifies  a  character  manipulation  string  for filenames generated from CUE sheets.
              These characters, taken one‐by‐one, represent from/to character translation.  They must
              always be in pairs.  Some examples:


              :-     Translate all instances of ':' to '-'

              :-/-   Translate both ':' and '/' to '-'

              :-/_*x Translate ':' to '-', '/' to '_', and '*' to 'x'


       -n fmt Specifies  the  file  count  output format.  The default is %02d, which gives two‐digit
              zero‐padded numbers (01, 02, 03, ...).

       -t fmt Name output files in user‐specified format based on CUE sheet  fields.   The  following
              formatting strings are recognized:


              %p     Performer

              %a     Album

              %t     Track title

              %n     Track number


       -u len Postfix  each track with len amount of lead‐out taken from the next track.  len must be
              given in bytes, m:ss, m:ss.ff or m:ss.nnn format.

       -x list
              Only extract tracks in list (comma separated, may contain ranges).  Examples include:


              7      Only extract track 7

              3-5    Only extract tracks 3 through 5

              2-6,9,11-13
                     Only extract tracks 2 through 6, 9, and 11 through 13


       Specifying split points
              Split points simply mark places within the WAVE data of the  input  file  where  tracks
              will be split.  They can be specified in any combination of the following formats:

              bytes  where bytes is a specific byte offset

              m:ss   where m = minutes and ss = seconds

              m:ss.ff
                     where  m  =  minutes,  ss = seconds and ff = frames (75 per second, so ff ranges
                     from 00 to 74)

              m:ss.nnn
                     where m = minutes, ss = seconds and nnn = milliseconds (will be rounded to clos‐
                     est  sector boundary, or the first sector boundary if the closest one happens to
                     be the beginning of the file)

              CUE sheet
                     - a simple CUE sheet, in which each "INDEX 01 m:ss:ff" line is  converted  to  a
                     m:ss.ff split point

              Split  points  must be given in increasing order, and must appear one per line.  If the
              byte offset calculated from the final split point equals the  input  file's  WAVE  data
              size,  then  it is ignored.  Since split points specify locations within the input file
              where tracks will be split, N split points will create N+1 output files.  All m:ss for‐
              mats  will create splits on sector boundaries whenever the input file is CD‐quality; to
              force non‐sector‐aligned splits, use the exact byte format.


   cat mode options
       -c     Specifies that extra RIFF chunks should be suppressed from the output.  The default  is
              to write the extra RIFF chunks.

       -d     Specifies  that  the WAVE data should be suppressed from the output.  The default is to
              write the data.

       -e     Specifies that the WAVE header should be suppressed from the output.  The default is to
              write the header.

       -n     Specifies  that  the NULL pad byte at end of odd-sized data chunks should be suppressed
              from the output, if present.  The default is to write the NULL pad byte.   This  option
              only applies when WAVE data is also written, otherwise it is ignored.


   cmp mode options
       -c secs
              Sets  the number of seconds of audio to use for the byte‐shift comparison buffer.  This
              option only makes sense with the -s option.  The default is 3 seconds.

       -f fuzz
              Sets the "fuzz factor" for determining whether byte‐shifted data is identical.  fuzz is
              a  positive  integer  that  represents  the maximum number of allowable byte mismatches
              between the two files in the area searched by the -s option.  This allows one to  check
              for differing bytes between to files that (a) are byte‐shifted and (b) contain at least
              one error in the area searched by the -s option.   The  higher  the  fuzz  factor,  the
              longer  the  search  takes,  so  set it low to begin with (8 or so), and increase it in
              small steps if needed.  NOTE: this switch can only be used with the -s switch.

       -l     List offsets and values of all differing bytes.  Output is similar to 'cmp -l'; in par‐
              ticular, offsets are 1‐based.  Can be used with the -s switch.

       -s     Check  to see whether the WAVE data contained in the input files are identical modulo a
              byte‐shift.  Currently, this will only detect differences up to the first 529200  bytes
              (equal  to 3 seconds of CD‐quality data).  This can be used to compare WAVE data within
              a pre‐burned file to WAVE data in the corresponding track ripped from  the  burned  CD,
              which  is  useful  if the ripped track came from a CD burned TAO, and thus might have a
              2‐second gap of silence at the beginning.  This option can  also  help  identify  a  CD
              burner/CD reader combined read/write offset.


   cue mode options
       -c     Specifies that a simple CUE sheet should be output.  This is the default action.  NOTE:
              all input files must be CD‐quality for CUE sheets to be valid.

       -s     Specifies that split points in explicit byte‐offset format should be output.


   conv mode options
       NOTE: file names for files created in conv mode will be named based on the  input  file  name.
       Specifically, if the input file name ends with the default file extension for that file's for‐
       mat, then the default extension for the desired output format will replace it;  otherwise,  it
       will  be  appended to it.  For example, for an output format of shn and a wav input file named
       'file.wav', the converted file will be named 'file.shn', since '.wav' is the default extension
       for the wav format.  On the other hand, given the same situation above, but with an input file
       named 'file.wave', the converted file will be named 'file.wave.shn', since  '.wave'  does  not
       match '.wav'.  This can be overridden with the -a and/or -z global options described above.

       Be  aware that some output format encoders (e.g. flac, ape) automatically strip headers and/or
       extra RIFF chunks, while others (e.g. sox) might adjust WAVE data sizes in rare  instances  in
       order to align the audio on a block boundary.

       -t     Read WAVE data from the terminal.


   info mode options
       This mode doesn't support any additional options.


   strip mode options
       NOTE: file names for files created in strip mode will be based on the input file name with the
       string '-stripped' appended to it, and the extension will be the default extension of the out‐
       put  file  format.   For  example,  with an output file format of wav the file 'bar.shn' would
       become 'bar-stripped.wav'.  This can be overridden  with  the  -a  and/or  -z  global  options
       described above.

       Be  aware that some output format encoders (e.g. flac, ape) automatically strip headers and/or
       extra RIFF chunks, while others (e.g. sox) might adjust WAVE data sizes in rare  instances  in
       order to align the audio on a block boundary.

       -c     Specifies  that  extra  RIFF  chunks  should not be stripped.  The default is to remove
              everything that appears after the first data chunk.

       -e     Specifies that WAVE headers should not be made canonical.  The default is to canonical‐
              ize headers.


   gen mode options
       NOTE:  file  names  for  files  created  in gen mode will be prefixed with 'silence.', and the
       extension will be the default extension of the output file format.  For example, with an  out‐
       put  file format of wav the generated file would become 'silence.wav'.  This can be overridden
       with the -a and/or -z global options described above.

       -l len Generate files containing len amount of silence.  len must be  given  in  bytes,  m:ss,
              m:ss.ff or m:ss.nnn format.


   trim mode options
       NOTE:  file names for files created in trim mode will be based on the input file name with the
       string '-trimmed' appended to it, and the extension will be the default extension of the  out‐
       put  file  format.   For  example,  with an output file format of shn the file 'foo.wav' would
       become 'foo-trimmed.shn'.  This can be  overridden  with  the  -a  and/or  -z  global  options
       described above.

       -b     Only trim silence from the beginning of files

       -e     Only trim silence from the end of files


ENVIRONMENT VARIABLES
       ST_DEBUG
              If  set,  shntool will print debugging information.  This is analogous to the -D global
              option, with the exception that debugging is enabled immediately, instead of  when  the
              command‐line is parsed.

       ST_<FORMAT>_DEC
              Specify  input  file format decoder and/or arguments.  Replace <FORMAT> with the format
              you wish to modify, e.g.  ST_SHN_DEC.  The format of this variable is analagous to  the
              -i global option, except that the initial format is not included.  Examples:

              ST_SHN_DEC='shorten-2.3b'

              ST_SHN_DEC='shorten -x -d 2048 %f -'


       ST_<FORMAT>_ENC
              Specify  output file format extension, encoder and/or arguments.  Replace <FORMAT> with
              the format you wish to modify, e.g.   ST_SHN_ENC.   The  format  of  this  variable  is
              analagous  to  the  -o  global  option, except that the initial format is not included.
              Examples:

              ST_SHN_ENC='shorten -v2 - %f'

              ST_FLAC_ENC='flake - %f'

              ST_AIFF_ENC='ext=aif'

              ST_CUST_ENC='ext=mp3 lame --quiet - %f'

       Note that command‐line options take precedence over any of these environment variables.


EXIT STATUS
       Generally speaking, shntool will exit with status 0 upon success, and status 1 if  it  encoun‐
       ters  an  error.   The  only  exception  is when the 'quit' option is selected from within the
       interactive file reordering menu, in which case the exist status will be 255.


NOTES
       shntool is a misnomer, since it processes WAVE data, not shorten data.  The name is a holdover
       from  its  early days as 'shnlen', a program created specifically to extract information about
       WAVE data stored within .shn files.

       Aliases for shntool are prefixed with 'shn' instead of 'wav' to avoid possible collisions with
       existing programs.


AUTHOR
       Jason Jordan <shnutils at freeshell dot org>

       Please send all bug reports to the above address.

       The  latest  version  of  shntool  can  always be found at <http://www.etree.org/shnutils/> or
       <http://shnutils.freeshell.org/>.


COPYRIGHT
       Copyright (C) 2000-2009 Jason Jordan

       This is free software.  You may redistribute copies of it under the terms of the  GNU  General
       Public  License  <http://www.gnu.org/licenses/gpl.html>.   There is NO WARRANTY, to the extent
       permitted by law.


REVISION
       $Id: shntool.1,v 1.140 2009/03/30 05:59:25 jason Exp $



shntool 3.0.10                                March 2009                                   SHNTOOL(1)

cuetag.sh

#! /bin/sh

# cuetag.sh - tag files based on cue/toc file information
# uses cueprint output
# usage: cuetag.sh <cuefile|tocfile> [file]...

CUEPRINT=cueprint
cue_file=""

# print usage instructions
usage()
{
        echo "usage: cuetag.sh <cuefile|tocfile> [file]..."
        echo
        echo "cuetag.sh adds tags to files based on cue or toc information"
        echo
        echo "Supported formats (format extension, format name, tagging utility):"
        echo "ogg, Ogg Vorbis, vorbiscomment"
        echo "flac, FLAC, metaflac"
        echo "mp3, MP3, mp3info"
        echo "txt, Vorbis Comment Text File, tee"
        echo
        echo "cuetag.sh uses cueprint, which must be in your path"
}

# Vorbis Comments
# for FLAC and Ogg Vorbis files
vorbis()
{
        # FLAC tagging
        METAFLAC="metaflac --remove-all-tags --import-tags-from=-"

        # Ogg Vorbis tagging
        # -w overwrites existing comments
        # -a appends to existing comments
        VORBISCOMMENT="vorbiscomment -w -c -"

        # VC text file format
        # TODO: this also outputs to stdout
        TXTFILE="tee"

        case "$2" in
        *.[Ff][Ll][Aa][Cc])
                VORBISTAG=$METAFLAC
                ;;
        *.[Oo][Gg][Gg])
                VORBISTAG=$VORBISCOMMENT
                ;;
        *.[Tt][Xx][Tt])
                VORBISTAG=$TXTFILE
                ;;
        esac

        # space seperated list of recomended stardard field names
        # see http://www.xiph.org/ogg/vorbis/doc/v-comment.html
        # TRACKTOTAL is not in the Xiph recomendation, but is in common use
        
        fields='TITLE VERSION ALBUM TRACKNUMBER TRACKTOTAL ARTIST PERFORMER COPYRIGHT LICENSE ORGANIZATION DESCRIPTION GENRE DATE LOCATION CONTACT ISRC'

        # fields' corresponding cueprint conversion characters
        # seperate alternates with a space

        TITLE='%t'
        VERSION=''
        ALBUM='%T'
        TRACKNUMBER='%n'
        TRACKTOTAL='%N'
        ARTIST='%c %p'
        PERFORMER='%p'
        COPYRIGHT=''
        LICENSE=''
        ORGANIZATION=''
        DESCRIPTION='%m'
        GENRE='%g'
        DATE=''
        LOCATION=''
        CONTACT=''
        ISRC='%i %u'

        (for field in $fields; do
                value=""
                for conv in $(eval echo \$$field); do
                        value=$($CUEPRINT -n $1 -t "$conv\n" "$cue_file")

                        if [ -n "$value" ]; then
                                echo "$field=$value"
                                break
                        fi
                done
        done) | $VORBISTAG "$2"
}

id3()
{
        MP3INFO=mp3info

        # space seperated list of ID3 v1.1 tags
        # see http://id3lib.sourceforge.net/id3/idev1.html

        fields="TITLE ALBUM ARTIST YEAR COMMENT GENRE TRACKNUMBER"

        # fields' corresponding cueprint conversion characters
        # seperate alternates with a space

        TITLE='%t'
        ALBUM='%T'
        ARTIST='%p'
        YEAR=''
        COMMENT='%c'
        GENRE='%g'
        TRACKNUMBER='%n'

        for field in $fields; do
                value=""
                for conv in $(eval echo \$$field); do
                        value=$($CUEPRINT -n $1 -t "$conv\n" "$cue_file")

                        if [ -n "$value" ]; then
                                break
                        fi
                done

                if [ -n "$value" ]; then
                        case $field in
                        TITLE)
                                $MP3INFO -t "$value" "$2"
                                ;;
                        ALBUM)
                                $MP3INFO -l "$value" "$2"
                                ;;
                        ARTIST)
                                $MP3INFO -a "$value" "$2"
                                ;;
                        YEAR)
                                $MP3INFO -y "$value" "$2"
                                ;;
                        COMMENT)
                                $MP3INFO -c "$value" "$2"
                                ;;
                        GENRE)
                                $MP3INFO -g "$value" "$2"
                                ;;
                        TRACKNUMBER)
                                $MP3INFO -n "$value" "$2"
                                ;;
                        esac
                fi
        done
}

main()
{
        if [ $# -lt 1 ]; then
                usage
                exit
        fi

        cue_file=$1
        shift

        ntrack=$(cueprint -d '%N' "$cue_file")
        trackno=1

        if [ $# -ne $ntrack ]; then
                echo "warning: number of files does not match number of tracks"
        fi

        for file in "$@"; do
                case $file in
                *.[Ff][Ll][Aa][Cc])
                        vorbis $trackno "$file"
                        ;;
                *.[Oo][Gg][Gg])
                        vorbis $trackno "$file"
                        ;;
                *.[Mm][Pp]3)
                        id3 $trackno "$file"
                        ;;
                *.[Tt][Xx][Tt])
                        vorbis $trackno "$file"
                        ;;
                *)
                        echo "$file: unknown file type"
                        ;;
                esac
                trackno=$(($trackno + 1))
        done
}

main "$@"

'Fair use' applies to tons of trademark and logo usage on this page.

helpdesk/split flac (zuletzt geändert am 2013-07-09 11:13:27 durch heiner)