xiph / xiph/flac

metaflac bug - error writing multi-line tag from stdin

Open
#232 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
2.4k
Forks
363
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the documented metaflac pipeline using a FLAC file whose lyrics tag contains multiple lines, then trace the tag-import path that parses stdin. Compare the exported multiline comment with the format expected by --import-tags-from=-; done means the command preserves multiline tags without reporting a malformed field.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
audio-video-rtc, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.