Skip to content

metaflac bug - error writing multi-line tag from stdin #232

@audiomuze

Description

@audiomuze

Seeing as there's no option within metaflac to --remove-all-tags-except, in an effort to achieve consistency in tagging I devised a workaround that writes tags to be preserved to stdout and pipes same to another call to metaflac which deletes all tags and then writes back input from stdin.

The general form would be:
metaflac --show-tag tagname1 --show-tag tagname2 --show-tag tagnamex "filename.flac" | metaflac --preserve-modtime --remove-all-tags --import-tags-from=- "filename.flac"

However, I've come up against an issue, as the following call demonstrates:
metaflac --show-tag lyrics x.flac | metaflac --import-tags-from=- x.flac

Running the above should result in the corresponding vorbiscomment simply being rewritten, and it works as intended until it encounters a tag with a CR or LF within the tag, meaning it will not work for the likes of a Lyrics tag, rendering the workaround fruitless.

To illustrate:
metaflac --list x.flac

METADATA block #0
  type: 0 (STREAMINFO)
  is last: false
  length: 34
  minimum blocksize: 4608 samples
  maximum blocksize: 4608 samples
  minimum framesize: 1009 bytes
  maximum framesize: 14722 bytes
  sample_rate: 44100 Hz
  channels: 2
  bits-per-sample: 16
  total samples: 8627724
  MD5 signature: 74bdec14815e8c901cf1f9a87171e2c5
METADATA block #1
  type: 4 (VORBIS_COMMENT)
  is last: false
  length: 73
  vendor string: reference libFLAC 1.3.1 20141125
  comments: 1
    comment[0]: lyrics=FIRST LINE
SECOND LINE
METADATA block #2
  type: 1 (PADDING)
  is last: true
  length: 22445

As soon as there's a CR or LF in a comment, such as in the example above, metaflac fails with the following:

-: ERROR: malformed vorbis comment field "SECOND LINE",
       field contains no '=' character

Is there something more I can do my side to work around this or does this now mean there's no solution until this bug is addressed or something like --remove-all-tags-except is implemented?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions