static int check_init_output_file(OutputFile *of, int file_index)

{

    int ret, i;



    for (i = 0; i < of->ctx->nb_streams; i++) {

        OutputStream *ost = output_streams[of->ost_index + i];

        if (!ost->initialized)

            return 0;

    }



    of->ctx->interrupt_callback = int_cb;



    ret = avformat_write_header(of->ctx, &of->opts);

    if (ret < 0) {

        av_log(NULL, AV_LOG_ERROR,

               "Could not write header for output file #%d "

               "(incorrect codec parameters ?): %s\n",

               file_index, av_err2str(ret));

        return ret;

    }

    //assert_avoptions(of->opts);

    of->header_written = 1;



    av_dump_format(of->ctx, file_index, of->ctx->filename, 1);



    if (sdp_filename || want_sdp)

        print_sdp();



    /* flush the muxing queues */

    for (i = 0; i < of->ctx->nb_streams; i++) {

        OutputStream *ost = output_streams[of->ost_index + i];



        /* try to improve muxing time_base (only possible if nothing has been written yet) */

        if (!av_fifo_size(ost->muxing_queue))

            ost->mux_timebase = ost->st->time_base;



        while (av_fifo_size(ost->muxing_queue)) {

            AVPacket pkt;

            av_fifo_generic_read(ost->muxing_queue, &pkt, sizeof(pkt), NULL);

            write_packet(of, &pkt, ost);

        }

    }



    return 0;

}

static int check_init_output_file(OutputFile *of, int file_index)

{

    int ret, i;



    for (i = 0; i < of->ctx->nb_streams; i++) {

        OutputStream *ost = output_streams[of->ost_index + i];

        if (!ost->initialized)

            return 0;

    }



    of->ctx->interrupt_callback = int_cb;



    ret = avformat_write_header(of->ctx, &of->opts);

    if (ret < 0) {

        av_log(NULL, AV_LOG_ERROR,

               "Could not write header for output file #%d "

               "(incorrect codec parameters ?): %s\n",

               file_index, av_err2str(ret));

        return ret;

    }

    

    of->header_written = 1;



    av_dump_format(of->ctx, file_index, of->ctx->filename, 1);



    if (sdp_filename || want_sdp)

        print_sdp();



    

    for (i = 0; i < of->ctx->nb_streams; i++) {

        OutputStream *ost = output_streams[of->ost_index + i];



        

        if (!av_fifo_size(ost->muxing_queue))

            ost->mux_timebase = ost->st->time_base;



        while (av_fifo_size(ost->muxing_queue)) {

            AVPacket pkt;

            av_fifo_generic_read(ost->muxing_queue, &pkt, sizeof(pkt), NULL);

            write_packet(of, &pkt, ost);

        }

    }



    return 0;

}

static int FUNC_0(OutputFile *VAR_0, int VAR_1)

{

    int VAR_2, VAR_3;



    for (VAR_3 = 0; VAR_3 < VAR_0->ctx->nb_streams; VAR_3++) {

        OutputStream *ost = output_streams[VAR_0->ost_index + VAR_3];

        if (!ost->initialized)

            return 0;

    }



    VAR_0->ctx->interrupt_callback = int_cb;



    VAR_2 = avformat_write_header(VAR_0->ctx, &VAR_0->opts);

    if (VAR_2 < 0) {

        av_log(NULL, AV_LOG_ERROR,

               "Could not write header for output file #%d "

               "(incorrect codec parameters ?): %s\n",

               VAR_1, av_err2str(VAR_2));

        return VAR_2;

    }

    

    VAR_0->header_written = 1;



    av_dump_format(VAR_0->ctx, VAR_1, VAR_0->ctx->filename, 1);



    if (sdp_filename || want_sdp)

        print_sdp();



    

    for (VAR_3 = 0; VAR_3 < VAR_0->ctx->nb_streams; VAR_3++) {

        OutputStream *ost = output_streams[VAR_0->ost_index + VAR_3];



        

        if (!av_fifo_size(ost->muxing_queue))

            ost->mux_timebase = ost->st->time_base;



        while (av_fifo_size(ost->muxing_queue)) {

            AVPacket pkt;

            av_fifo_generic_read(ost->muxing_queue, &pkt, sizeof(pkt), NULL);

            write_packet(VAR_0, &pkt, ost);

        }

    }



    return 0;

}

static int FUNC_0(OutputFile *VAR_0, int VAR_1)
{ int VAR_2, VAR_3; for (VAR_3 = 0; VAR_3 < VAR_0->ctx->nb_streams; VAR_3++) { OutputStream *ost = output_streams[VAR_0->ost_index + VAR_3]; if (!ost->initialized)
return 0; } VAR_0->ctx->interrupt_callback = int_cb; VAR_2 = avformat_write_header(VAR_0->ctx, &VAR_0->opts); if (VAR_2 < 0) { av_log(NULL, AV_LOG_ERROR,
"Could not write header for output file #%d "
"(incorrect codec parameters ?): %s\n",
VAR_1, av_err2str(VAR_2)); return VAR_2; } VAR_0->header_written = 1; av_dump_format(VAR_0->ctx, VAR_1, VAR_0->ctx->filename, 1); if (sdp_filename || want_sdp)
print_sdp(); for (VAR_3 = 0; VAR_3 < VAR_0->ctx->nb_streams; VAR_3++) { OutputStream *ost = output_streams[VAR_0->ost_index + VAR_3]; if (!av_fifo_size(ost->muxing_queue))
ost->mux_timebase = ost->st->time_base; while (av_fifo_size(ost->muxing_queue)) { AVPacket pkt; av_fifo_generic_read(ost->muxing_queue, &pkt, sizeof(pkt), NULL); write_packet(VAR_0, &pkt, ost); } } return 0; }