FFMPEG Adding Metadata to an .mp3 From .mp3 Input?

10,155

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.

Share:
10,155

Related videos on Youtube

Sarah Szabo
Author by

Sarah Szabo

Updated on September 18, 2022

Comments

  • Sarah Szabo
    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:0

    Edit 0:

    This also happens when I try to add -acodec libmp3lame although the error seems to indicate that I don't have the .mp3 codec

    sarah@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 - Слава Україні
    Scott - Слава Україні almost 5 years
    Thanks (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 your ffmpeg command quotes "$z" (and "$metadataTPE2", "$metadataComposer", "$metadataGenre" and "‌​$metadataYear") but not $z.mp3.  … (Cont’d)
  • Scott - Слава Україні
    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, but let and ++ are not.  (7) P.P.S. How can that script even work when it says things like counterTotalFiles = 0 (with spaces)?