Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Command line tool to duplicate tags for mp4 (m4b, m4a)? (Read 1243 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Command line tool to duplicate tags for mp4 (m4b, m4a)?

I'm trying to copy all tags from a mp4 file to another, but haven't found a command line tool (Windows) to do it.

For mp3 and ogg there are options, like id3.exe --duplicate or tools that dump tags to stdout and read them from stdin to tag another file. I haven't found such a tool for mp4 yet, and am struggling to manually catch all possible tags with mediainfo or exiftool.

I know mp4box, or other tools like kid3-cli, tone, ... but didn't see how to do it in one batch, maybe some wizardry with json files or the like.

Re: Command line tool to duplicate tags for mp4 (m4b, m4a)?

Reply #1
ffmpeg can do it, I think you'll have to make a copy of your destination file rather than just update the existing file.

Assuming you have "source.mp4" with your tags, "untagged.mp4" is your audio without tags, and "destination.mp4" as the audio from untagged.mp4 + the tags from source.mp4:

Code: [Select]
ffmpeg -i source.mp4 -i untagged.mp4 -map_metadata 0 -map 1 -c:a copy -movflags faststart destination.mp4

Here's the breakdown of the command:

  • give ffmpeg two inputs (`-i source.mp4 -i untagged.mp4`)
  • specify you want the metadata from the first input (`-map_metadata 0`)
  • specify you want data streams from the second input (`-map 1`)
  • you want to copy the audio as-is (`-c:a copy`)
  • you want the "faststart" option for movflags (that places the moov atom at the beginning of the file)
  • finally the output filename

What it probably won't copy very well is embedded pictures, I always have a hard time getting that handled correctly.

It might not copy each and every tag but I think the only missing tags would be particularly esoteric ones. All your standard stuff like artist, title, album, albumartist, musicbrainz IDs, etc should copy fine.

Re: Command line tool to duplicate tags for mp4 (m4b, m4a)?

Reply #2
It looks like exiftool should be able to do this as well:

Code: [Select]
exiftool -TagsFromFile source.mp4 -overwrite_original -all:all untagged.mp4

This will copy the tags from source.mp4 and write them into untagged.mp4 - updating it in-place.

Re: Command line tool to duplicate tags for mp4 (m4b, m4a)?

Reply #3
Code: [Select]
ffmpeg -i source.mp4 -i untagged.mp4 -map_metadata 0 -map 1 -c:a copy -movflags faststart destination.mp4
What it probably won't copy very well is embedded pictures, I always have a hard time getting that handled correctly.
This may sound strange, but ffmpeg treats cover arts as video streams. So I think you can do it like this:
Code: [Select]
ffmpeg -i source.mp4 -i untagged.mp4 -map_metadata 0 -map 1 -c:a copy -map 0 -c:v copy -movflags faststart destination.mp4