[Ffmpeg-devel] [PATCH] Read AVI tags

David Conrad davedc_
Tue Aug 15 07:39:45 CEST 2006


Hi,
The following patch adds some read support for metadata tags in AVI  
files. One note: the artist tag is put in the author field since  
there is no AVI tag for author, but this seems to be the same  
behavior as the mp3 parser's id3 tag reader.

Index: libavformat/avidec.c
===================================================================
--- libavformat/avidec.c	(revision 5999)
+++ libavformat/avidec.c	(working copy)
@@ -180,6 +180,15 @@
      }
}
+static int avi_read_tag(ByteIOContext *pb, char *buf, int maxlen,  
unsigned int size)
+{
+    offset_t i = url_ftell(pb);
+    size += (size & 1);
+    get_strz(pb, buf, maxlen);
+    url_fseek(pb, i+size, SEEK_SET);
+    return 0;
+}
+
static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
      AVIContext *avi = s->priv_data;
@@ -438,6 +447,25 @@
              }
              url_fseek(pb, i+size, SEEK_SET);
              break;
+        case MKTAG('I', 'N', 'A', 'M'):
+            avi_read_tag(pb, s->title, sizeof(s->title), size);
+            av_log(NULL, AV_LOG_ERROR, "title: %s\n", s->title);
+            break;
+        case MKTAG('I', 'A', 'R', 'T'):
+            avi_read_tag(pb, s->author, sizeof(s->author), size);
+            av_log(NULL, AV_LOG_ERROR, "author: %s\n", s->author);
+            break;
+        case MKTAG('I', 'C', 'O', 'P'):
+            avi_read_tag(pb, s->copyright, sizeof(s->copyright), size);
+            av_log(NULL, AV_LOG_ERROR, "copyright: %s\n", s- 
 >copyright);
+            break;
+        case MKTAG('I', 'C', 'M', 'T'):
+            avi_read_tag(pb, s->comment, sizeof(s->comment), size);
+            av_log(NULL, AV_LOG_ERROR, "comment: %s\n", s->comment);
+            break;
+        case MKTAG('I', 'G', 'N', 'R'):
+            avi_read_tag(pb, s->genre, sizeof(s->genre), size);
+            break;
          default:
              /* skip tag */
              size += (size & 1);





More information about the ffmpeg-devel mailing list