“Nothing is particularly hard if you divide it into small jobs.” –Henry Ford
Tips and Tricks: ID3 tags on Windows using ffmpeg
Looking for How To: Create/Write ID3 tags using ffmpeg? Click here.
The problem or issue with ID3 tags on Windows is; Windows only recognizes version 2.3 or earlier of the ID3 tag implementation and ffmpeg, by default, will write version 2.4. So how do you make ffmpeg write version 2.3 ID3 tags instead of version 2.4?
RTM (Read The Manual)
In a previous article, “How To: Setup and Use ffmpeg on Windows”, I suggest to create a text file of the help output. If you run ffmpeg with the command line of ffmpeg.exe -? this will display the help instructions. There is so much information it would be easier to send it to a text file so you can open it and read it whenever you need to reference a parameter or option. To create the text file follow these steps:
- Open a Command Prompt Window.
- Change the current directory to where you run ffmpeg from.
If you followed the instructions from the fore mentioned article, you should be able to run ffmpeg from any directory because we added the program directory to the system path and created a batch file to call.
- Type the command line, ffmpeg.exe -? > “Path and name of output file”
Replace the “Path and name of output file” with the actual Path and / or name of the text file you want. In the article we used “ffmpeg_help.txt”.
C:\>cd program files\ffmpeg\bin C:\Program Files\ffmpeg\bin>ffmpeg.exe -? > "C:\Program Files\ffmpeg\ffmpeg_help.txt" C:\Program Files\ffmpeg\bin>
Command Prompt Window Example
In the example above, I didn’t use the batch file from the previous article. Here is the example using the batch file:
C:\>cd program files\ffmpeg C:\Program Files\ffmpeg>ffmpeg32 -? > ffmpeg_help.txt C:\Program Files\ffmpeg>
Command Prompt Window Example – Using batch file
Notice we didn’t have to change directories to the “bin” directory where the ffmpeg executable file is located. Nor did we have to specify a directory for the output file because we want the file to be created in the current directory.
Okay. So what was the point of creating the text file? If we open the text file we just created in the steps above, we will find that ffmpeg has a parameter -id3v2_version on line 1,458 (Your version may be different.).
MP3 muxer AVOptions:
-id3v2_version <int> E.... Select ID3v2 version to write. Currently 3 and 4 are supported.
-write_id3v1 <int> E.... Enable ID3v1 writing. ID3v1 tags are written in UTF-8 which may not be supported by most software.
As we read the line, <int> indicates that this parameter requires a integer value. The E…. signifies that this parameter is only used when encoding a file. The rest of the line tells us that this parameter is used to ‘Select ID3v2 version to write.’ and that 3 and 4 are the only values currently supported. Which is exactly what we are looking for; a way to specify which version ffmpeg will use to write the ID3v2 tag.
How to use the parameter.
Let’s assume you have an AAC file with the extension .m4a. This file has the information we want already stored in metadata in the file. We want to convert the .m4a file to a .mp3 file with a sampling rate of 44100 Hz, a bit rate of 192k, and keep the same ID3 tag information but make them ID3v2.3 so they are compatible with Windows. Here is the command line: (Note: The command line below is using the batch file from the previous article.)
ffmpeg32 -i song.m4a -acodec libmp3lame -ar 44100 -b:a 192k -id3v2_version 3 -write_id3v1 1 song.mp3
Check out the related articles for more information.