Revision 4b358c3e libavformat/mpegtsenc.c

View differences:

libavformat/mpegtsenc.c
216 216
    for(i = 0; i < s->nb_streams; i++) {
217 217
        AVStream *st = s->streams[i];
218 218
        MpegTSWriteStream *ts_st = st->priv_data;
219
        AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL,0);
219 220
        switch(st->codec->codec_id) {
220 221
        case CODEC_ID_MPEG1VIDEO:
221 222
        case CODEC_ID_MPEG2VIDEO:
......
252 253
        /* write optional descriptors here */
253 254
        switch(st->codec->codec_type) {
254 255
        case CODEC_TYPE_AUDIO:
255
            if (strlen(st->language) == 3) {
256
            if (lang && strlen(lang->value) == 3) {
256 257
                *q++ = 0x0a; /* ISO 639 language descriptor */
257 258
                *q++ = 4;
258
                *q++ = st->language[0];
259
                *q++ = st->language[1];
260
                *q++ = st->language[2];
259
                *q++ = lang->value[0];
260
                *q++ = lang->value[1];
261
                *q++ = lang->value[2];
261 262
                *q++ = 0; /* undefined type */
262 263
            }
263 264
            break;
264 265
        case CODEC_TYPE_SUBTITLE:
265 266
            {
266 267
                const char *language;
267
                language = st->language;
268
                if (strlen(language) != 3)
269
                    language = "eng";
268
                language = lang && strlen(lang->value)==3 ? lang->value : "eng";
270 269
                *q++ = 0x59;
271 270
                *q++ = 8;
272 271
                *q++ = language[0];
......
383 382
    MpegTSWriteStream *ts_st;
384 383
    MpegTSService *service;
385 384
    AVStream *st;
385
    AVMetadataTag *title;
386 386
    int i, total_bit_rate;
387 387
    const char *service_name;
388 388
    uint64_t sdt_size, pat_pmt_size, pos;
......
390 390
    ts->tsid = DEFAULT_TSID;
391 391
    ts->onid = DEFAULT_ONID;
392 392
    /* allocate a single DVB service */
393
    service_name = s->title;
394
    if (service_name[0] == '\0')
395
        service_name = DEFAULT_SERVICE_NAME;
393
    title = av_metadata_get(s->metadata, "title", NULL, 0);
394
    service_name = title ? title->value : DEFAULT_SERVICE_NAME;
396 395
    service = mpegts_add_service(ts, DEFAULT_SID,
397 396
                                 DEFAULT_PROVIDER_NAME, service_name);
398 397
    service->pmt.write_packet = section_write_packet;

Also available in: Unified diff