<li><ahref="#format">format</a> - the user-level view of the FLAC format (for a more detailed explanation see the <ahref="format.html">format page</a>).</li>
<li><ahref="#flac">flac</a> - the usage of the command-line file encoder/decoder <spanclass="commandname">flac</span>.</li>
<li><ahref="#metaflac">metaflac</a> - the usage of the command-line FLAC metadata editor <spanclass="commandname">metaflac</span>.</li>
<li><ahref="#plugins">plugins</a> - documentation for the various input plugins.</li>
<li><ahref="api/index.html">libFLAC and libFLAC++ APIs</a> - for developers who want to add FLAC support to their programs.</li>
<li><ahref="http://losslessaudio.blogspot.com/2005/12/media-center-edition-2005-with-flac.html">How to add FLAC support to Windows Media Player</a></li>
Keep in mind that the online version of this document will always apply to the latest release. For older releases, check the documentation included with the release package.
<spanclass="commandname">flac</span> has been tuned so that the default options yield a good speed vs. compression tradeoff for many kinds of input. However, if you are looking to maximize the compression rate or speed, or want to use the full power of FLAC's metadata system, this section is for you. If not, just skip to the <ahref="#flac">next section</a>.
The first four bytes are to identify the FLAC stream. The metadata that follows contains all the information about the stream except for the audio data itself. After the metadata comes the encoded audio data.
FLAC defines several types of metadata blocks (see the <ahref="format.html">format</a> page for the complete list). Metadata blocks can be any length and new ones can be defined. A decoder is allowed to skip any metadata types it does not understand. Only one is mandatory: the <spanclass="code">STREAMINFO</span> block. This block has information like the sample rate, number of channels, etc., and data that can help the decoder manage its buffers, like the minimum and maximum data rate and minimum and maximum block size. Also included in the <spanclass="code">STREAMINFO</span> block is the MD5 signature of the <i>unencoded</i> audio data. This is useful for checking an entire stream for transmission errors.
<br/><br/>
Other blocks allow for padding, seek tables, tags, cuesheets, and application-specific data. You can see <spanclass="commandname">flac</span> options below for adding <spanclass="code">PADDING</span> blocks or specifying seek points. FLAC does not require seek points for seeking but they can speed up seeks, or be used for cueing in editing applications.
<br/><br/>
Also, if you have a need of a custom metadata block, you can define your own and request an ID <ahref="id.html">here</a>. Then you can reserve a <spanclass="code">PADDING</span> block of the correct size when encoding, and overwrite the padding block with your <spanclass="code">APPLICATION</span> block after encoding. The resulting stream will be FLAC compatible; decoders that are aware of your metadata can use it and the rest will safely ignore it.
After the metadata comes the encoded audio data. Audio data and metadata are not interleaved. Like most audio codecs, FLAC splits the unencoded audio data into blocks, and encodes each block separately. The encoded block is packed into a frame and appended to the stream. The reference encoder uses a single block size for the whole stream but the FLAC format does not require it.
The block size is an important parameter to encoding. If it is too small, the frame overhead will lower the compression. If it is too large, the modeling stage of the compressor will not be able to generate an efficient model. Understanding FLAC's modeling will help you to improve compression for some kinds of input by varying the block size. In the most general case, using linear prediction on 44.1kHz audio, the optimal block size will be between 2-6 ksamples. <spanclass="commandname">flac</span> defaults to a block size of 4608 in this case. Using the fast fixed predictors, a smaller block size is usually preferable because of the smaller frame header.
<br/><br/>
<b>INTER-CHANNEL DECORRELATION</b>
<br/><br/>
In the case of stereo input, once the data is blocked it is optionally passed through an inter-channel decorrelation stage. The left and right channels are converted to center and side channels through the following transformation: mid = (left + right) / 2, side = left - right. This is a lossless process, unlike joint stereo. For normal CD audio this can result in significant extra compression. <spanclass="commandname">flac</span> has two options for this: <spanclass="argument">-m</span> always compresses both the left-right and mid-side versions of the block and takes the smallest frame, and <spanclass="argument">-M</span>, which adaptively switches between left-right and mid-side.
<br/><br/>
<b>MODELING</b>
<br/><br/>
In the next stage, the encoder tries to approximate the signal with a function in such a way that when the approximation is subracted, the result (called the <i>residual</i>, <i>residue</i>, or <i>error</i>) requires fewer bits-per-sample to encode. The function's parameters also have to be transmitted so they should not be so complex as to eat up the savings. FLAC has two methods of forming approximations: 1) fitting a simple polynomial to the signal; and 2) general linear predictive coding (LPC). I will not go into the details here, only some generalities that involve the encoding options.
<br/><br/>
First, fixed polynomial prediction (specified with <spanclass="argument">-l 0</span>) is much faster, but less accurate than LPC. The higher the maximum LPC order, the slower, but more accurate, the model will be. However, there are diminishing returns with increasing orders. Also, at some point (usually around order 9) the part of the encoder that guesses what is the best order to use will start to get it wrong and the compression will actually decrease slightly; at that point you will have to you will have to use the exhaustive search option <spanclass="argument">-e</span> to overcome this, which is significantly slower.
Second, the parameters for the fixed predictors can be transmitted in 3 bits whereas the parameters for the LPC model depend on the bits-per-sample and LPC order. This means the frame header length varies depending on the method and order you choose and can affect the optimal block size.
Once the model is generated, the encoder subracts the approximation from the original signal to get the residual (error) signal. The error signal is then losslessly coded. To do this, FLAC takes advantage of the fact that the error signal generally has a Laplacian (two-sided geometric) distribution, and that there are a set of special Huffman codes called Rice codes that can be used to efficiently encode these kind of signals quickly and without needing a dictionary.
Rice coding involves finding a single parameter that matches a signal's distribution, then using that parameter to generate the codes. As the distribution changes, the optimal parameter changes, so FLAC supports a method that allows the parameter to change as needed. The residual can be broken into several <i>contexts</i> or <i>partitions</i>, each with it's own Rice parameter. <spanclass="commandname">flac</span> allows you to specify how the partitioning is done with the <spanclass="argument">-r</span> option. The residual can be broken into 2^<i>n</i> partitions, by using the option <spanclass="argument">-r n,n</span>. The parameter <i>n</i> is called the <i>partition order</i>. Furthermore, the encoder can be made to search through <i>m</i> to <i>n</i> partition orders, taking the best one, by specifying <spanclass="argument">-r m,n</span>. Generally, the choice of n does not affect encoding speed but m,n does. The larger the difference between m and n, the more time it will take the encoder to search for the best order. The block size will also affect the optimal order.
An audio frame is preceded by a frame header and trailed by a frame footer. The header starts with a sync code, and contains the minimum information necessary for a decoder to play the stream, like sample rate, bits per sample, etc. It also contains the block or sample number and an 8-bit CRC of the frame header. The sync code, frame header CRC, and block/sample number allow resynchronization and seeking even in the absence of seek points. The frame footer contains a 16-bit CRC of the entire encoded frame for error detection. If the reference decoder detects a CRC error it will generate a silent block.
As a convenience, the reference decoder knows how to skip <ahref="http://www.id3.org/">ID3v1 and ID3v2 tags</a>. Note however that the FLAC specification does not require compliant implementations to support ID3 in any form and their use is discouraged.
<br/><br/>
<spanclass="commandname">flac</span> has a verify option <spanclass="argument">-V</span> that verifies the output while encoding. With this option, a decoder is run in parallel to the encoder and its output is compared against the original input. If a difference is found <spanclass="commandname">flac</span> will stop with an error.
<spanclass="commandname">flac</span> is the command-line file encoder/decoder. The encoder currently supports as input RIFF WAVE, AIFF, FLAC or Ogg FLAC format, or raw interleaved samples. The decoder currently can output to RIFF WAVE or AIFF format, or raw interleaved samples. <spanclass="commandname">flac</span> only supports linear PCM samples (in other words, no A-LAW, uLAW, etc.), and the input must be between 4 and 24 bits per sample. This is not a limitation of the FLAC format, just the reference encoder/decoder.
<spanclass="commandname">flac</span> assumes that files ending in ".wav" or that have the RIFF WAVE header present are WAVE files, files ending in ".aif" or ".aiff" or have the AIFF header present are AIFF files, and files ending in ".flac" or have the FLAC header present are FLAC files. This assumption may be overridden with a command-line option. It also assumes that files ending in ".ogg" of have the Ogg FLAC header present are Ogg FLAC files. Other than this, <spanclass="commandname">flac</span> makes no assumptions about file extensions, though the convention is that FLAC files have the extension ".flac" (or ".fla" on ancient "8.3" file systems like FAT-16).
Before going into the full command-line description, a few other things help to sort it out: 1) <spanclass="commandname">flac</span> encodes by default, so you must use <b>-d</b> to decode; 2) the options <spanclass="argument">-0</span> .. <spanclass="argument">-8</span> (or <spanclass="argument">--fast</span> and <spanclass="argument">--best</span>) that control the compression level actually are just synonyms for different groups of specific encoding options (described later) and you can get the same effect by using the same options; 3) <spanclass="commandname">flac</span> behaves similarly to gzip in the way it handles input and output files.
<br/><br/>
<spanclass="commandname">flac</span> will be invoked one of four ways, depending on whether you are encoding, decoding, testing, or analyzing:
Analyzing: flac -a [<i><ahref="#general_options"><general-options></a></i>] [<i><ahref="#analysis_options"><analysis-options></a></i>] [FLACfile [...]]
</li>
</ul>
In any case, if no <spanclass="argument">inputfile</span> is specified, stdin is assumed. If only one inputfile is specified, it may be "-" for stdin. When stdin is used as input, <spanclass="commandname">flac</span> will write to stdout. Otherwise <spanclass="commandname">flac</span> will perform the desired operation on each input file to similarly named output files (meaning for encoding, the extension will be replaced with ".flac", or appended with ".flac" if the input file has no extension, and for decoding, the extension will be ".wav" for WAVE output and ".raw" for raw output). The original file is not deleted unless --delete-input-file is specified.
since the former allows flac to seek backwards to write the <spanclass="code">STREAMINFO</span> or RIFF WAVE header contents when necessary.
<br/><br/>
Also, you can force output data to go to stdout using <spanclass="argument">-c</span>.
<br/><br/>
To encode or decode files that start with a dash, use <spanclass="argument">--</span> to signal the end of options, to keep the filenames themselves from being treated as options:
The encoding options affect the compression ratio and encoding speed. The format options are used to tell <spanclass="commandname">flac</span> the arrangement of samples if the input file (or output file when decoding) is a raw file. If it is a RIFF WAVE or AIFF file the format options are not needed since they are read from the AIFF/WAVE header.
<br/><br/>
In test mode, <spanclass="commandname">flac</span> acts just like in decode mode, except no output file is written. Both decode and test modes detect errors in the stream, but they also detect when the MD5 signature of the decoded audio does not match the stored MD5 signature, even when the bitstream is valid.
<spanclass="commandname">flac</span> can also re-encode FLAC files. In other words, you can specify a FLAC or Ogg FLAC file as an input to the encoder and it will decoder it and re-encode it according to the options you specify. It will also preserve all the metadata unless you override it with other options (e.g. specifying new tags, seekpoints, cuesheet, padding, etc.).
Show detailed explanation of usage and all options. Running <spanclass="commandname">flac</span> without arguments shows the short help screen by default.
Decode (<spanclass="commandname">flac</span> encodes by default). <spanclass="commandname">flac</span> will exit with an exit code of <spanclass="argument">1</span> (and print a message, even in silent mode) if there were any errors during decoding, including when the MD5 checksum does not match the decoded output. Otherwise the exit code will be <spanclass="argument">0</span>.
Analyze (same as <spanclass="argument">-d</span> except an analysis file is written). The exit codes are the same as in decode mode. This option is mainly for developers; the output will be a text file that has data about each frame and subframe.
Force overwriting of output files. By default, <spanclass="commandname">flac</span> warns that the output file already exists and continues to the next file.
Force the output file name (usually <spanclass="commandname">flac</span> just changes the extension). May only be used when encoding a single file. May not be used in conjunction with <ahref="#flac_options_output_prefix"><spanclass="argument">--output-prefix</span></a>.
Prefix each output file name with the given string. This can be useful for encoding/decoding files to a different directory. Make sure if your string is a path name that it ends with a trailing '<spanclass="argument">/</span>' slash.
Automatically delete the input file after a successful encode or decode. If there was an error (including a verify error) the input file is left intact.
Skip over the first # of samples of the input. This works for both encoding and decoding, but not testing. The alternative form <spanclass="argument">mm:ss.ss</span> can be used to specify minutes, seconds, and fractions of a second.<br/><br/>
Examples:<br/><br/>
<spanclass="argument">--skip=123</span> : skip the first 123 samples of the input<br/>
<spanclass="argument">--skip=1:23.45</span> : skip the first 1 minute and 23.45 seconds of the input
Stop at the given sample number for each input file. This works for both encoding and decoding, but not testing. The given sample number is not included in the decoded output. The alternative form <spanclass="argument">mm:ss.ss</span> can be used to specify minutes, seconds, and fractions of a second. If a <spanclass="argument">+</span> sign is at the beginning, the <spanclass="argument">--until</span> point is relative to the <spanclass="argument">--skip</span> point. If a <spanclass="argument">-</span> sign is at the beginning, the <spanclass="argument">--until</span> point is relative to end of the audio.<br/><br/>
Examples:<br/><br/>
<spanclass="argument">--until=123</span> : decode only the first 123 samples of the input (samples 0-122, stopping at 123)<br/>
<spanclass="argument">--until=1:23.45</span> : decode only the first 1 minute and 23.45 seconds of the input<br/>
<spanclass="argument">--skip=1:00 --until=+1:23.45</span> : decode 1:00.00 to 2:23.45<br/>
<spanclass="argument">--until=-1:23.45</span> : decode everything except the last 1 minute and 23.45 seconds<br/>
<spanclass="argument">--until=-0:00</span> : decode until the end of the input (the same as not specifying <spanclass="argument">--until</span>)
When encoding, generate Ogg FLAC output instead of native FLAC. Ogg FLAC streams are FLAC streams wrapped in an Ogg transport layer. The resulting file should have an '.ogg' extension and will still be decodable by <spanclass="commandname">flac</span>.<br/><br/>
When decoding, force the input to be treated as Ogg FLAC. This is useful when piping input from stdin or when the filename does not end in '.ogg'.<br/><br/>
<b>NOTE:</b> Ogg FLAC files created prior to <spanclass="commandname">flac</span> 1.1.1 used an ad-hoc mapping and do not support seeking. They should be decoded and re-encoded with <spanclass="commandname">flac</span> 1.1.1 or later.
When used with --ogg, specifies the serial number to use for the first Ogg FLAC stream, which is then incremented for each additional stream. When encoding and no serial number is given, <spanclass="commandname">flac</span> uses a random number for the first stream, then increments it for each additional stream. When decoding and no number is given, <spanclass="commandname">flac</span> uses the serial number of the first page.
Set the beginning and ending cuepoints to decode. The optional first <spanclass="argument">#.#</span> is the track and index point at which decoding will start; the default is the beginning of the stream. The optional second <spanclass="argument">#.#</span> is the track and index point at which decoding will end; the default is the end of the stream. If the cuepoint does not exist, the closest one before it (for the start point) or after it (for the end point) will be used. If those don't exist, the start of the stream (for the start point) or end of the stream (for the end point) will be used. The cuepoints are merely translated into sample numbers then used as --skip and --until.<br/><br/>
Examples:<br/><br/>
<spanclass="argument">--cue=-</span> : decode the entire stream<br/>
<spanclass="argument">--cue=4.1</span> : decode from track 4, index 1 to the end of the stream<br/>
<spanclass="argument">--cue=4.1-</span> : decode from track 4, index 1 to the end of the stream<br/>
<spanclass="argument">--cue=-4.1</span> : decode from the beginning of the stream up to, but not including, track 4, index 1<br/>
<spanclass="argument">--cue=2.1-2.4</span> : decode from track 2, index 1, up to, but not including, track 2, index 4<br/>
<spanclass="argument">--cue=9.1-10.1</span> : decode from track 9 the way it would be played on a CD player; this works even if the CD has no 10th track.
By default <spanclass="commandname">flac</span> stops decoding with an error and removes the partially decoded file if it encounters a bitstream error. With <spanclass="argument">-F</span>, errors are still printed but <spanclass="commandname">flac</span> will continue decoding to completion. Note that errors may cause the decoded audio to be missing some samples or have silent sections.
</td>
</tr>
<!-- @@@ undocumented, also not in the man page yet
<b>WARNING: THIS IS NOT LOSSLESS. DECODED AUDIO WILL NOT BE IDENTICAL TO THE ORIGINAL WITH THIS OPTION</b>.
<br/><br/>
The equals sign and <specification> is optional. If omitted, the default is <spanclass="argument">0aLn1</span>.
<br/><br/>
The <spanclass="argument"><specification></span> is a shorthand notation for describing how to apply ReplayGain. All components are optional but order is important. '<spanclass="argument">[]</span>' means 'optional'. '<spanclass="argument">|</span>' means 'or'. '<spanclass="argument">{}</span>' means required. The format is:<br/><br/>
Specify '<spanclass="argument">a</span>' to use the album gain, or '<spanclass="argument">t</span>' to use the track gain. If tags for the preferred kind (album/track) do not exist but tags for the other (track/album) do, those will be used instead.
Specify '<spanclass="argument">l</span>' to peak-limit the output, so that the ReplayGain peak value is full-scale. Specify '<spanclass="argument">L</span>' to use a 6dB hard limiter that kicks in when the signal approaches full-scale.
</li>
<li>
<spanclass="argument">n{0|1|2|3}</span><br/>
Specify the amount of noise shaping. ReplayGain synthesis happens in floating point; the result is dithered before converting back to integer. This quantization adds noise. Noise shaping tries to move the noise where you won't hear it as much. <spanclass="argument">0</span> means no noise shaping, <spanclass="argument">1</span> means 'low', <spanclass="argument">2</span> means 'medium', <spanclass="argument">3</span> means 'high'.
</li>
</ul>
For example, the default of <spanclass="argument">0aLn1</span> means 0dB preamp, use album gain, 6dB hard limit, low noise shaping.
<br/><br/>
<spanclass="argument">-@@@-apply-replaygain-which-is-not-lossless=3</span> means 3dB preamp, use album gain, no limiting, no noise shaping.
<br/><br/>
<spanclass="commandname">flac</span> uses the ReplayGain tags for the calculation. If a stream does not have the required tags or they can't be parsed, decoding will continue with a warning, and no ReplayGain is applied to that stream.
Verify the encoding process. With this option, <spanclass="commandname">flac</span> will create a parallel decoder that decodes the output of the encoder and compares the result against the original. It will abort immediately with an error if a mismatch occurs. <spanclass="argument">-V</span> increases the total encoding time but is guaranteed to catch any unforseen bug in the encoding process.
Allow encoder to generate non-<ahref="format.html#subset">Subset</a> files. The resulting FLAC file may not be streamable or might have trouble being played in all players (especially hardware devices), so you should only use this option in combination with custom encoding options meant for archival.
Calculate <ahref="http://www.replaygain.org/">ReplayGain</a> values and store them as FLAC tags, similar to <ahref="http://packages.qa.debian.org/v/vorbisgain.html">VorbisGain</a>. Title gains/peaks will be computed for each input file, and an album gain/peak will be computed for all files. All input files must have the same resolution, sample rate, and number of channels. Only mono and stereo files are allowed, and the sample rate must be one of 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, or 48 kHz. Also note that this option may leave a few extra bytes in a <spanclass="code">PADDING</span> block as the exact size of the tags is not known until all files are processed.<br/><br/>
Import the given cuesheet file and store it in a <ahref="format.html#def_CUESHEET"><spanclass="code">CUESHEET</span></a> metadata block. This option may only be used when encoding a single file. A seekpoint will be added for each index point in the cuesheet to the <ahref="format.html#def_SEEKTABLE"><spanclass="code">SEEKTABLE</span></a> unless <spanclass="argument">--no-cued-seekpoints</span> is specified.<br/><br/>
The cuesheet file must be of the sort written by <ahref="http://www.goldenhawk.com/cdrwin.htm">CDRwin</a>, <ahref="http://www.dcsoft.com/prod03.htm">CDRcue</a>, <ahref="http://www.exactaudiocopy.de/">EAC</a>, et al.
Import a picture and store it in a <ahref="format.html#def_PICTURE"><spanclass="code">PICTURE</span></a> metadata block. More than one <spanclass="argument">--picture</span> command can be specified. The <spanclass="argument">SPECIFICATION</span> is a string whose parts are separated by <spanclass="argument">|</span> (pipe) characters. Some parts may be left empty to invoke default values. The format of <spanclass="argument">SPECIFICATION</span> is<br/><br/>
<spanclass="argument">TYPE</span> is optional; it is a number from one of:<br/>
<tt><ul>
<li>0: Other</li>
<li>1: 32x32 pixels 'file icon' (PNG only)</li>
<li>2: Other file icon</li>
<li>3: Cover (front)</li>
<li>4: Cover (back)</li>
<li>5: Leaflet page</li>
<li>6: Media (e.g. label side of CD)</li>
<li>7: Lead artist/lead performer/soloist</li>
<li>8: Artist/performer</li>
<li>9: Conductor</li>
<li>10: Band/Orchestra</li>
<li>11: Composer</li>
<li>12: Lyricist/text writer</li>
<li>13: Recording Location</li>
<li>14: During recording</li>
<li>15: During performance</li>
<li>16: Movie/video screen capture</li>
<li>17: A bright coloured fish</li>
<li>18: Illustration</li>
<li>19: Band/artist logotype</li>
<li>20: Publisher/Studio logotype</li>
</ul></tt>
The default is 3 (front cover). There may only be one picture each of type 1 and 2 in a file.<br/><br/>
<spanclass="argument">MIME-TYPE</span> is mandatory; for best compatibility with players, use pictures with MIME type <tt>image/jpeg</tt> or <tt>image/png</tt>. The MIME type can also be --> to mean that <spanclass="argument">FILE</span> is actually a URL to an image, though this use is discouraged.<br/><br/>
<spanclass="argument">DESCRIPTION</span> is optional; the default is an empty string.<br/><br/>
The next part specfies the resolution and color information. If the <spanclass="argument">MIME-TYPE</span> is <tt>image/jpeg</tt>, <tt>image/png</tt>, or <tt>image/gif</tt>, you can usually leave this empty and they can be detected from the file. Otherwise, you must specify the width in pixels, height in pixels, and color depth in bits-per-pixel. If the image has indexed colors you should also specify the number of colors used. When manually specified, it is not checked against the file for accuracy.<br/><br/>
<spanclass="argument">FILE</span> is the path to the picture file to be imported, or the URL if MIME type is --><br/><br/>
For example, the specification <spanclass="argument">|image/jpeg|||../cover.jpg</span> will embed the JPEG file at <tt>../cover.jpg</tt>, defaulting to type 3 (front cover) and an empty description. The resolution and color info will be retrieved from the file itself.<br/><br/>
The specification <spanclass="argument">4|-->|CD|320x300x24/173|http://blah.blah/backcover.tiff</span> will embed the given URL, with type 4 (back cover), description "CD", and a manually specified resolution of 320x300, 24 bits-per-pixel, and 173 colors. The file at the URL will not be fetched; the URL itself is stored in the PICTURE metadata block.
Align encoding of multiple CD format files on sector boundaries. This option is only allowed when encoding files all of which have a 44.1kHz sample rate and 2 channels. With <spanclass="argument">--sector-align</span>, the encoder will align the resulting .flac streams so that their lengths are even multiples of a CD sector (1/75th of a second, or 588 samples). It does this by carrying over any partial sector at the end of each file to the next stream. The last stream will be padded to alignment with zeroes.<br/><br/>
This option will have no effect if the files are already aligned (as is the normally the case with WAVE files ripped from a CD). <spanclass="commandname">flac</span> can only align a set of files given in one invocation of <spanclass="commandname">flac</span>.<br/><br/>
<b>WARNING:</b> The ordering of files is important! If you give a command like '<spanclass="code">flac --sector-align *.wav</span>' the shell may not expand the wildcard to the order you expect. To be safe you should '<spanclass="code">echo *.wav</span>' first to confirm the order, or be explicit like '<spanclass="code">flac --sector-align 8.wav 9.wav 10.wav</span>'.
Include a point or points in a <spanclass="code">SEEKTABLE</span>:<br/>
<ul>
<li>
<spanclass="argument"># </span> : a specific sample number for a seek point
</li>
<li>
<spanclass="argument">X </span> : a placeholder point (always goes at the end of the <spanclass="code">SEEKTABLE</span>)
</li>
<li>
<spanclass="argument">#x</span> : # evenly spaced seekpoints, the first being at sample 0
</li>
<li>
<spanclass="argument">#s</span> : a seekpoint every # seconds; # does not have to be a whole number, it can be, for example, <spanclass="argument">9.5</span>, meaning a seekpoint every 9.5 seconds
</li>
</ul>
You may use many -S options; the resulting <spanclass="code">SEEKTABLE</span> will be the unique-ified union of all such values.<br/>
With no -S options, flac defaults to '-S 10s'. Use --no-seektable for no <spanclass="code">SEEKTABLE</span>.<br/>
<b>NOTE:</b> -S #x and -S #s will not work if the encoder can't determine the input size before starting.<br/>
<b>NOTE:</b> if you use -S # and # is >= samples in the input, there will be either no seek point entered (if the input size is determinable before encoding starts) or a placeholder point (if input size is not determinable).<br/>
Tell the encoder to write a <spanclass="code">PADDING</span> metadata block of the given length (in bytes) after the <spanclass="code">STREAMINFO</span> block. This is useful if you plan to tag the file later with an <spanclass="code">APPLICATION</span> block; instead of having to rewrite the entire file later just to insert your block, you can write directly over the <spanclass="code">PADDING</span> block. Note that the total length of the <spanclass="code">PADDING</span> block will be 4 bytes longer than the length given because of the 4 metadata block header bytes. You can force no <spanclass="code">PADDING</span> block at all to be written with <spanclass="argument">--no-padding</span>. The encoder writes a <spanclass="code">PADDING</span> block of 8192 bytes by default (or 65536 bytes if the input audio stream is more than 20 minutes long).
Add a FLAC tag. The comment must adhere to the Vorbis comment spec (which FLAC tags implement), i.e. the FIELD must contain only legal characters, terminated by an 'equals' sign. Make sure to quote the comment if necessary. This option may appear more than once to add several comments. NOTE: all tags will be added to all encoded files.
Like <ahref="#flac_options_tag"><spanclass="argument">--tag</span></a>, except FILENAME is a file whose contents will be read verbatim to set the tag value. The contents will be converted to UTF-8 from the local charset. This can be used to store a cuesheet in a tag (e.g. <spanclass="argument">--tag-from-file="CUESHEET=image.cue"</span>). Do not try to store binary data in tag fields! Use APPLICATION blocks for that.
Specify the block size in samples. Subset streams must use one of 192/576/1152/2304/4608/256/512/1024/2048/4096 (and 8192/16384 if the sample rate is >48kHz). The reference encoder uses the same block size for the entire stream.
Enable mid-side coding (only for stereo streams). Tends to increase compression by a few percent on average. For each block both the stereo pair and mid-side versions of the block will be encoded, and smallest resulting frame will be stored.
Enable adaptive mid-side coding (only for stereo streams). Like <spanclass="argument">-m</span> but the encoder adaptively switches between independent and mid-side coding, which is faster but yields less compression than <spanclass="argument">-m</span> (which does an exhaustive search).
Exhaustive model search (expensive!). Normally the encoder estimates the best model to use and encodes once based on the estimate. With an exhaustive model search, the encoder will generate subframes for every order and use the smallest. If the max LPC order is high this can significantly increase the encode time but can shave off another 0.5%.
Window audio data with given the apodization function. The functions are: bartlett, bartlett_hann, blackman, blackman_harris_4term_92db, connes, flattop, gauss(STDDEV), hamming, hann, kaiser_bessel, nuttall, rectangle, triangle, tukey(P), welch.<br/>
For gauss(STDDEV), STDDEV is the standard deviation (0<STDDEV<=0.5).<br/>
For tukey(P), P specifies the fraction of the window that is tapered (0<=P<=1; P=0 corresponds to "rectangle" and P=1 corresponds to "hann").<br/>
More than one -A option (up to 32) may be used. Any function that is specified erroneously is silently dropped. The encoder chooses suitable defaults in the absence of any -A options; any -A option specified replaces the default(s).<br/>
When more than one function is specified, then for every subframe the encoder will try each of them separately and choose the window that results in the smallest compressed subframe. Multiple functions can greatly increase the encoding time.<br/>
Specifies the maximum LPC order. This number must be <= 32. For Subset streams, it must be <=12 if the sample rate is <=48kHz. If 0, the encoder will not attempt generic linear prediction, and use only fixed predictors. Using fixed predictors is faster but usually results in files being 5-10% larger.
Specifies the precision of the quantized LP coefficients, in bits. The default is <spanclass="argument">-q 0</span>, which means let the encoder decide based on the signal. Unless you really know your input file it's best to leave this up to the encoder.
Do exhaustive LP coefficient quantization optimization. This option overrides any <spanclass="argument">-q</span> option. It is expensive and typically will only improve the compression a tiny fraction of a percent. <spanclass="argument">-q</span> has no effect when <spanclass="argument">-l 0</span> is used.
Set the [min,]max residual partition order. The min value defaults to 0 if unspecified.<br/><br/>
By default the encoder uses a single Rice parameter for the subframe's entire residual. With this option, the residual is iteratively partitioned into 2^min# .. 2^max# pieces, each with its own Rice parameter. Higher values of max# yield diminishing returns. The most bang for the buck is usually with <spanclass="argument">-r 2,2</span> (more for higher block sizes). This usually shaves off about 1.5%. The technique tends to peak out about when blocksize/(2^n)=128. Use <spanclass="argument">-r 0,16</span> to force the highest degree of optimization.
Specify the size of the raw input in bytes. If you are encoding raw samples from stdin, you must set this option in order to be able to use --skip, --until, --cue-sheet, or other options that need to know the size of the input beforehand. If the size given is greater than what is found in the input stream, the encoder will complain about an unexpected end-of-file. If the size given is less, samples will be truncated.
Force the decoder to output AIFF format. This option is not needed if the output filename (as set by -o) ends with .aiff. Also, this option has no effect when encoding since input AIFF is auto-detected.
<spanclass="commandname">metaflac</span> is the command-line <spanclass="code">.flac</span> file metadata editor. You can use it to list the contents of metadata blocks, edit, delete or insert blocks, and manage padding.
<br/><br/>
<spanclass="commandname">metaflac</span> takes a set of "options" (though some are not optional) and a set of FLAC files to operate on. There are three kinds of "options":
Major operations, which specify a mode of operation like listing blocks, removing blocks, etc. These will have sub-operations describing exactly what is to be done.
Shorthand operations, which are convenient synonyms for major operations. For example, there is a shorthand operation <spanclass="argument">--show-sample-rate</span> that shows just the sample rate field from the <spanclass="code">STREAMINFO</span> metadata block.
All of these are described in the tables below. At least one shorthand or major operation must be supplied. You can use multiple shorthand operations to do more than one thing to a file or set of files. Most of the common things to do to metadata have shorthand operations. As an example, here is how to show the MD5 signatures for a set of three FLAC files:
Another example; this removes all DESCRIPTION and COMMENT tags in a set of FLAC files, and uses the <spanclass="argument">--preserve-modtime</span> global option to keep the FLAC file modification times the same (usually when files are edited the modification time is set to the current time):
By default <spanclass="commandname">metaflac</span> tries to use padding where possible to avoid rewriting the entire file if the metadata size changes. Use this option to tell metaflac to not take advantage of padding this way.
Add a tag. The <spanclass="argument">FIELD</span> must comply with the Vorbis comment spec, of the form <spanclass="argument">NAME=VALUE</span>. If there is currently no tag block, one will be created.
Like <ahref="#metaflac_shorthand_set_tag"><spanclass="argument">--set-tag</span></a>, except the VALUE is a filename whose contents will be read verbatim to set the tag value. Unless <ahref="#metaflac_options_no_utf8_convert"><spanclass="argument">--no-utf8-convert</span></a> is specified, the contents will be converted to UTF-8 from the local charset. This can be used to store a cuesheet in a tag (e.g. <spanclass="argument">--set-tag-from-file="CUESHEET=image.cue"</span>). Do not try to store binary data in tag fields! Use APPLICATION blocks for that.
Import tags from a file. Use <spanclass="argument">-</span> for stdin. Each line should be of the form <spanclass="argument">NAME=VALUE</span>. Multi-line comments are currently not supported. Specify <spanclass="argument">--remove-all-tags</span> and/or <ahref="#metaflac_options_no_utf8_convert"><spanclass="argument">--no-utf8-convert</span></a> before <spanclass="argument">--import-tags-from</span> if necessary. If <spanclass="argument">FILE</span> is <spanclass="argument">-</span> (stdin), only one FLAC file may be specified.
Export tags to a file. Use <spanclass="argument">-</span> for stdin. Each line will be of the form <spanclass="argument">NAME=VALUE</span>. Specify <ahref="#metaflac_options_no_utf8_convert"><spanclass="argument">--no-utf8-convert</span></a> if necessary.
Import a cuesheet from a file. Use <spanclass="argument">-</span> for stdin. Only one FLAC file may be specified. A seekpoint will be added for each index point in the cuesheet to the <spanclass="code">SEEKTABLE</span> unless <spanclass="argument">--no-cued-seekpoints</span> is specified.
Export <spanclass="code">CUESHEET</span> block to a cuesheet file, suitable for use by CD authoring software. Use <spanclass="argument">-</span> for stdout. Only one FLAC file may be specified on the command line.
Import a picture and store it in a <ahref="format.html#def_PICTURE"><spanclass="code">PICTURE</span></a> metadata block. See the <spanclass="commandname">flac</span> option <spanclass="argument"><ahref="#flac_options_picture">--picture</a></span> for an explanation of the <spanclass="argument">SPECIFICATION</span> syntax.
Export <spanclass="code">PICTURE</span> block to a file. Use <spanclass="argument">-</span> for stdout. Only one FLAC file may be specified on the command line. The first <spanclass="code">PICTURE</span> block will be exported unless <spanclass="argument">--export-picture-to</span> is preceded by a <spanclass="argument">--block-number=#</span> option to specify the exact metadata block to extract. Note that the block number is the one shown by --list.
Calculates the title and album gains/peaks of the given FLAC files as if all the files were part of one album, then stores them in the <spanclass="code">VORBIS_COMMENT</span> block. The tags are the same as those used by <spanclass="commandname">vorbisgain</span>. Existing ReplayGain tags will be replaced. If only one FLAC file is given, the album and title gains will be the same. Since this operation requires two passes, it is always executed last, after all other operations have been completed and written to disk. All FLAC files specified must have the same resolution, sample rate, and number of channels. The sample rate must be one of 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, or 48 kHz.
Add seek points to a <spanclass="code">SEEKTABLE</span> block:<br/>
<ul>
<li>
<spanclass="argument"># </span> : a specific sample number for a seek point
</li>
<li>
<spanclass="argument">X </span> : a placeholder point (always goes at the end of the <spanclass="code">SEEKTABLE</span>)
</li>
<li>
<spanclass="argument">#x</span> : # evenly spaced seekpoints, the first being at sample 0
</li>
<li>
<spanclass="argument">#s</span> : a seekpoint every # seconds; # does not have to be a whole number, it can be, for example, <spanclass="argument">9.5</span>, meaning a seekpoint every 9.5 seconds
</li>
</ul>
If no <spanclass="code">SEEKTABLE</span> block exists, one will be created. If one already exists, points will be added to the existing table, and any duplicates will be turned into placeholder points.<br/>
You may use many <spanclass="argument">--add-seekpoint</span> options; the resulting <spanclass="code">SEEKTABLE</span> will be the unique-ified union of all such values. Example: <spanclass="argument">--add-seekpoint=100x --add-seekpoint=3.5s</span> will add 100 evenly spaced seekpoints and a seekpoint every 3.5 seconds.<br/>
Add a padding block of the given length (in bytes). The overall length of the new block will be 4 + length; the extra 4 bytes is for the metadata block header.
List the contents of one or more metadata blocks to stdout. By default, all metadata blocks are listed in text format. Use the following options to change this behavior:<br/><br/>
An optional comma-separated list of block types to be included or ignored with this option. Use only one of <spanclass="argument">--block-type</span> or <spanclass="argument">--except-block-type</span>. The valid block types are: <spanclass="code">STREAMINFO</span>, <spanclass="code">PADDING</span>, <spanclass="code">APPLICATION</span>, <spanclass="code">SEEKTABLE</span>, <spanclass="code">VORBIS_COMMENT</span>. You may narrow down the types of <spanclass="code">APPLICATION</span> blocks displayed as follows:<br/>
<td>The <spanclass="code">APPLICATION</span> block(s) whose hexadecimal big- endian representation of the 4-byte ID is "0xXXXXXXXX". For the example "abcd" above the hexadecimal equivalalent is 0x61626364</td>
NOTE: if both <spanclass="argument">--block-number</span> and <spanclass="argument">--[except-]block-type</span> are specified, the result is the logical AND of both arguments.<br/><br/>
If the application block you are displaying contains binary data but your <spanclass="argument">--data-format=text</span>, you can display a hex dump of the application data contents instead using <spanclass="argument">--application-data-format=hexdump</span>.
Remove one or more metadata blocks from the metadata. Unless <spanclass="argument">--dont-use-padding</span> is specified, the blocks will be replaced with padding. You may not remove the <spanclass="code">STREAMINFO</span> block.<br/><br/>
NOTE: if both <spanclass="argument">--block-number</span> and <spanclass="argument">--[except-]block-type</span> are specified, the result is the logical AND of both arguments.
Remove all metadata blocks (except the <spanclass="code">STREAMINFO</span> block) from the metadata. Unless <spanclass="argument">--dont-use-padding</span> is specified, the blocks will be replaced with padding.
All that is necessary is to copy <spanclass="code">libxmms-flac.so</span> to the directory where XMMS looks for input plugins (usually <spanclass="code">/usr/lib/xmms/Input</span> or <spanclass="code">$HOME/.xmms/Input</span>). There is nothing else to configure. Make sure to restart XMMS before trying to play any <spanclass="code">.flac</span> files.
</div>
<divclass="box_footer"></div>
</div>
<br/>
<divclass="box">
<divclass="box_title">
<aname="winamp2_plugin">winamp2 plugin</a>
</div>
<divclass="box_header"></div>
<divclass="box_body">
The Winamp plugin should work for both Winamp2 and Winamp5. If you are using Winamp 2.x, all that is necessary is to copy <spanclass="code">in_flac.dll</span> to the <spanclass="code">Plugins/</span> directory of your Winamp installation. There is nothing else to configure. Make sure to restart Winamp before trying to play any <spanclass="code">.flac</span> files.
</div>
<divclass="box_footer"></div>
</div>
<br/>
<divclass="box">
<divclass="box_title">
<aname="bugs">known bugs</a>
</div>
<divclass="box_header"></div>
<divclass="box_body">
Bug tracking is done on the Sourceforge project page <ahref="http://sourceforge.net/bugs/?group_id=13478">here</a>. If you submit a bug, make sure and provide an email contact or use the Monitor feature.
All decoders prior to and including 1.0.4 have a bug that prevents them from skipping unknown metadata blocks properly. A FLAC file created by flac 1.1.0 containing a <spanclass="code">CUESHEET</span> metadata block will not decode in 1.0.x decoders.
</li>
<li>
<spanclass="commandname">metaflac</span> has a bug where, if --import-vc-from is used on a FLAC file that has no Vorbis comment block, the FLAC file can be corrupted. All FLAC files generated by 1.0.4 have a Vorbis comment block added automatically but files from 1.0.3 and before do not. This is fixed in CVS.
</li>
<li>
There is an odd bug in <spanclass="commandname">metaflac</span> such that you must always use the <spanclass="argument">--dont-use-padding</span> option with <spanclass="argument">--add-padding</span> or the padding block won't be written. This is fixed in CVS.
Monkey's Audio comes with a nice GUI that many people are familiar with. It supports some external encoders, but not FLAC. However, the FLAC Windows distribution comes with a utility that allows you to replace one the of the supported lossless external codecs with FLAC. Here's how:
<li>Copy <spanclass="commandname">flac.exe</span> and <spanclass="commandname">flac_ren.exe</span> to the <spanclass="code">External/</span> directory of the Monkey's Audio installation.</li>
<li>Shorten - copy <spanclass="commandname">flac_mac.exe</span> on top of <spanclass="commandname">External/shortn32.exe</span></li>
<li>WavPack - copy <spanclass="commandname">flac_mac.exe</span> on top of both <spanclass="commandname">External/wavpack.exe</span> and <spanclass="commandname">External/wvunpack.exe</span></li>
<li>RKAU - copy <spanclass="commandname">flac_mac.exe</span> on top of <spanclass="commandname">External/rkau.exe</span></li>
<li>Now you can encode FLAC files as if you were using the replaced encoder. The renamed <spanclass="commandname">flac_mac.exe</span> utility will call <spanclass="commandname">flac.exe</span> and afterwards, <spanclass="commandname">flac_ren.exe</span> will rename the resulting file to have the .flac extension.</li>
</ul>
Other front-ends may be wedged in the same way; if you have one in mind, post it to the <ahref="http://lists.sourceforge.net/lists/listinfo/flac-dev">flac-dev</a> mailing list.