Embed metadata into AVI header, using ffmpeg
Posted: Thu Jan 20, 2011 4:55 pm
Unfortunately, it's rarely used, but even the AVI container offers ways to embed metadata directly in the file.
I'm using the tool 'FFmpeg' to do this. According to the FFmpeg documentation, the syntax is quite straightforward:
You need to pass the full '-metadata' argument for each key/value pair.
Here's an example:
== You *must* copy the whole file:
Unfortunately, the current FFmpeg implementation cannot simply update the header data of an existing AVI file. It must read/write the whole file at least once, in order to embed the metadata.
== Available metadata fields?
According to FFmpeg's AVI-format source code, FFmpeg’s AVI muxer honors the following metadata keys and maps them to these FourCCs in the file header:(Note: The list in the FFmpeg Metadata article in the Multimedia Wiki is outdated and does not contain all tags)
The above list only contains the metadata fields mapped to a human readable alias. If I read FFmpeg's AVI-format source code correctly, it can handle more fields:
I couldn't find an official specification of those FourCC attribute names, but thanks to the sourcecode of a "RIFF" handling library, here's a list that looks meaningful:
Additional references:
I'm using the tool 'FFmpeg' to do this. According to the FFmpeg documentation, the syntax is quite straightforward:
Code: Select all
-metadata key=value
Here's an example:
Code: Select all
ffmpeg -i input.avi -vcodec copy -acodec copy -metadata title="The Title" -metadata=encoded_by="Hans Stahl" output.avi
Unfortunately, the current FFmpeg implementation cannot simply update the header data of an existing AVI file. It must read/write the whole file at least once, in order to embed the metadata.
== Available metadata fields?
According to FFmpeg's AVI-format source code, FFmpeg’s AVI muxer honors the following metadata keys and maps them to these FourCCs in the file header:
Code: Select all
const AVMetadataConv ff_avi_metadata_conv[] = {
{ "IART", "artist" },
{ "ICMT", "comment" },
{ "ICOP", "copyright" },
{ "ICRD", "date" },
{ "IGNR", "genre" },
{ "ILNG", "language" },
{ "INAM", "title" },
{ "IPRD", "album" },
{ "IPRT", "track" },
{ "ISFT", "encoder" },
{ "ITCH", "encoded_by"},
{ "strn", "title" },
{ 0 },
};
The above list only contains the metadata fields mapped to a human readable alias. If I read FFmpeg's AVI-format source code correctly, it can handle more fields:
Code: Select all
const char ff_avi_tags[][5] = {
"IARL", "IART", "ICMS", "ICMT", "ICOP", "ICRD", "ICRP", "IDIM", "IDPI",
"IENG", "IGNR", "IKEY", "ILGT", "ILNG", "IMED", "INAM", "IPLT", "IPRD",
"IPRT", "ISBJ", "ISFT", "ISHP", "ISRC", "ISRF", "ITCH",
{0}
};
Code: Select all
ATTRIBUTE_NAMES = {
'Archival Location' => 'IARL',
'Artist' => 'IART',
'Author' => 'IART',
'Comissioned' => 'ICSM',
'Comment' => 'ICMT',
'Description' => 'ICMT',
'Copyright' => 'ICOP',
'Date Created' => 'ICRD',
'Cropped' => 'ICRP',
'Dimensions' => 'IDIM',
'Dots Per Inch' => 'IDPI',
'Engineer' => 'IENG',
'Genre' => 'IGNR',
'Keywords' => 'IKEY',
'Lightness' => 'ILGT',
'Medium' => 'IMED',
'Title' => 'INAM',
'Name' => 'INAM',
'Number of Colors' => 'IPLT',
'Product' => 'IPRD',
'Subject' => 'ISBJ',
'Software' => 'ISFT',
'Encoding Application' => 'ISFT',
'Sharpness' => 'ISHP',
'Source' => 'ISRC',
'Source Form' => 'ISRF',
'Technician' => 'ITCH'
}
Additional references: