How to convert audio and keep track metadata with all formats
How to convert audio and keep track metadata with all formats
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?
1 Answer
1
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.
-vn
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy
Thanks, works :)
– Bleuzen
Sep 16 '18 at 13:57