Is there a way to copy all tags from one FLAC file to another seamlessly using a command-line tool?

  • 1
    Why is it that so much official documentation misses out on so friggin' many things that users are so very likely to need? Good question.
    – killermist
    Jun 21, 2012 at 23:04

3 Answers 3

metaflac --export-tags-to=- input.flac | \
metaflac --remove-all-tags --import-tags-from=- output.flac

Possibly needs the --no-utf8-convert option, too.

  • 1
    Too bad it doesn't copy pictures too… You'll have to do the same trick with --export-picture-to and --import-picture-from Jun 2, 2013 at 13:35
  • importing pictures from stdin doesn't seem to work well, it seems you really want to export the picture(s) to a file and then import them back from the files. When trying to import from stdin, it is often ending up with a picture block in the target file, but with zero bytes (no picture data)
    – Cheetah
    Jan 8, 2018 at 16:50

If you only want the text part of metadata, you should use metaflac with the --no-utf8-convert option on export and on import, otherwise characters that are not in your shell's characters set get mangled (e.g. for me Japanese metadata did get mangled without it):

metaflac --no-utf8-convert --export-tags-to=- src.flac | metaflac --remove-all-tags --import-tags-from=- dest.flac

no idea why utf8 is not the default.

This is not complete. If you want to move images as well, a small python script leveraging mutagen is the best way to copy all metadata.

  • This works but one crucial thing I think you overlooked is that the --remove-all-tags should come BEFORE the --import-tags-from=-. I had to switch them, or it imported the tags, then removed them, and I was left with a tagless FLAC every time. Feb 5, 2022 at 1:32

I'm slightly puzzled by the responses, since tags and images transfer natively by default with ffmpeg.

I think the issue was getting caught up in the OP terms, but if the actual goal is to create a flac from a flac that retains all the comment headers/metadata, ffmpeg does this automatically:

ffmpeg -i input.flac output.flac

If you want to change the compression level in output.flac, use the '-compression_level [1-8]' option. -y will overwrite the output.flac if it already exists.

I just tested this, and it all 'just works'. All tags transfer, embedded images transfer.

Exporting tags can have utility for other purposes, but in this case, it's somewhat unnecessary steps to do something that is quite easy.

This is assuming that the output.flac is not tagged already. Otherwise the metaflac based solutions will be useful to remove the tags first. Note that image embedding is more complicated, and requires more steps if the output.flac already has an embedded image, but that's outside of the scope of this specific question.

  • 1
    "tags and images transfer natively"... except when they don't. You also need -map 0 to transfer all images, and not all tags get copied. (I'd really like to know how to do this with ffmpeg, as I'm using it to filter audio files and would really like to copy everything without a second step.)
    – Matthew
    Oct 29, 2023 at 22:20
  • It would be more useful to note which tags don't get copied. I did a lot of testing with images, and I found that the only images that have consistent support are the main cover images, everything else has such inconsistent cross player support it wasn't worth spending time on it. But for this stuff, note which don't rather than some don't, since that does not narrow it down very much. I'll poke around with - map 0 but would be useful to know the type of image that did not transfer. Even better provide a flac sample.
    – Lizardx
    Nov 2, 2023 at 3:40
  • Given that there exist tags that don't get copied, I'd be very surprised if the list of tags that aren't copied isn't infinitely long, i.e. only specific, "known" tags get copied. In my case, it's the chapter tags that are being dropped, but really, I see no reason ffmpeg shouldn't (at least optionally) copy everything, known or not, between Xiph-family formats.
    – Matthew
    Nov 2, 2023 at 17:12
  • As for images... images aren't part of the VORBIS_COMMENT block, which is where the unneeded reparsing is happening. I suspect ffmpeg just treats those as multiple video streams and copies them just fine, except by default (i.e. without -map 0), only copies the first "stream". Note that the "type" is a numeric value buried in the block data. If you want to experiment, just use EasyTag to slap some images into a flac. (You can probably use metaflac also, but EasyTag has a friendlier interface.)
    – Matthew
    Nov 2, 2023 at 17:21
  • This takes a lot of research in my experience, testing, etc, very time consuming. I found EasyTag to be toxic for tags, and avoid even opening a tagged file in it, outputting the full comments using metaflac or whatever much safer, and also more predictable. I did a lot of viewing of that raw data when doing the initial testing, but sadly with digital media, there's always more you don't know, particularly related to tags and image embeds. Very poorly designed, bad specs, bad implementations, and horrible player support which nullifies most of what you learn since not supported usually.
    – Lizardx
    Nov 5, 2023 at 22:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .