Revision 0a6d97b3

View differences:

ffmpeg.c
114 114
static int nb_input_files_ts_scale[MAX_FILES] = {0};
115 115

  
116 116
static AVFormatContext *output_files[MAX_FILES];
117
static AVCodec *output_codecs[MAX_FILES*MAX_STREAMS];
117
static AVCodec **output_codecs = NULL;
118 118
static int nb_output_files = 0;
119
static int nb_ocodecs;
119
static int nb_output_codecs = 0;
120 120

  
121 121
static AVStreamMap stream_maps[MAX_FILES*MAX_STREAMS];
122 122
static int nb_stream_maps;
......
622 622
    av_free(opt_names);
623 623
    av_free(streamid_map);
624 624
    av_free(input_codecs);
625
    av_free(output_codecs);
625 626

  
626 627
    av_free(video_codec_name);
627 628
    av_free(audio_codec_name);
......
2357 2358
    for(i=0;i<nb_ostreams;i++) {
2358 2359
        ost = ost_table[i];
2359 2360
        if (ost->encoding_needed) {
2360
            AVCodec *codec = output_codecs[i];
2361
            AVCodec *codec = i < nb_output_codecs ? output_codecs[i] : NULL;
2361 2362
            if (!codec)
2362 2363
                codec = avcodec_find_encoder(ost->st->codec->codec_id);
2363 2364
            if (!codec) {
......
3396 3397
        ffmpeg_exit(1);
3397 3398
    }
3398 3399

  
3400
    output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1);
3399 3401
    if(!video_stream_copy){
3400 3402
        if (video_codec_name) {
3401 3403
            codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1,
3402 3404
                                         avcodec_opts[AVMEDIA_TYPE_VIDEO]->strict_std_compliance);
3403 3405
            codec = avcodec_find_encoder_by_name(video_codec_name);
3404
            output_codecs[nb_ocodecs] = codec;
3406
            output_codecs[nb_output_codecs-1] = codec;
3405 3407
        } else {
3406 3408
            codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO);
3407 3409
            codec = avcodec_find_encoder(codec_id);
......
3510 3512
            }
3511 3513
        }
3512 3514
    }
3513
    nb_ocodecs++;
3514 3515
    if (video_language) {
3515 3516
        av_metadata_set2(&st->metadata, "language", video_language, 0);
3516 3517
        av_freep(&video_language);
......
3536 3537
        ffmpeg_exit(1);
3537 3538
    }
3538 3539

  
3540
    output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1);
3539 3541
    if(!audio_stream_copy){
3540 3542
        if (audio_codec_name) {
3541 3543
            codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1,
3542 3544
                                         avcodec_opts[AVMEDIA_TYPE_AUDIO]->strict_std_compliance);
3543 3545
            codec = avcodec_find_encoder_by_name(audio_codec_name);
3544
            output_codecs[nb_ocodecs] = codec;
3546
            output_codecs[nb_output_codecs-1] = codec;
3545 3547
        } else {
3546 3548
            codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO);
3547 3549
            codec = avcodec_find_encoder(codec_id);
......
3586 3588
        choose_sample_fmt(st, codec);
3587 3589
        choose_sample_rate(st, codec);
3588 3590
    }
3589
    nb_ocodecs++;
3590 3591
    audio_enc->time_base= (AVRational){1, audio_sample_rate};
3591 3592
    if (audio_language) {
3592 3593
        av_metadata_set2(&st->metadata, "language", audio_language, 0);
......
3611 3612
        ffmpeg_exit(1);
3612 3613
    }
3613 3614
    subtitle_enc = st->codec;
3615
    output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1);
3614 3616
    if(!subtitle_stream_copy){
3615 3617
        subtitle_enc->codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1,
3616 3618
                                                   avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance);
3617
        codec= output_codecs[nb_ocodecs] = avcodec_find_encoder_by_name(subtitle_codec_name);
3619
        codec= output_codecs[nb_output_codecs-1] = avcodec_find_encoder_by_name(subtitle_codec_name);
3618 3620
    }
3619 3621
    avcodec_get_context_defaults3(st->codec, codec);
3620 3622

  
......
3631 3633
    } else {
3632 3634
        set_context_opts(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], subtitle_enc, AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);
3633 3635
    }
3634
    nb_ocodecs++;
3635 3636

  
3636 3637
    if (subtitle_language) {
3637 3638
        av_metadata_set2(&st->metadata, "language", subtitle_language, 0);

Also available in: Unified diff