Search code examples
python-3.xffmpegmetadatamp3

FFMPEG split mp3 and add metatag


I have a 2 hour mp3 that I automatically split with python3 and ffmpeg into many mp3 files. I would also like to add metadata to mp3 files, in order to have title, artist, year and album.

In a csv file I have the cutting times and the name of the mp3 file, but I can't add meta data. The function I use is this:

ffmpeg -loglevel panic -i 1.mp3 -ss 02:29:11 -to 02:34:43 -c copy -metadata 'title=My Title', 'artist=ME', 'date=2023' temp/myfile1.mp3

Not work, It only works if I set the title only. Can you help me, please? Thank you,


Solution

  • -metadata can only be used for setting 1 key=value pair at a time, you need to use this flag multiple times, once for each key=value pair, like this

    -metadata title="My Title" -metadata artist="ME" -metadata date="2023" -metadata album="My Album"