Revision 04d2540c libavformat/avienc.c

View differences:

libavformat/avienc.c
21 21
#include "avformat.h"
22 22
#include "avi.h"
23 23
#include "riff.h"
24
#include "libavutil/intreadwrite.h"
24 25

  
25 26
/*
26 27
 * TODO:
......
114 115
    }
115 116
}
116 117

  
117
static void avi_write_info_tag2(AVFormatContext *s, AVStream *st, const char *fourcc, const char *key1, const char *key2)
118
{
119
    AVMetadataTag *tag;
120
    if(st){
121
        tag= av_metadata_get(st->metadata, key1, NULL, 0);
122
        if(!tag && key2)
123
            tag= av_metadata_get(st->metadata, key2, NULL, 0);
124
    }else{
125
        tag= av_metadata_get(s->metadata, key1, NULL, 0);
126
    if(!tag && key2)
127
        tag= av_metadata_get(s->metadata, key2, NULL, 0);
128
    }
129
    if(tag)
130
        avi_write_info_tag(s->pb, fourcc, tag->value);
131
}
132

  
133 118
static int avi_write_counters(AVFormatContext* s, int riff_id)
134 119
{
135 120
    ByteIOContext *pb = s->pb;
......
171 156
    int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale;
172 157
    AVCodecContext *stream, *video_enc;
173 158
    int64_t list1, list2, strh, strf;
159
    AVMetadataTag *t = NULL;
174 160

  
175 161
    for(n=0;n<s->nb_streams;n++) {
176 162
        s->streams[n]->priv_data= av_mallocz(sizeof(AVIStream));
......
301 287
            return -1;
302 288
        }
303 289
        ff_end_tag(pb, strf);
304
        avi_write_info_tag2(s, s->streams[i], "strn", "Title", "Description");
290
        if ((t = av_metadata_get(s->streams[i]->metadata, "strn", NULL, 0))) {
291
            avi_write_info_tag(s->pb, t->key, t->value);
292
            t = NULL;
293
        }
294
        //FIXME a limitation of metadata conversion system
295
        else if ((t = av_metadata_get(s->streams[i]->metadata, "INAM", NULL, 0))) {
296
            avi_write_info_tag(s->pb, "strn", t->value);
297
            t = NULL;
298
        }
305 299
      }
306 300

  
307 301
        if (!url_is_streamed(pb)) {
......
378 372

  
379 373
    list2 = ff_start_tag(pb, "LIST");
380 374
    put_tag(pb, "INFO");
381
    avi_write_info_tag2(s, NULL, "INAM", "Title", NULL);
382
    avi_write_info_tag2(s, NULL, "IART", "Artist", "Author");
383
    avi_write_info_tag2(s, NULL, "ICOP", "Copyright", NULL);
384
    avi_write_info_tag2(s, NULL, "ICMT", "Comment", NULL);
385
    avi_write_info_tag2(s, NULL, "IPRD", "Album", NULL);
386
    avi_write_info_tag2(s, NULL, "IGNR", "Genre", NULL);
387
    avi_write_info_tag2(s, NULL, "IPRT", "Track", NULL);
375
    for (i = 0; *ff_avi_tags[i]; i++) {
376
        if ((t = av_metadata_get(s->metadata, ff_avi_tags[i], NULL, AV_METADATA_MATCH_CASE)))
377
            avi_write_info_tag(s->pb, t->key, t->value);
378
    }
388 379
    if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
389 380
        avi_write_info_tag(pb, "ISFT", LIBAVFORMAT_IDENT);
390 381
    ff_end_tag(pb, list2);
......
655 646
    avi_write_trailer,
656 647
    .codec_tag= (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0},
657 648
    .flags= AVFMT_VARIABLE_FPS,
649
    .metadata_conv = ff_avi_metadata_conv,
658 650
};

Also available in: Unified diff