4

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)

Fred Sobotka
  • 5,252
  • 22
  • 32
Juco
  • 43
  • 4

2 Answers2

3

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
llogan
  • 121,796
  • 28
  • 232
  • 243
  • I'm really glad I found this answer because eyeD3 was very easy to install on my shared webhosting server from an unprivileged account. – Fred Sobotka Aug 18 '22 at 07:19
2

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).

AmigoJack
  • 5,234
  • 1
  • 15
  • 31
  • Trying what you suggest, `ffmpeg -i "sample.wav" -ab 320k -metadata comment='this is test' -write_id3v1 true -id3v2_version 0 "test.mp3"` did not work for me on `ffmpeg version 2022-09-19-git-4ba68639ca-full_build-www.gyan.dev` on Windows 10 Command Prompt. I get the error: `Unable to find a suitable output format for 'is' is: Invalid argument` (There is no such thing as official builds for Windows anymore. The only two builds that are linked on the FFmpeg site are from BtbN and gyan.dev.) – Arete Sep 21 '22 at 12:24
  • You are right: I've correct the example from `comment='with space'` to `"comment=with space"` for Windows 7x64 as per [BtbN release](https://github.com/BtbN/FFmpeg-Builds/releases). Older versions behave the same - I must have copied OP's example without actually using spaces myself. – AmigoJack Sep 21 '22 at 13:45