23

I'm using ffmpeg to extract just the audio stream from a video file:

ffmpeg -i video.mp4 -vn -acodec copy audio.aac

This produces a clean audio file but without any metadata.

To add metadata, ffmpeg has a command line option:

ffmpeg -i video.mp4 -vn -acodec copy -metadata title="My Title" audio.aac

This runs without error, but when the output file is checked with ffprobe, it has no metadata tags at all.

If the output container is changed to mp4, the metadata can be set and appears in the output file:

ffmpeg -i video.mp4 -vn -acodec copy -metadata title="My Title" audio.mp4

Here's the interesting bit; if I use Banshee to edit the metadata of an existing .aac file, then use ffmpeg to process the file the same way, the original metadata is copied successfully to the new .aac file.

ffmpeg -i metadata.aac -vn -acodec copy audio.aac

but, attempts to change the metadata have no effect:

ffmpeg -i metadata.aac -vn -acodec copy -metadata title="My Title" audio.aac

So it seems the .aac container can hold metadata and ffmpeg can copy it from input to output, but can't alter it when the copy codec is used.

Does anyone know of a way to get ffmpeg to alter the metadata in an aac container without reencoding?

Alternately, is there another generic tool I could be using to set the metadata after the file has been processed?

Much thanks. Chris.

4 Answers 4

20

The goal was to produce an audio-only file from a video file without re-encoding and to introduce metadata recognizable by media players. The environment is Debian GNU/Linux.

I'd like to thank @bootload for putting me on the right track to finding an answer.

ffmpeg does not appear to support adding metadata tags to .AAC output files, however, here are two possible workarounds.

  1. The command line utilities id3 and id3v2 (available from the standard repositories) can apply id3 tags to a .aac audio file. Nautilus recognized both v1 and v2 tag styles so either should work. The same tags were recognized by the Banshee media player.
id3v2 -t "My Title" audio.aac
  1. ffmpeg can add metadata to an MP4 container, but an .mp4 extension in Nautilus will appear as a video file. Apple Inc. uses non-standard extensions to the MP4 container to distinguish video files (.m4v) from audio files (.m4a). These extensions are recognized under Debian by Nautilus and by ffmpeg. So,
ffmpeg -i video.mp4 -vn -acodec copy -metadata title="My Title" audio.m4a

will produce an audio-only file recognized by Nautilus, and ffmpeg can safely add metadata to the container.

3

What is the intended hardware? Is it for an Apple iP* device? If so try http://atomicparsley.sourceforge.net/ Otherwise try http://ffmpeg.org/ffmpeg.html#Examples using the "UTF-8-encoded INI" mex/demux method. (Extract the metadata as utf8 file & modify & re-insert).

5
  • The environment is Debian GNU/Linux.
    – Chris C.
    Commented Oct 26, 2011 at 12:58
  • The ffmpeg documentation is not clear on how to use the metadata muxer/demuxer, though the document link shows the resulting file format. Can you provide a command line example of how this would be done? Thanks.
    – Chris C.
    Commented Oct 26, 2011 at 13:00
  • @ChrisC doesn't look good. Without wading through the aac & ffmpeg specs to verify this it looks like the metadata honoured by ffmpeg is listed here ~ wiki.multimedia.cx/index.php?title=FFmpeg_Metadata#Basic_Usage and acc isn't supported. Using the cli for other formats you follow the pattern 'ffmpeg -i track05.wav -metadata title="Track #5" -metadata author="Unknown Artist" -acodec alac -y track05.m4a for example. The generalised pattern is ffmpeg -i <SOURCE> -metadata key="value" <SOURCE>. This is exactly the process you followed :(
    – bootload
    Commented Oct 27, 2011 at 1:07
  • Lets get very specific. What is the format of the metadata you want to encode to? Are we talking ID3? What format are you going to finally work with?
    – bootload
    Commented Oct 27, 2011 at 2:49
  • I took a look around to see what AAC supports. There may not be an official format, but within Debian ID3V1 and ID3V2 both seem to work. Banshee appears to be putting ID3V2 tags on when using its editor.
    – Chris C.
    Commented Oct 28, 2011 at 22:33
1

MP4Box (part of the "gpac" package) envelopes AAC files with MP4 containers without altering the original data. Metadata can then be added using just about any piece of tagging software:

MP4Box -add old.aac new.mp4
1

This has been fixed many years ago according to this ticket.

use the option -write_apetag ex:

ffmpeg -i video.mp4 -vn -acodec copy -write_apetag 1 -metadata title="My Title" audio.aac
2
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Mar 12, 2023 at 16:08
  • Also, I'm a bit confused about your answer. The OP, who also included his own answer, was clearly thinking about ID3(v2) tags. You're using the ability that ffmpeg now has of writing APE tags. APE tags are not the same as ID3 tags (or the same as Vorbis comments... or... who knows what else is out there). So... this time, the Community Bot is right, you need to explain your assumptions better :) Commented Jul 10, 2023 at 15:37

You must log in to answer this question.

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