Commit bfda3788 authored by Josh Coalson's avatar Josh Coalson

add support for encoding from FLAC to FLAC while preserving metadata

parent ff151cc7
......@@ -67,6 +67,7 @@
<ul>
<li>Large file (&gt;2GB) support everywhere</li>
<li>Much better recovery for corrupted files</li>
<li><span class="commandname">flac</span> now supports FLAC as input to the encoder (i.e. can re-encode FLAC to FLAC) and preserve all the metadata like tags, etc.</li>
</ul>
</li>
<li>
......@@ -85,6 +86,7 @@
flac:
<ul>
<li>Improved the <a href="documentation.html#flac_options_decode_through_errors"><span class="argument">-F</span></a> to allow decoding of FLAC files whose metadata is corrupted, and other kinds of corruption.</li>
<li>Encoder can now take FLAC as input. The output FLAC file will have all the same metadata as the original unless overridden with options on the command line.</li>
<li>Added a new option <a href="documentation.html#flac_options_tag_from_file"><span class="argument">--tag-from-file</span></a> for setting a tag from file (e.g. for importing a cuesheet as a tag).</li>
<li>Added support for encoding from non-compressed AIFF-C (<a href="https://sourceforge.net/tracker/?func=detail&amp;atid=113478&amp;aid=1090933&amp;group_id=13478">SF #1090933</a>).</li>
<li>Importing of non-CDDA-compliant cuesheets now only issues a warning, not an error (see <a href="http://www.hydrogenaudio.org/forums/index.php?showtopic=31282">here</a>).</li>
......
......@@ -142,9 +142,9 @@
</div>
<div class="box_header"></div>
<div class="box_body">
<span class="commandname">flac</span> is the command-line file encoder/decoder. The input to the encoder and the output to the decoder must either be RIFF WAVE format, AIFF, or raw interleaved sample data. <span class="commandname">flac</span> only supports linear PCM samples (in other words, no A-LAW, uLAW, etc.). Another restriction (hopefully short-term) is that the input must be 8, 16, or 24 bits per sample. This is not a limitation of the FLAC format, just the reference encoder/decoder.
<span class="commandname">flac</span> is the command-line file encoder/decoder. The encoder currently supports as input RIFF WAVE, AIFF, or FLAC format, or raw interleaved samples. The decoder currently can output to RIFF WAVE or AIFF format, or raw interleaved samples. <span class="commandname">flac</span> only supports linear PCM samples (in other words, no A-LAW, uLAW, etc.). Another restriction (hopefully short-term) is that the input must be 8, 16, or 24 bits per sample. This is not a limitation of the FLAC format, just the reference encoder/decoder.
<br /><br />
<span class="commandname">flac</span> assumes that files ending in ".wav" or that have the RIFF WAVE header present are WAVE files, and files ending in ".aif" or ".aiff" or have the AIFF header present are in AIFF files. This may be overridden with a command-line option. It also assumes that files ending in ".ogg" are Ogg FLAC files. Other than this, <span class="commandname">flac</span> makes no assumptions about file extensions, though the convention is that FLAC files have the extension ".flac" (or ".fla" on ancient file systems like FAT-16).
<span class="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" are Ogg FLAC files. Other than this, <span class="commandname">flac</span> makes no assumptions about file extensions, though the convention is that FLAC files have the extension ".flac" (or ".fla" on ancient file systems like FAT-16).
<br /><br />
Before going into the full command-line description, a few other things help to sort it out: 1) <span class="commandname">flac</span> encodes by default, so you must use <b>-d</b> to decode; 2) the options <span class="argument">-0</span> .. <span class="argument">-8</span> (or <span class="argument">--fast</span> and <span class="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) <span class="commandname">flac</span> behaves similarly to gzip in the way it handles input and output files.
<br /><br />
......@@ -197,6 +197,8 @@
<br /><br />
In test mode, <span class="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.
<br /><br />
<span class="commandname">flac</span> can also re-encode FLAC files. In other words, you can specify a 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.).
<br /><br />
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
<table width="100%" border="1" bgcolor="#EEEED4">
......
......@@ -50,6 +50,7 @@
<arg><replaceable>infile.wav</replaceable></arg>
<arg><replaceable>infile.aiff</replaceable></arg>
<arg><replaceable>infile.raw</replaceable></arg>
<arg><replaceable>infile.flac</replaceable></arg>
<arg>-</arg>
</group>
</cmdsynopsis>
......@@ -71,10 +72,6 @@
encoding, decoding, testing and analyzing FLAC streams.
</para>
<para>This manual page was originally written for the &debian;
distribution because the original program did not have a
manual page.</para>
</refsect1>
<refsect1>
<title>OPTIONS</title>
......
This diff is collapsed.
......@@ -31,6 +31,8 @@
#include <config.h>
#endif
extern const int FLAC_ENCODE__DEFAULT_PADDING;
typedef struct {
utils__SkipUntilSpecification skip_specification;
utils__SkipUntilSpecification until_specification;
......@@ -89,8 +91,13 @@ typedef struct {
unsigned sample_rate;
} raw_encode_options_t;
typedef struct {
encode_options_t common;
} flac_encode_options_t;
int flac__encode_aif(FILE *infile, off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, wav_encode_options_t options, FLAC__bool is_aifc);
int flac__encode_wav(FILE *infile, off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, wav_encode_options_t options);
int flac__encode_raw(FILE *infile, off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, raw_encode_options_t options);
int flac__encode_flac(FILE *infile, off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, flac_encode_options_t options);
#endif
This diff is collapsed.
......@@ -17,7 +17,7 @@
TESTS_ENVIRONMENT = FLAC__TEST_LEVEL=@FLAC__TEST_LEVEL@ FLAC__TEST_WITH_VALRGIND=@FLAC__TEST_WITH_VALGRIND@
SUBDIRS = cuesheets
SUBDIRS = cuesheets flac-to-flac-metadata-test-files metaflac-test-files
if FLaC__HAS_OGG
OGG_TESTS = \
......
......@@ -54,4 +54,4 @@ valgrind: all
release : all
clean:
rm -f *.raw *.flac *.ogg *.cmp *.aiff *.wav *.diff *.log *.cue core
rm -f *.raw *.flac *.ogg *.cmp *.aiff *.wav *.diff *.log *.cue core flac-to-flac-metadata-test-files/out.* metaflac-test-files/out.*
# FLAC - Free Lossless Audio Codec
# Copyright (C) 2006 Josh Coalson
#
# This file is part the FLAC project. FLAC is comprised of several
# components distributed under difference licenses. The codec libraries
# are distributed under Xiph.Org's BSD-like license (see the file
# COPYING.Xiph in this distribution). All other programs, libraries, and
# plugins are distributed under the GPL (see COPYING.GPL). The documentation
# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
# FLAC distribution contains at the top the terms under which it may be
# distributed.
#
# Since this particular file is relevant to all components of FLAC,
# it may be distributed under the Xiph.Org license, which is the least
# restrictive of those mentioned above. See the file COPYING.Xiph in this
# distribution.
EXTRA_DIST = \
case00a-expect.meta \
case01a-expect.meta \
case01b-expect.meta \
case02a-expect.meta \
case02b-expect.meta \
case03a-expect.meta \
case03b-expect.meta \
case03c-expect.meta \
case04a-expect.meta \
case04b-expect.meta \
case04c-expect.meta \
case05a-expect.meta \
case05b-expect.meta \
case05c-expect.meta \
case05d-expect.meta \
case05e-expect.meta \
input-SCPAP.flac \
input-SCVA.flac \
input-SCVAUP.flac \
input-SCVPAP.flac \
input-SVAUP.flac \
input-VA.flac \
input0.cue
CLEANFILES = \
$(wildcard out.*)
METADATA block #0
type: 0 (STREAMINFO)
is last: false
length: 34
sample_rate: 44100 Hz
channels: 2
bits-per-sample: 16
total samples: 5880
MD5 signature: 74ffd4737eb5488d512be4af58943362
METADATA block #1
type: 3 (SEEKTABLE)
is last: false
length: 180
seek points: 10
point 0: sample_number=0
point 1: sample_number=4608
point 2: PLACEHOLDER
point 3: PLACEHOLDER
point 4: PLACEHOLDER
point 5: PLACEHOLDER
point 6: PLACEHOLDER
point 7: PLACEHOLDER
point 8: PLACEHOLDER
point 9: PLACEHOLDER
METADATA block #2
type: 5 (CUESHEET)
is last: false
length: 540
media catalog number: 1234567890123
lead-in: 88200
is CD: true
number of tracks: 3
track[0]
offset: 0
number: 1
ISRC:
type: AUDIO
pre-emphasis: false
number of index points: 2
index[0]
offset: 0
number: 1
index[1]
offset: 588
number: 2
track[1]
offset: 2940
number: 2
ISRC:
type: AUDIO
pre-emphasis: false
number of index points: 1
index[0]
offset: 0
number: 1
track[2]
offset: 5880
number: 170 (LEAD-OUT)
METADATA block #3
type: 4 (VORBIS_COMMENT)
is last: false
length: 203
comments: 6
comment[0]: REPLAYGAIN_TRACK_PEAK=0.99996948
comment[1]: REPLAYGAIN_TRACK_GAIN=-7.89 dB
comment[2]: REPLAYGAIN_ALBUM_PEAK=0.99996948
comment[3]: REPLAYGAIN_ALBUM_GAIN=-7.89 dB
comment[4]: artist=1
comment[5]: title=2
METADATA block #4
type: 2 (APPLICATION)
is last: false
length: 4
application ID: 66616b65
data contents:
METADATA block #5
type: 126 (UNKNOWN)
is last: false
length: 0
data contents:
METADATA block #6
type: 1 (PADDING)
is last: true
length: 3201
METADATA block #0
type: 0 (STREAMINFO)
is last: false
length: 34
sample_rate: 44100 Hz
channels: 2
bits-per-sample: 16
total samples: 5880
MD5 signature: 74ffd4737eb5488d512be4af58943362
METADATA block #1
type: 3 (SEEKTABLE)
is last: false
length: 180
seek points: 10
point 0: sample_number=0
point 1: sample_number=4608
point 2: PLACEHOLDER
point 3: PLACEHOLDER
point 4: PLACEHOLDER
point 5: PLACEHOLDER
point 6: PLACEHOLDER
point 7: PLACEHOLDER
point 8: PLACEHOLDER
point 9: PLACEHOLDER
METADATA block #2
type: 5 (CUESHEET)
is last: false
length: 540
media catalog number: 1234567890123
lead-in: 88200
is CD: true
number of tracks: 3
track[0]
offset: 0
number: 1
ISRC:
type: AUDIO
pre-emphasis: false
number of index points: 2
index[0]
offset: 0
number: 1
index[1]
offset: 588
number: 2
track[1]
offset: 2940
number: 2
ISRC:
type: AUDIO
pre-emphasis: false
number of index points: 1
index[0]
offset: 0
number: 1
track[2]
offset: 5880
number: 170 (LEAD-OUT)
METADATA block #3
type: 4 (VORBIS_COMMENT)
is last: false
length: 203
comments: 6
comment[0]: REPLAYGAIN_TRACK_PEAK=0.99996948
comment[1]: REPLAYGAIN_TRACK_GAIN=-7.89 dB
comment[2]: REPLAYGAIN_ALBUM_PEAK=0.99996948
comment[3]: REPLAYGAIN_ALBUM_GAIN=-7.89 dB
comment[4]: artist=1
comment[5]: title=2
METADATA block #4
type: 2 (APPLICATION)
is last: false
length: 4
application ID: 66616b65
data contents:
METADATA block #5
type: 1 (PADDING)
is last: true
length: 3205
METADATA block #0
type: 0 (STREAMINFO)
is last: false
length: 34
sample_rate: 44100 Hz
channels: 2
bits-per-sample: 16
total samples: 5880
MD5 signature: 74ffd4737eb5488d512be4af58943362
METADATA block #1
type: 3 (SEEKTABLE)
is last: false
length: 180
seek points: 10
point 0: sample_number=0
point 1: sample_number=4608
point 2: PLACEHOLDER
point 3: PLACEHOLDER
point 4: PLACEHOLDER
point 5: PLACEHOLDER
point 6: PLACEHOLDER
point 7: PLACEHOLDER
point 8: PLACEHOLDER
point 9: PLACEHOLDER
METADATA block #2
type: 5 (CUESHEET)
is last: false
length: 540
media catalog number: 1234567890123
lead-in: 88200
is CD: true
number of tracks: 3
track[0]
offset: 0
number: 1
ISRC:
type: AUDIO
pre-emphasis: false
number of index points: 2
index[0]
offset: 0
number: 1
index[1]
offset: 588
number: 2
track[1]
offset: 2940
number: 2
ISRC:
type: AUDIO
pre-emphasis: false
number of index points: 1
index[0]
offset: 0
number: 1
track[2]
offset: 5880
number: 170 (LEAD-OUT)
METADATA block #3
type: 4 (VORBIS_COMMENT)
is last: false
length: 203
comments: 6
comment[0]: REPLAYGAIN_TRACK_PEAK=0.99996948
comment[1]: REPLAYGAIN_TRACK_GAIN=-7.89 dB
comment[2]: REPLAYGAIN_ALBUM_PEAK=0.99996948
comment[3]: REPLAYGAIN_ALBUM_GAIN=-7.89 dB
comment[4]: artist=1
comment[5]: title=2
METADATA block #4
type: 2 (APPLICATION)
is last: true
length: 4
application ID: 66616b65
data contents:
METADATA block #0
type: 0 (STREAMINFO)
is last: false
length: 34
sample_rate: 44100 Hz
channels: 2
bits-per-sample: 16
total samples: 5880
MD5 signature: 74ffd4737eb5488d512be4af58943362
METADATA block #1
type: 3 (SEEKTABLE)
is last: false
length: 180
seek points: 10
point 0: sample_number=0
point 1: sample_number=4608
point 2: PLACEHOLDER
point 3: PLACEHOLDER
point 4: PLACEHOLDER
point 5: PLACEHOLDER
point 6: PLACEHOLDER
point 7: PLACEHOLDER
point 8: PLACEHOLDER
point 9: PLACEHOLDER
METADATA block #2
type: 5 (CUESHEET)
is last: false
length: 540
media catalog number: 1234567890123
lead-in: 88200
is CD: true
number of tracks: 3
track[0]
offset: 0
number: 1
ISRC:
type: AUDIO
pre-emphasis: false
number of index points: 2
index[0]
offset: 0
number: 1
index[1]
offset: 588
number: 2
track[1]
offset: 2940
number: 2
ISRC:
type: AUDIO
pre-emphasis: false
number of index points: 1
index[0]
offset: 0
number: 1
track[2]
offset: 5880
number: 170 (LEAD-OUT)
METADATA block #3
type: 4 (VORBIS_COMMENT)
is last: false
length: 203
comments: 6
comment[0]: REPLAYGAIN_TRACK_PEAK=0.99996948
comment[1]: REPLAYGAIN_TRACK_GAIN=-7.89 dB
comment[2]: REPLAYGAIN_ALBUM_PEAK=0.99996948
comment[3]: REPLAYGAIN_ALBUM_GAIN=-7.89 dB
comment[4]: artist=1
comment[5]: title=2
METADATA block #4
type: 2 (APPLICATION)
is last: false
length: 4
application ID: 66616b65
data contents:
METADATA block #5
type: 1 (PADDING)
is last: true
length: 1234
METADATA block #0
type: 0 (STREAMINFO)
is last: false
length: 34
sample_rate: 44100 Hz
channels: 2
bits-per-sample: 16
total samples: 5880
MD5 signature: 74ffd4737eb5488d512be4af58943362
METADATA block #1
type: 3 (SEEKTABLE)
is last: false
length: 180
seek points: 10
point 0: sample_number=0
point 1: sample_number=4608
point 2: PLACEHOLDER
point 3: PLACEHOLDER
point 4: PLACEHOLDER
point 5: PLACEHOLDER
point 6: PLACEHOLDER
point 7: PLACEHOLDER
point 8: PLACEHOLDER
point 9: PLACEHOLDER
METADATA block #2
type: 5 (CUESHEET)
is last: false
length: 540
media catalog number: 1234567890123
lead-in: 88200
is CD: true
number of tracks: 3
track[0]
offset: 0
number: 1
ISRC:
type: AUDIO
pre-emphasis: false
number of index points: 2
index[0]
offset: 0
number: 1
index[1]
offset: 588
number: 2
track[1]
offset: 2940
number: 2
ISRC:
type: AUDIO
pre-emphasis: false
number of index points: 1
index[0]
offset: 0
number: 1
track[2]
offset: 5880
number: 170 (LEAD-OUT)
METADATA block #3
type: 4 (VORBIS_COMMENT)
is last: false
length: 203
comments: 6
comment[0]: REPLAYGAIN_TRACK_PEAK=0.99996948
comment[1]: REPLAYGAIN_TRACK_GAIN=-7.89 dB
comment[2]: REPLAYGAIN_ALBUM_PEAK=0.99996948
comment[3]: REPLAYGAIN_ALBUM_GAIN=-7.89 dB
comment[4]: artist=1
comment[5]: title=2
METADATA block #4
type: 2 (APPLICATION)
is last: false
length: 4
application ID: 66616b65
data contents:
METADATA block #5
type: 1 (PADDING)
is last: true
length: 1234
METADATA block #0
type: 0 (STREAMINFO)
is last: false
length: 34
sample_rate: 44100 Hz
channels: 2
bits-per-sample: 16
total samples: 5880
MD5 signature: 74ffd4737eb5488d512be4af58943362
METADATA block #1
type: 3 (SEEKTABLE)
is last: false
length: 180
seek points: 10
point 0: sample_number=0
point 1: sample_number=4608
point 2: PLACEHOLDER
point 3: PLACEHOLDER
point 4: PLACEHOLDER
point 5: PLACEHOLDER
point 6: PLACEHOLDER
point 7: PLACEHOLDER
point 8: PLACEHOLDER
point 9: PLACEHOLDER
METADATA block #2
type: 5 (CUESHEET)
is last: false
length: 540
media catalog number: 1234567890123
lead-in: 88200
is CD: true
number of tracks: 3
track[0]
offset: 0
number: 1
ISRC:
type: AUDIO
pre-emphasis: false
number of index points: 2
index[0]
offset: 0
number: 1
index[1]
offset: 588
number: 2
track[1]
offset: 2940
number: 2
ISRC:
type: AUDIO
pre-emphasis: false
number of index points: 1
index[0]
offset: 0
number: 1
track[2]
offset: 5880
number: 170 (LEAD-OUT)
METADATA block #3
type: 4 (VORBIS_COMMENT)
is last: false
length: 203
comments: 6
comment[0]: REPLAYGAIN_TRACK_PEAK=0.99996948
comment[1]: REPLAYGAIN_TRACK_GAIN=-7.89 dB
comment[2]: REPLAYGAIN_ALBUM_PEAK=0.99996948
comment[3]: REPLAYGAIN_ALBUM_GAIN=-7.89 dB
comment[4]: artist=1
comment[5]: title=2
METADATA block #4
type: 2 (APPLICATION)
is last: false
length: 4
application ID: 66616b65
data contents:
METADATA block #5
type: 1 (PADDING)
is last: true
length: 4096
METADATA block #0
type: 0 (STREAMINFO)
is last: false
length: 34
sample_rate: 44100 Hz
channels: 2
bits-per-sample: 16
total samples: 5880
MD5 signature: 74ffd4737eb5488d512be4af58943362
METADATA block #1
type: 4 (VORBIS_COMMENT)
is last: false
length: 40
comments: 0