Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

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

2) 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.

share|improve this answer
add comment

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).

share|improve this answer
    
The environment is Debian GNU/Linux. –  Chris C. Oct 26 '11 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. Oct 26 '11 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 Oct 27 '11 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 Oct 27 '11 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. Oct 28 '11 at 22:33
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.