FFMPEG Adding Metadata to an .mp3 From .mp3 Input?
Your ffmpeg build does not have any MP3 encoder. However, for your use case, that's irrelevant.
Use
ffmpeg -i input.mp3 -c copy -metadata artist="Someone" output.mp3
Output has to be a separate file. FFmpeg can't update the input itself.
Related videos on Youtube
Sarah Szabo
Updated on September 18, 2022Comments
-
Sarah Szabo over 1 year
If I start off with a .mp3 file, how can I add metadata to it? I'm aware of the
-metadata title="Some Title" -metadata artist="Someone"
formatting, but not sure how this can be applied to a .mp3 file, especially if the file is already a .mp3.I'm thinking something more like this:
ffmpeg -i input.mp3 -metadata artist="Someone" -f mp3 output.mp3
The only thing is that when I execute this with ffmpeg 4 compiled with all libraries on Kubuntu 18.04, I get this error message:
Automatic encoder selection failed for output stream #0:0. Default encoder for format mp3 (codec mp3) is probably disabled. Please choose an encoder manually.
Error selecting an encoder for stream 0:0Edit 0:
This also happens when I try to add
-acodec libmp3lame
although the error seems to indicate that I don't have the .mp3 codecsarah@ConvergentRefuge:~/Desktop/Indexing/Test Folder$ ffmpeg -i DANCE\ WITH\ THE\ DEAD\ -\ BATTLE.mp3 -acodec libmp3lame -f mp3 file.mp3 ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 7 (Ubuntu 7.3.0-16ubuntu3) configuration: libavutil 56. 14.100 / 56. 14.100 libavcodec 58. 18.100 / 58. 18.100 libavformat 58. 12.100 / 58. 12.100 libavdevice 58. 3.100 / 58. 3.100 libavfilter 7. 16.100 / 7. 16.100 libswscale 5. 1.100 / 5. 1.100 libswresample 3. 1.100 / 3. 1.100 Input #0, mp3, from 'DANCE WITH THE DEAD - BATTLE.mp3': Duration: 00:04:15.92, start: 0.025057, bitrate: 128 kb/s Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s Metadata: encoder : LAME3.99r Side data: replaygain: track gain - -9.200000, track peak - unknown, album gain - unknown, album peak - unknown, Unknown encoder 'libmp3lame'
-
Scott - Слава Україні almost 5 yearsThanks (I guess?) for the complete, working script, but it might be more helpful to (1) present and explain the
ffmpeg
command at the core of the script, and (2) explain the rest of what the script is doing. Also, (3) when you have a command that’s 352 characters long, it’s nice to break it up into shorter lines. And (4) I noticed that yourffmpeg
command quotes"$z"
(and"$metadataTPE2"
,"$metadataComposer"
,"$metadataGenre"
and"$metadataYear"
) but not$z.mp3
. … (Cont’d) -
Scott - Слава Україні almost 5 years(Cont’d) … (5) Finally, most importantly, it looks like your
ffmpeg
command takes.wav
files as input and produces.mp3
files as output. But the question asks how to take.mp3
files as input and produce.mp3
files as output. (6) P.S. Arithmetic Expansion is specified by POSIX, butlet
and++
are not. (7) P.P.S. How can that script even work when it says things likecounterTotalFiles = 0
(with spaces)?