1 http://cakebox.homeunix.net/doc/ffmpeg/APIchanges
3 2009-03-01 - r17682 - lavf 52.31.0 - Generic metadata API
4 Introduce a new metadata API (see av_metadata_get() and friends).
5 The old API is now deprecated and should not be used anymore. This especially
6 includes the following structure fields:
7 - AVFormatContext.title
8 - AVFormatContext.author
9 - AVFormatContext.copyright
10 - AVFormatContext.comment
11 - AVFormatContext.album
12 - AVFormatContext.year
13 - AVFormatContext.track
14 - AVFormatContext.genre
17 - AVProgram.provider_name
21 /usr/include/libavformat/avformat.h :
22 #if LIBAVFORMAT_VERSION_INT < (53<<16)
28 int year; /**< ID3 year, 0 if none */
29 int track; /**< track number, 0 if none */
30 char genre[32]; /**< ID3 genre */
34 AVMetadataTag *tag = NULL;
35 while((tag=av_metadata_get(m, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
36 printf(" %-16s: %s\n", tag->key, tag->value);
39 --- ffmpeg-php-0.6.0//ffmpeg_movie.c 2011-01-05 21:48:29.247659645 +0200
40 +++ ffmpeg-php-metadata_api/ffmpeg_movie.c 2011-01-05 21:47:10.709759988 +0200
44 AVFormatContext *fmt_ctx;
45 + AVMetadata *metadata;
46 AVCodecContext *codec_ctx[MAX_STREAMS];
50 ffmovie_ctx = persistent ? malloc(sizeof(ff_movie_context)) :
51 emalloc(sizeof(ff_movie_context));
52 ffmovie_ctx->fmt_ctx = NULL;
53 + ffmovie_ctx->metadata = NULL;
54 ffmovie_ctx->frame_number = 0;
56 for (i = 0; i < MAX_STREAMS; i++) {
61 +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 31, 0)
62 +/* {{{ _php_get_metadata()
64 +static char* _php_get_metadata_tag(ff_movie_context *ffmovie_ctx, const char *key)
66 + // on first access do av_metadata_conv
67 + if (ffmovie_ctx->metadata == NULL) {
68 + av_metadata_conv(ffmovie_ctx->fmt_ctx, NULL, ffmovie_ctx->fmt_ctx->iformat->metadata_conv);
69 + ffmovie_ctx->metadata = ffmovie_ctx->fmt_ctx->metadata;
72 + // can metadata be missing?
73 + if (!ffmovie_ctx->metadata) {
77 + // get from metadata
78 + AVMetadataTag *tag = av_metadata_get(ffmovie_ctx->metadata, key, NULL, 0);
79 + return tag ? tag->value : NULL;
85 /* {{{ proto object ffmpeg_movie(string filename)
86 Constructor for ffmpeg_movie objects
88 ff_movie_context *ffmovie_ctx;
90 GET_MOVIE_RESOURCE(ffmovie_ctx);
93 +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 31, 0)
94 + char *tag = _php_get_metadata_tag(ffmovie_ctx, "comment");
96 + RETURN_STRINGL(tag, strlen(tag), 1);
99 RETURN_STRINGL(ffmovie_ctx->fmt_ctx->comment,
100 strlen(ffmovie_ctx->fmt_ctx->comment), 1);
107 GET_MOVIE_RESOURCE(ffmovie_ctx);
109 +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 31, 0)
110 + char *tag = _php_get_metadata_tag(ffmovie_ctx, "title");
112 + RETURN_STRINGL(tag, strlen(tag), 1);
115 RETURN_STRINGL(ffmovie_ctx->fmt_ctx->title,
116 strlen(ffmovie_ctx->fmt_ctx->title), 1);
123 GET_MOVIE_RESOURCE(ffmovie_ctx);
125 +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 31, 0)
126 + char *tag = _php_get_metadata_tag(ffmovie_ctx, "artist");
128 + RETURN_STRINGL(tag, strlen(tag), 1);
131 RETURN_STRINGL(ffmovie_ctx->fmt_ctx->author,
132 strlen(ffmovie_ctx->fmt_ctx->author), 1);
139 GET_MOVIE_RESOURCE(ffmovie_ctx);
141 +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 31, 0)
142 + char *tag = _php_get_metadata_tag(ffmovie_ctx, "copyright");
144 + RETURN_STRINGL(tag, strlen(tag), 1);
147 RETURN_STRINGL(ffmovie_ctx->fmt_ctx->copyright,
148 strlen(ffmovie_ctx->fmt_ctx->copyright), 1);
155 GET_MOVIE_RESOURCE(ffmovie_ctx);
157 +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 31, 0)
158 + char *tag = _php_get_metadata_tag(ffmovie_ctx, "album");
160 + RETURN_STRINGL(tag, strlen(tag), 1);
163 RETURN_STRINGL(ffmovie_ctx->fmt_ctx->album,
164 strlen(ffmovie_ctx->fmt_ctx->album), 1);
171 GET_MOVIE_RESOURCE(ffmovie_ctx);
173 +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 31, 0)
174 + char *tag = _php_get_metadata_tag(ffmovie_ctx, "genre");
176 + RETURN_STRINGL(tag, strlen(tag), 1);
179 RETURN_STRINGL(ffmovie_ctx->fmt_ctx->genre,
180 strlen(ffmovie_ctx->fmt_ctx->genre), 1);
187 GET_MOVIE_RESOURCE(ffmovie_ctx);
189 +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 31, 0)
190 + char *tag = _php_get_metadata_tag(ffmovie_ctx, "track");
192 + RETURN_STRINGL(tag, strlen(tag), 1);
195 RETURN_LONG(ffmovie_ctx->fmt_ctx->track);
202 GET_MOVIE_RESOURCE(ffmovie_ctx);
204 +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 31, 0)
205 + // "id3v2 tag TYER is not considered in generic format
206 + // ideally "date" should be used here and extract year from it for full compatability
207 + char *tag = _php_get_metadata_tag(ffmovie_ctx, "TYER");
209 + RETURN_STRINGL(tag, strlen(tag), 1);
212 RETURN_LONG(ffmovie_ctx->fmt_ctx->year);