'How to stop ffmpeg from manipulating mp3 metadata?
I'm using ffmpeg to change bitrate of my mp3 files. It works well, but one thing is very frustrating.
ffmpeg automatically changes some of metadata fields. Specifically it converts ID3v2.3 to ID3v2.4, and it does it incorrectly. For example, it writes TYER
field that actually does not exist in ID3v2.4. But the most frustrating thing is, it converts USLT
field to lyrics-LANGCODE
(like lyrics-eng
). Most of music players does not recognise this tag!
I don't want ffmpeg to mess up with metadata fields. I just want it to change bitrate. Is there anyway to tell ffmpeg that it should not touch any metadata fields?
I'm running ffmpeg 4.0.2 in windows 64bit. Options are:
ffmpeg -i input.mp3 -codec:a libmp3lame -b:a 128k output.mp3
And no, -id3v2_version 3
did not help. It corrected TYER
problem, but not lyrics problem.
Solution 1:[1]
I couldn't solve the lyrics problem with ffmpeg
but was able to copy lyrics from the LYRICS-ENG
metadata field to the USLT
field.
I used the Mp3tag tool for batch copying of the data.
It has the Actions feature for batch operations.
What I did:
- Actions -> Actions
- New -> New -> Format value
- "Field": UNSYNCEDLYRICS, "Format string": %LYRICS-ENG%
- Navigate to a folder with the files, select them and execute the created action
Solution 2:[2]
I used a mix between ffmpeg and the first answer to this question: I first convert a full folder of files thanks to the cmd loop below (in this case converting .flac files to .mp3). Right now I am changing the bitrate of my entire iTunes library so that it takes less place, and ffmpeg does indeed change the tag of the lyrics. But using mp3tag and creating this action allows me to switch them back to a tag that iTunes knows. This is a very quick way of doing it, and I was searching for it for a very long time !
FOR /F "tokens=*" %G IN ('dir /b *.flac') DO ffmpeg -i "%G" -ab 320k -acodec mp3 "3%~nG.mp3"
Solution 3:[3]
i have found several approaches that do something that may work but i do not think that it is currently possible to completely fix that issue.
[every time you see an "{lyrics}" in this answer you have to replace it with the actual lyrics, you can get those using external tools like ffprobe in combination with grep or, for example, the npm package music-metadata]
with the command
$ ffmpeg -i input.mp3 -metadata "lyrics-eng" -metadata "unsyncedlyrics=eng||{lyrics}"
you can clear the TXXX:lyrics-eng field and instead write them to TXXX:unsynchedlyrics. Mp3Tag recognizes the latter the same as normal USLT and if you save the file using Mp3Tag (without changing anything) it automatically reverts back to USLT
with the command
$ ffmpeg -i input.mp3 -metadata "lyrics-eng=" -metadata "lyrics=eng||{lyrics}"
ffmpeg adds your lyrics as "TXXX:USLT". Mp3Tag does not recognize those at all.
the hacky workaround that i ended up using (on windows), was to copy them using the first method, open them all in Mp3Tag using its command line interface ($ Mp3Tag.exe /fn:"<file name 1>" /fn:"<file name 2>" ... /fn:"<file name n>"
) and then just press ctrl+a
and then ctrl+s
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | mortalis |
Solution 2 | Alexandre Potton |
Solution 3 |