Revision ca8064d2

View differences:

ffmpeg.c
3390 3390
    *has_subtitle_ptr = has_subtitle;
3391 3391
}
3392 3392

  
3393
static void new_video_stream(AVFormatContext *oc)
3393
static void new_video_stream(AVFormatContext *oc, int file_idx)
3394 3394
{
3395 3395
    AVStream *st;
3396 3396
    AVCodecContext *video_enc;
......
3417 3417
    }
3418 3418

  
3419 3419
    avcodec_get_context_defaults3(st->codec, codec);
3420
    bitstream_filters[nb_output_files] =
3421
        grow_array(bitstream_filters[nb_output_files],
3422
                   sizeof(*bitstream_filters[nb_output_files]),
3423
                   &nb_bitstream_filters[nb_output_files], oc->nb_streams);
3424
    bitstream_filters[nb_output_files][oc->nb_streams - 1]= video_bitstream_filters;
3420
    bitstream_filters[file_idx] =
3421
        grow_array(bitstream_filters[file_idx],
3422
                   sizeof(*bitstream_filters[file_idx]),
3423
                   &nb_bitstream_filters[file_idx], oc->nb_streams);
3424
    bitstream_filters[file_idx][oc->nb_streams - 1]= video_bitstream_filters;
3425 3425
    video_bitstream_filters= NULL;
3426 3426

  
3427 3427
    avcodec_thread_init(st->codec, thread_count);
......
3534 3534
    frame_pix_fmt = PIX_FMT_NONE;
3535 3535
}
3536 3536

  
3537
static void new_audio_stream(AVFormatContext *oc)
3537
static void new_audio_stream(AVFormatContext *oc, int file_idx)
3538 3538
{
3539 3539
    AVStream *st;
3540 3540
    AVCodec *codec= NULL;
......
3562 3562

  
3563 3563
    avcodec_get_context_defaults3(st->codec, codec);
3564 3564

  
3565
    bitstream_filters[nb_output_files] =
3566
        grow_array(bitstream_filters[nb_output_files],
3567
                   sizeof(*bitstream_filters[nb_output_files]),
3568
                   &nb_bitstream_filters[nb_output_files], oc->nb_streams);
3569
    bitstream_filters[nb_output_files][oc->nb_streams - 1]= audio_bitstream_filters;
3565
    bitstream_filters[file_idx] =
3566
        grow_array(bitstream_filters[file_idx],
3567
                   sizeof(*bitstream_filters[file_idx]),
3568
                   &nb_bitstream_filters[file_idx], oc->nb_streams);
3569
    bitstream_filters[file_idx][oc->nb_streams - 1]= audio_bitstream_filters;
3570 3570
    audio_bitstream_filters= NULL;
3571 3571

  
3572 3572
    avcodec_thread_init(st->codec, thread_count);
......
3614 3614
    audio_stream_copy = 0;
3615 3615
}
3616 3616

  
3617
static void new_subtitle_stream(AVFormatContext *oc)
3617
static void new_subtitle_stream(AVFormatContext *oc, int file_idx)
3618 3618
{
3619 3619
    AVStream *st;
3620 3620
    AVCodec *codec=NULL;
......
3634 3634
    }
3635 3635
    avcodec_get_context_defaults3(st->codec, codec);
3636 3636

  
3637
    bitstream_filters[nb_output_files] =
3638
        grow_array(bitstream_filters[nb_output_files],
3639
                   sizeof(*bitstream_filters[nb_output_files]),
3640
                   &nb_bitstream_filters[nb_output_files], oc->nb_streams);
3641
    bitstream_filters[nb_output_files][oc->nb_streams - 1]= subtitle_bitstream_filters;
3637
    bitstream_filters[file_idx] =
3638
        grow_array(bitstream_filters[file_idx],
3639
                   sizeof(*bitstream_filters[file_idx]),
3640
                   &nb_bitstream_filters[file_idx], oc->nb_streams);
3641
    bitstream_filters[file_idx][oc->nb_streams - 1]= subtitle_bitstream_filters;
3642 3642
    subtitle_bitstream_filters= NULL;
3643 3643

  
3644 3644
    subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
......
3665 3665
static int opt_new_stream(const char *opt, const char *arg)
3666 3666
{
3667 3667
    AVFormatContext *oc;
3668
    int file_idx = nb_output_files - 1;
3668 3669
    if (nb_output_files <= 0) {
3669 3670
        fprintf(stderr, "At least one output file must be specified\n");
3670 3671
        ffmpeg_exit(1);
3671 3672
    }
3672
    oc = output_files[nb_output_files - 1];
3673
    oc = output_files[file_idx];
3673 3674

  
3674
    if      (!strcmp(opt, "newvideo"   )) new_video_stream   (oc);
3675
    else if (!strcmp(opt, "newaudio"   )) new_audio_stream   (oc);
3676
    else if (!strcmp(opt, "newsubtitle")) new_subtitle_stream(oc);
3675
    if      (!strcmp(opt, "newvideo"   )) new_video_stream   (oc, file_idx);
3676
    else if (!strcmp(opt, "newaudio"   )) new_audio_stream   (oc, file_idx);
3677
    else if (!strcmp(opt, "newsubtitle")) new_subtitle_stream(oc, file_idx);
3677 3678
    else av_assert0(0);
3678 3679
    return 0;
3679 3680
}
......
3776 3777
        }
3777 3778

  
3778 3779
        if (use_video) {
3779
            new_video_stream(oc);
3780
            new_video_stream(oc, nb_output_files);
3780 3781
        }
3781 3782

  
3782 3783
        if (use_audio) {
3783
            new_audio_stream(oc);
3784
            new_audio_stream(oc, nb_output_files);
3784 3785
        }
3785 3786

  
3786 3787
        if (use_subtitle) {
3787
            new_subtitle_stream(oc);
3788
            new_subtitle_stream(oc, nb_output_files);
3788 3789
        }
3789 3790

  
3790 3791
        oc->timestamp = recording_timestamp;

Also available in: Unified diff