Juco
Juco

Reputation: 43

Can't give metadata of comment to MP3 file using ffmpeg

I want to covert an AAC audio file to MP3 and add a comment in the metadata of the MP3 file using ffmpeg.
The -metadata comment option doesn't work and ffmpeg doesn't return an error.

The complete command I'm running is ffmpeg -i "test.aac" -ab 128k -metadata comment='this is test' "test.mp3"

I also tried -metadata description='this is test' and even updated ffmpeg. Other options such as -metadata artist and -metadata album work well.

What's wrong with this approach?

Output

Stream mapping:
  Stream #0:0 -> #0:0 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, mp3, to 'test.mp3':
  Metadata:
    description     : this is test
    TSSE            : Lavf58.29.100
    Stream #0:0: Audio: mp3 (libmp3lame), 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.54.100 libmp3lame

Environment
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple clang version 11.0.3 (clang-1103.0.32.59)

Upvotes: 4

Views: 2413

Answers (2)

AmigoJack
AmigoJack

Reputation: 6099

ffmpeg by default writes an ID3v2 tag to MP3 output files. As of version 4.3.1 (or even snapshot 2021-02-10 and 2022-09-20) it is still wrongly written as a TXXX frame instead of COMM - /libavformat/id3v2.c does nowhere handle the needed association, and /libavformat/id3v2enc.c indicates that the -comment parameter is only used when providing a graphic to embed (i.e. album cover).

As an alternative you could force an ID3v1 tag (with all its shortcomings). You must also disable an ID3v2 tag creation, as almost every software encountering both ID3 versions prefers data from v2 over v1. The parameters to be added would be -write_id3v1 true -id3v2_version 0, so the overall execution is (on Windows):

ffmpeg -i "test.aac" -ab 128k -metadata "comment=this is a test" -write_id3v1 true -id3v2_version 0 "test.mp3"

This works as expected: no ID3v2 tag, only an ID3v1 tag where only the comment is filled. The quotation marks starting before comment and ending after test are needed so Windows knows where that one whole parameter starts and where it ends (and not with the next space character, as per default - that's also the reason why filenames should go into quotation marks).

Upvotes: 3

llogan
llogan

Reputation: 133703

Possible bug. ffmpeg is writing comment metadata as user text frame (TXXX) instead of the expected comment (COMM).

For now I suggest using a different tool for comment tag. eyeD3 example:

eyeD3 --comment "added a comment" input.mp3

Upvotes: 3

Related Questions