Revision a23c9c4a

View differences:

libavformat/movenc.c
474 474
    return 0;
475 475
}
476 476

  
477
static int mov_find_video_codec_tag(AVFormatContext *s, MOVTrack *track)
477
static const AVCodecTag codec_3gp_tags[] = {
478
    { CODEC_ID_H263,   MKTAG('s','2','6','3') },
479
    { CODEC_ID_H264,   MKTAG('a','v','c','1') },
480
    { CODEC_ID_MPEG4,  MKTAG('m','p','4','v') },
481
    { CODEC_ID_AAC,    MKTAG('m','p','4','a') },
482
    { CODEC_ID_AMR_NB, MKTAG('s','a','m','r') },
483
    { CODEC_ID_AMR_WB, MKTAG('s','a','w','b') },
484
};
485

  
486
static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
478 487
{
479 488
    int tag = track->enc->codec_tag;
480
    if (!tag) {
489
    if (track->mode == MODE_MP4 || track->mode == MODE_PSP) {
490
        if (!codec_get_tag(ff_mp4_obj_type, track->enc->codec_id))
491
            return 0;
492
        if (track->enc->codec_id == CODEC_ID_H264)           tag = MKTAG('a','v','c','1');
493
        else if (track->enc->codec_type == CODEC_TYPE_VIDEO) tag = MKTAG('m','p','4','v');
494
        else if (track->enc->codec_type == CODEC_TYPE_AUDIO) tag = MKTAG('m','p','4','a');
495
    } else if (track->mode == MODE_3GP || track->mode == MODE_3G2) {
496
        tag = codec_get_tag(codec_3gp_tags, track->enc->codec_id);
497
    } else if (!tag) { // do not override tag for mov
481 498
        if (track->enc->codec_id == CODEC_ID_DVVIDEO) {
482 499
            if (track->enc->height == 480) { /* NTSC */
483 500
                if (track->enc->pix_fmt == PIX_FMT_YUV422P)
......
492 509
                else
493 510
                    tag = MKTAG('d', 'v', 'p', 'p');
494 511
            }
495
        } else if (track->enc->codec_id == CODEC_ID_H263) {
496
            if (track->mode == MODE_MOV)
497
                tag = MKTAG('h', '2', '6', '3');
498
            else
499
                tag = MKTAG('s', '2', '6', '3');
500 512
        } else {
513
            if (track->enc->codec_type == CODEC_TYPE_VIDEO) {
501 514
            tag = codec_get_tag(codec_movvideo_tags, track->enc->codec_id);
502
        }
503
    }
504 515
    // if no mac fcc found, try with Microsoft tags
505 516
    if (!tag) {
506 517
        tag = codec_get_tag(codec_bmp_tags, track->enc->codec_id);
......
508 519
            av_log(s, AV_LOG_INFO, "Warning, using MS style video codec tag, the file may be unplayable!\n");
509 520
        }
510 521
    }
511
    assert(tag);
512
    return tag;
513
}
514

  
515
static int mov_find_audio_codec_tag(AVFormatContext *s, MOVTrack *track)
516
{
517
    int tag = track->enc->codec_tag;
518
    if (!tag) {
522
            } else if (track->enc->codec_type == CODEC_TYPE_AUDIO) {
519 523
        tag = codec_get_tag(codec_movaudio_tags, track->enc->codec_id);
520
    }
521 524
    // if no mac fcc found, try with Microsoft tags
522 525
    if (!tag) {
523 526
        int ms_tag = codec_get_tag(codec_wav_tags, track->enc->codec_id);
......
526 529
            av_log(s, AV_LOG_INFO, "Warning, using MS style audio codec tag, the file may be unplayable!\n");
527 530
        }
528 531
    }
529
    assert(tag);
532
            }
533
        }
534
    }
530 535
    return tag;
531 536
}
532 537

  
......
1458 1463
        track->enc = st->codec;
1459 1464
        track->language = ff_mov_iso639_to_lang(st->language, mov->mode != MODE_MOV);
1460 1465
        track->mode = mov->mode;
1466
        track->tag = mov_find_codec_tag(s, track);
1467
        if (!track->tag) {
1468
            av_log(s, AV_LOG_ERROR, "track %d: could not find tag for codec\n", i);
1469
            return -1;
1470
        }
1461 1471
        if(st->codec->codec_type == CODEC_TYPE_VIDEO){
1462
            track->tag = mov_find_video_codec_tag(s, track);
1463 1472
            track->timescale = st->codec->time_base.den;
1464 1473
            av_set_pts_info(st, 64, 1, st->codec->time_base.den);
1465 1474
            if (track->timescale > 100000)
......
1468 1477
                       "file may not be playable by quicktime. Specify a shorter timebase\n"
1469 1478
                       "or choose different container.\n");
1470 1479
        }else if(st->codec->codec_type == CODEC_TYPE_AUDIO){
1471
            track->tag = mov_find_audio_codec_tag(s, track);
1472 1480
            track->timescale = st->codec->sample_rate;
1473 1481
            av_set_pts_info(st, 64, 1, st->codec->sample_rate);
1474 1482
            if(!st->codec->frame_size){

Also available in: Unified diff