Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert audio and keep track metadata with all formats

Tags:

ffmpeg

audio

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?

like image 644
Bleuzen Avatar asked Oct 23 '25 16:10

Bleuzen


1 Answers

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.

like image 155
Gyan Avatar answered Oct 26 '25 07:10

Gyan