my inputs are multiple FLAC and OGG files. I want to convert them all to mp3. (a script does batch converting, ffmpeg command only has to handle one input file).
I also want to keep the tags (song artist, track name, album name, ...). My current command to do this is:
ffmpeg -vn -n -i $INFILE -c:a libmp3lame -q:a 1 -ar 44100 -map_metadata 0:s:0 -id3v2_version 3 $OUTFILE.mp3
Now the problem is: it works when the input file is an OGG file. But it doesn't work if input is a FLAC file.
I also found a command for FLAC input files:
ffmpeg -vn -n -i $INFILE -c:a libmp3lame -q:a 1 -ar 44100 $OUTFILE.mp3
(which is the same but without the map_metadata option. So FLAC tags are copied without that options. But without them it doesn't work for OGG input files. And with the options it doesn't work for FLAC input files.
How can I handle both input formats and keep tags of both without needing a different command?
Use
ffmpeg -n -i $INFILE -c:a libmp3lame -q:a 1 -ar 44100 -map_metadata 0 -map_metadata 0:s:0 -id3v2_version 3 -vn $OUTFILE.mp3
This maps both the global as well as stream metadata.
-vn belongs to the output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With