<li>Better multichannel support</li>
<li>Large file (>2GB) support everywhere</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>
- <li>New <a href="format.html#def_PICTURE"><span class="code">PICTURE</span></a> metadata block for storing things like cover art, new <span class="argument"><a href="documentation.html#flac_options_picture">--picture</a></span> option to <span class="commandname">flac</span> and <span class="argument"><a href="documentation.html#metaflac_shorthand_import_picture">--import-picture</a></span> option to <span class="commandname">metaflac</span> for importing pictures, and metadata API <a href="api/group__flac__metadata__level0.html#ga3">additions</a> for searching for suitable pictures based on type, size and color constraints.</li>
+ <li>New <a href="format.html#def_PICTURE"><span class="code">PICTURE</span></a> metadata block for storing things like cover art, new <span class="argument"><a href="documentation.html#flac_options_picture">--picture</a></span> option to <span class="commandname">flac</span> and <span class="argument"><a href="documentation.html#metaflac_shorthand_import_picture">--import-picture</a></span> option to <span class="commandname">metaflac</span> for importing pictures, new <a href="documentation.html#metaflac_shorthand_export_picture_to">--export-picture-to</a></span> option to <span class="commandname">metaflac</span> for exporting pictures, and metadata API <a href="api/group__flac__metadata__level0.html#ga3">additions</a> for searching for suitable pictures based on type, size and color constraints.</li>
<li>Support for new <tt>REPLAYGAIN_REFERENCE_LOUDNESS</tt> tag.</li>
<li>In the developer libraries, the interface has been simplfied by merging the three decoding layers into a single class; ditto for the encoders. Also, libOggFLAC has been merged into libFLAC and libOggFLAC++ has been merged into libFLAC++ so there is a single API supporting both native FLAC and Ogg FLAC.</li>
</ul>
<ul>
<li>Added a new option <a href="documentation.html#metaflac_shorthand_set_tag_from_file"><span class="argument">--set-tag-from-file</span></a> for setting a tag from file (e.g. for importing a cuesheet as a tag).</li>
<li>Added a new option <span class="argument"><a href="documentation.html#metaflac_shorthand_import_picture">--import-picture</a></span> for importing pictures.</li>
+ <li>Added a new option <span class="argument"><a href="documentation.html#metaflac_shorthand_export_picture_to">--export-picture-to</a></span> for exporting pictures.</li>
<li>Added shorthand operation <a href="documentation.html#metaflac_shorthand_remove_replay_gain"><span class="argument">--remove-replay-gain</span></a> for removing ReplayGain tags.</li>
<li><a href="documentation.html#metaflac_shorthand_export_cuesheet_to"><span class="argument">--export-cuesheet-to</span></a> now properly specifies the FLAC file name (<a href="https://sourceforge.net/tracker/index.php?func=detail&aid=1272825&group_id=13478&atid=363478">SF #1272825</a>).</li>
<li>Importing of non-CDDA-compliant cuesheets now issues a warning.</li>
<span class="argument">--import-tags-from=FILE</span>
</td>
<td>
- Import tags from a file. Use '-' for stdin. Each line should be of the form <span class="argument">NAME=VALUE</span>. Multi-line comments are currently not supported. Specify <span class="argument">--remove-all-tags</span> and/or <a href="#metaflac_options_no_utf8_convert"><span class="argument">--no-utf8-convert</span></a> before <span class="argument">--import-tags-from</span> if necessary.
+ Import tags from a file. Use <span class="argument">-</span> for stdin. Each line should be of the form <span class="argument">NAME=VALUE</span>. Multi-line comments are currently not supported. Specify <span class="argument">--remove-all-tags</span> and/or <a href="#metaflac_options_no_utf8_convert"><span class="argument">--no-utf8-convert</span></a> before <span class="argument">--import-tags-from</span> if necessary.
</td>
</tr>
<tr>
<span class="argument">--export-tags-to=FILE</span>
</td>
<td>
- Export tags to a file. Use '-' for stdin. Each line will be of the form <span class="argument">NAME=VALUE</span>. Specify <a href="#metaflac_options_no_utf8_convert"><span class="argument">--no-utf8-convert</span></a> if necessary.
+ Export tags to a file. Use <span class="argument">-</span> for stdin. Each line will be of the form <span class="argument">NAME=VALUE</span>. Specify <a href="#metaflac_options_no_utf8_convert"><span class="argument">--no-utf8-convert</span></a> if necessary.
</td>
</tr>
<tr>
<span class="argument">--import-cuesheet-from=FILE</span>
</td>
<td>
- Import a cuesheet from a file. Use '-' for stdin. Only one FLAC file may be specified. A seekpoint will be added for each index point in the cuesheet to the <span class="code">SEEKTABLE</span> unless <span class="argument">--no-cued-seekpoints</span> is specified.
+ Import a cuesheet from a file. Use <span class="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 <span class="code">SEEKTABLE</span> unless <span class="argument">--no-cued-seekpoints</span> is specified.
</td>
</tr>
<tr>
<span class="argument">--export-cuesheet-to=FILE</span>
</td>
<td>
- Export <span class="code">CUESHEET</span> block to a cuesheet file, suitable for use by CD authoring software. Use '-' for stdout. Only one FLAC file may be specified on the command line.
+ Export <span class="code">CUESHEET</span> block to a cuesheet file, suitable for use by CD authoring software. Use <span class="argument">-</span> for stdout. Only one FLAC file may be specified on the command line.
</td>
</tr>
<tr>
Import a picture and store it in a <a href="format.html#def_PICTURE"><span class="code">PICTURE</span></a> metadata block. See the <span class="commandname">flac</span> option <span class="argument"><a href="#flac_options_picture">--picture</a></span> for an explanation of the <span class="argument">SPECIFICATION</span> syntax.
</td>
</tr>
+ <tr>
+ <td nowrap="nowrap" align="right" valign="top" bgcolor="#F4F4CC">
+ <a name="metaflac_shorthand_export_picture_to" />
+ <span class="argument">--export-picture-to=FILE</span>
+ </td>
+ <td>
+ Export <span class="code">PICTURE</span> block to a file. Use <span class="argument">-</span> for stdout. Only one FLAC file may be specified on the command line. The first <span class="code">PICTURE</span> block will be exported unless <span class="argument">--export-picture-to</span> is preceded by a <span class="argument">--block-number=#</span> option to specify the exact metadata block to extract. Note that the block number is the one shown by --list.
+ </td>
+ </tr>
<tr>
<td nowrap="nowrap" align="right" valign="top" bgcolor="#F4F4CC">
<a name="metaflac_shorthand_add_replay_gain" />
<para>The specification "4|-->|CD|320x300x24/173|http://blah.blah/backcover.tiff" 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.</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--export-picture-to=file</option></term>
+ <listitem>
+ <para>
+ Export PICTURE block to a file. Use '-' for stdout. Only one FLAC file may be specified on the command line. The first PICTURE block will be exported unless --export-picture-to is preceded by a --block-number=# option to specify the exact metadata block to extract. Note that the block number is the one shown by --list.
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><option>--add-replay-gain</option></term>
<listitem>
ok = do_shorthand_operation__cuesheet(filename, chain, operation, needs_write);
break;
case OP__IMPORT_PICTURE:
+ case OP__EXPORT_PICTURE_TO:
ok = do_shorthand_operation__picture(filename, chain, operation, needs_write);
break;
case OP__ADD_SEEKPOINT:
#include "share/grabbag.h" /* for grabbag__picture_parse_specification */
static FLAC__bool import_pic_from(const char *filename, FLAC__StreamMetadata **picture, const char *specification, FLAC__bool *needs_write);
+static FLAC__bool export_pic_to(const char *filename, const FLAC__StreamMetadata *picture, const char *pic_filename);
FLAC__bool do_shorthand_operation__picture(const char *filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write)
{
ok = false;
}
}
+ if(ok) {
+ /* check global PICTURE constraints (max 1 block each of type=1 and type=2) */
+ while(FLAC__metadata_iterator_prev(iterator))
+ ;
+ do {
+ FLAC__StreamMetadata *block = FLAC__metadata_iterator_get_block(iterator);
+ if(block->type == FLAC__METADATA_TYPE_PICTURE) {
+ if(block->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD) {
+ if(has_type1) {
+ print_error_with_chain_status(chain, "%s: ERROR: FLAC stream can only have one 32x32 standard icon (type=1) PICTURE block", filename);
+ ok = false;
+ }
+ has_type1 = true;
+ }
+ else if(block->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON) {
+ if(has_type2) {
+ print_error_with_chain_status(chain, "%s: ERROR: FLAC stream can only have one icon (type=2) PICTURE block", filename);
+ ok = false;
+ }
+ has_type2 = true;
+ }
+ }
+ } while(FLAC__metadata_iterator_next(iterator));
+ }
+ break;
+ case OP__EXPORT_PICTURE_TO:
+ {
+ const Argument_BlockNumber *a = operation->argument.export_picture_to.block_number_link;
+ int block_number = (a && a->num_entries > 0)? (int)a->entries[0] : -1;
+ unsigned i = 0;
+ do {
+ FLAC__StreamMetadata *block = FLAC__metadata_iterator_get_block(iterator);
+ if(block->type == FLAC__METADATA_TYPE_PICTURE && (block_number < 0 || i == (unsigned)block_number))
+ picture = block;
+ i++;
+ } while(FLAC__metadata_iterator_next(iterator) && 0 == picture);
+ if(0 == picture) {
+ if(block_number < 0)
+ fprintf(stderr, "%s: ERROR: FLAC file has no PICTURE block\n", filename);
+ else
+ fprintf(stderr, "%s: ERROR: FLAC file has no PICTURE block at block #%d\n", filename, block_number);
+ ok = false;
+ }
+ else
+ ok = export_pic_to(filename, picture, operation->argument.filename.value);
+ }
break;
default:
ok = false;
break;
};
- /* check global PICTURE constraints (max 1 block each of type=1 and type=2) */
- while(FLAC__metadata_iterator_prev(iterator))
- ;
- do {
- FLAC__StreamMetadata *block = FLAC__metadata_iterator_get_block(iterator);
- if(block->type == FLAC__METADATA_TYPE_PICTURE) {
- if(block->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD) {
- if(has_type1) {
- print_error_with_chain_status(chain, "%s: ERROR: FLAC stream can only have one 32x32 standard icon (type=1) PICTURE block", filename);
- ok = false;
- }
- has_type1 = true;
- }
- else if(block->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON) {
- if(has_type2) {
- print_error_with_chain_status(chain, "%s: ERROR: FLAC stream can only have one icon (type=2) PICTURE block", filename);
- ok = false;
- }
- has_type2 = true;
- }
- }
- } while(FLAC__metadata_iterator_next(iterator));
-
-
FLAC__metadata_iterator_delete(iterator);
return ok;
}
*needs_write = true;
return true;
}
+
+FLAC__bool export_pic_to(const char *filename, const FLAC__StreamMetadata *picture, const char *pic_filename)
+{
+ FILE *f;
+ const FLAC__uint32 len = picture->data.picture.data_length;
+
+ if(0 == pic_filename || strlen(pic_filename) == 0) {
+ fprintf(stderr, "%s: ERROR: empty export file name\n", filename);
+ return false;
+ }
+ if(0 == strcmp(pic_filename, "-"))
+ f = stdout;
+ else
+ f = fopen(pic_filename, "w");
+
+ if(0 == f) {
+ fprintf(stderr, "%s: ERROR: can't open export file %s: %s\n", filename, pic_filename, strerror(errno));
+ return false;
+ }
+
+ if(fwrite(picture->data.picture.data, 1, len, f) != len) {
+ fprintf(stderr, "%s: ERROR: writing PICTURE data to file\n", filename);
+ return false;
+ }
+
+ if(f != stdout)
+ fclose(f);
+
+ return true;
+}
{ "import-cuesheet-from", 1, 0, 0 },
{ "export-cuesheet-to", 1, 0, 0 },
{ "import-picture", 1, 0, 0 },
+ { "export-picture-to", 1, 0, 0 },
{ "add-seekpoint", 1, 0, 0 },
{ "add-replay-gain", 0, 0, 0 },
{ "remove-replay-gain", 0, 0, 0 },
static void append_new_argument(CommandLineOptions *options, Argument argument);
static Operation *append_major_operation(CommandLineOptions *options, OperationType type);
static Operation *append_shorthand_operation(CommandLineOptions *options, OperationType type);
+static Argument *find_argument(CommandLineOptions *options, ArgumentType type);
static Operation *find_shorthand_operation(CommandLineOptions *options, OperationType type);
static Argument *append_argument(CommandLineOptions *options, ArgumentType type);
static FLAC__bool parse_md5(const char *src, FLAC__byte dest[16]);
}
/* check for only one FLAC file used with --import-cuesheet-from/--export-cuesheet-to */
- if((0 != find_shorthand_operation(options, OP__IMPORT_CUESHEET_FROM) || 0 != find_shorthand_operation(options, OP__EXPORT_CUESHEET_TO)) && options->num_files > 1) {
- fprintf(stderr, "ERROR: you may only specify one FLAC file when using '--import-cuesheet-from' or '--export-cuesheet-to'\n");
+ if(
+ (
+ 0 != find_shorthand_operation(options, OP__IMPORT_CUESHEET_FROM) ||
+ 0 != find_shorthand_operation(options, OP__EXPORT_CUESHEET_TO) ||
+ 0 != find_shorthand_operation(options, OP__EXPORT_PICTURE_TO)
+ ) && options->num_files > 1
+ ) {
+ fprintf(stderr, "ERROR: you may only specify one FLAC file when using '--import-cuesheet-from', '--export-cuesheet-to' or '--export-picture-to'\n");
had_error = true;
}
if(0 != op->argument.specification.value)
free(op->argument.specification.value);
break;
+ case OP__EXPORT_PICTURE_TO:
+ if(0 != op->argument.export_picture_to.filename)
+ free(op->argument.export_picture_to.filename);
+ break;
case OP__ADD_SEEKPOINT:
if(0 != op->argument.add_seekpoint.specification)
free(op->argument.add_seekpoint.specification);
ok = false;
}
}
+ else if(0 == strcmp(opt, "export-picture-to")) {
+ const Argument *arg = find_argument(options, ARG__BLOCK_NUMBER);
+ op = append_shorthand_operation(options, OP__EXPORT_PICTURE_TO);
+ FLAC__ASSERT(0 != option_argument);
+ if(!parse_string(option_argument, &(op->argument.export_picture_to.filename))) {
+ fprintf(stderr, "ERROR (--%s): missing filename\n", opt);
+ ok = false;
+ }
+ op->argument.export_picture_to.block_number_link = arg? &(arg->value.block_number) : 0;
+ }
else if(0 == strcmp(opt, "add-seekpoint")) {
const char *violation;
char *spec;
return options->ops.operations + (options->ops.num_operations - 1);
}
+Argument *find_argument(CommandLineOptions *options, ArgumentType type)
+{
+ unsigned i;
+ for(i = 0; i < options->args.num_arguments; i++)
+ if(options->args.arguments[i].type == type)
+ return &options->args.arguments[i];
+ return 0;
+}
+
Operation *find_shorthand_operation(CommandLineOptions *options, OperationType type)
{
unsigned i;
OP__IMPORT_CUESHEET_FROM,
OP__EXPORT_CUESHEET_TO,
OP__IMPORT_PICTURE,
+ OP__EXPORT_PICTURE_TO,
OP__ADD_SEEKPOINT,
OP__ADD_REPLAY_GAIN,
OP__ADD_PADDING,
Argument_AddSeekpoint *add_seekpoint_link;
} Argument_ImportCuesheetFrom;
+typedef struct {
+ char *filename;
+ const Argument_BlockNumber *block_number_link; /* may be NULL to mean 'first PICTURE block' */
+} Argument_ExportPictureTo;
+
typedef struct {
unsigned length;
} Argument_AddPadding;
Argument_String filename;
Argument_String specification;
Argument_ImportCuesheetFrom import_cuesheet_from;
+ Argument_ExportPictureTo export_picture_to;
Argument_AddSeekpoint add_seekpoint;
Argument_AddPadding add_padding;
} argument;
fprintf(out, " you should also specify the number of colors used.\n");
fprintf(out, " FILE is the path to the picture file to be imported, or the URL if\n");
fprintf(out, " MIME type is -->\n");
+ fprintf(out, "--export-picture-to=FILE Export PICTURE block to a file. Use '-' for stdout.\n");
+ fprintf(out, " Only one FLAC file may be specified. The first PICTURE\n");
+ fprintf(out, " block will be exported unless --export-picture-to is\n");
+ fprintf(out, " preceded by a --block-number=# option to specify the exact\n");
+ fprintf(out, " metadata block to extract. Note that the block number is\n");
+ fprintf(out, " the one shown by --list.\n");
fprintf(out, "--add-replay-gain Calculates the title and album gains/peaks of the given\n");
fprintf(out, " FLAC files as if all the files were part of one album,\n");
fprintf(out, " then stores them in the VORBIS_COMMENT block. The tags\n");
ncase=`expr $ncase + 1`
done
[ $ncase = 60 ] || die "expected case# to be 60"
+
+fn=export-picture-check
+echo -n "Testing --export-picture-to... "
+run_metaflac --export-picture-to=$fn $flacfile
+check_flac
+cmp $fn pictures/0.gif || die "ERROR, exported picture file and original differ"
+echo OK
+rm -f $fn
+echo -n "Testing --block-number --export-picture-to... "
+run_metaflac --block-number=9 --export-picture-to=$fn $flacfile
+check_flac
+cmp $fn pictures/0.png || die "ERROR, exported picture file and original differ"
+echo OK
+rm -f $fn
+
run_metaflac --remove --block-type=PICTURE $flacfile
check_flac
metaflac_test case60 "--remove --block-type=PICTURE" "--list"