avconv.c:1614: error: Uninitialized Value
  The value read from quality was never initialized.

avconv.c:1614:42: 
1612. #endif
1613.                             do_video_out(os, ost, ist, &picture, &frame_size,
1614.                                          same_quant ? quality : ost->st->codec->global_quality);
                                               ^
1615.                             if (vstats_filename && frame_size)
1616.                                 do_video_stats(os, ost, frame_size);

static int output_packet(InputStream *ist, int ist_index,
                         OutputStream **ost_table, int nb_ostreams,
                         const AVPacket *pkt)
{
    AVFormatContext *os;
    OutputStream *ost;
    int ret, i;
    int got_output;
    AVFrame picture;
    void *buffer_to_free = NULL;
    static unsigned int samples_size= 0;
    AVSubtitle subtitle, *subtitle_to_free;
    int64_t pkt_pts = AV_NOPTS_VALUE;
#if CONFIG_AVFILTER
    int frame_available;
#endif
    float quality;
    AVPacket avpkt;
    int bps = av_get_bytes_per_sample(ist->st->codec->sample_fmt);
    if(ist->next_pts == AV_NOPTS_VALUE)
        ist->next_pts= ist->pts;
    if (pkt == NULL) {
        av_init_packet(&avpkt);
        avpkt.data = NULL;
        avpkt.size = 0;
        goto handle_eof;
    } else {
        avpkt = *pkt;
    }
    if(pkt->dts != AV_NOPTS_VALUE)
        ist->next_pts = ist->pts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
    if(pkt->pts != AV_NOPTS_VALUE)
        pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
    while (avpkt.size > 0 || (!pkt && got_output)) {
        uint8_t *data_buf, *decoded_data_buf;
        int data_size, decoded_data_size;
    handle_eof:
        ist->pts= ist->next_pts;
        if(avpkt.size && avpkt.size != pkt->size &&
           ((!ist->showed_multi_packet_warning && verbose>0) || verbose>1)){
            fprintf(stderr, "Multiple frames in a packet from stream %d\n", pkt->stream_index);
            ist->showed_multi_packet_warning=1;
        }
        decoded_data_buf = NULL;
        decoded_data_size= 0;
        data_buf  = avpkt.data;
        data_size = avpkt.size;
        subtitle_to_free = NULL;
        if (ist->decoding_needed) {
            switch(ist->st->codec->codec_type) {
            case AVMEDIA_TYPE_AUDIO:{
                if(pkt && samples_size < FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE)) {
                    samples_size = FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE);
                    av_free(samples);
                    samples= av_malloc(samples_size);
                }
                decoded_data_size= samples_size;
                ret = avcodec_decode_audio3(ist->st->codec, samples, &decoded_data_size,
                                            &avpkt);
                if (ret < 0)
                    return ret;
                avpkt.data += ret;
                avpkt.size -= ret;
                data_size   = ret;
                got_output  = decoded_data_size > 0;
                if (!got_output) {
                    continue;
                }
                decoded_data_buf = (uint8_t *)samples;
                ist->next_pts += ((int64_t)AV_TIME_BASE/bps * decoded_data_size) /
                    (ist->st->codec->sample_rate * ist->st->codec->channels);
                break;}
            case AVMEDIA_TYPE_VIDEO:
                    decoded_data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
                    avcodec_get_frame_defaults(&picture);
                    avpkt.pts = pkt_pts;
                    avpkt.dts = ist->pts;
                    pkt_pts = AV_NOPTS_VALUE;
                    ret = avcodec_decode_video2(ist->st->codec,
                                                &picture, &got_output, &avpkt);
                    quality = same_quant ? picture.quality : 0;
                    if (ret < 0)
                        return ret;
                    if (!got_output) {
                        goto discard_packet;
                    }
                    ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx, picture.pkt_pts, picture.pkt_dts);
                    if (ist->st->codec->time_base.num != 0) {
                        int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame;
                        ist->next_pts += ((int64_t)AV_TIME_BASE *
                                          ist->st->codec->time_base.num * ticks) /
                            ist->st->codec->time_base.den;
                    }
                    avpkt.size = 0;
                    buffer_to_free = NULL;
                    pre_process_video_frame(ist, (AVPicture *)&picture, &buffer_to_free);
                    break;
            case AVMEDIA_TYPE_SUBTITLE:
                ret = avcodec_decode_subtitle2(ist->st->codec,
                                               &subtitle, &got_output, &avpkt);
                if (ret < 0)
                    return ret;
                if (!got_output) {
                    goto discard_packet;
                }
                subtitle_to_free = &subtitle;
                avpkt.size = 0;
                break;
            default:
                return -1;
            }
        } else {
            switch(ist->st->codec->codec_type) {
            case AVMEDIA_TYPE_AUDIO:
                ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) /
                    ist->st->codec->sample_rate;
                break;
            case AVMEDIA_TYPE_VIDEO:
                if (ist->st->codec->time_base.num != 0) {
                    int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame;
                    ist->next_pts += ((int64_t)AV_TIME_BASE *
                                      ist->st->codec->time_base.num * ticks) /
                        ist->st->codec->time_base.den;
                }
                break;
            }
            ret = avpkt.size;
            avpkt.size = 0;
        }
#if CONFIG_AVFILTER
        if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
            for (i = 0; i < nb_ostreams; i++) {
                ost = ost_table[i];
                if (ost->input_video_filter && ost->source_index == ist_index) {
                    AVRational sar;
                    if (ist->st->sample_aspect_ratio.num)
                        sar = ist->st->sample_aspect_ratio;
                    else
                        sar = ist->st->codec->sample_aspect_ratio;
                    av_vsrc_buffer_add_frame(ost->input_video_filter, &picture,
                                             ist->pts,
                                             sar);
                }
            }
        }
#endif
        if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
            if (audio_volume != 256) {
                short *volp;
                volp = samples;
                for(i=0;i<(decoded_data_size / sizeof(short));i++) {
                    int v = ((*volp) * audio_volume + 128) >> 8;
                    if (v < -32768) v = -32768;
                    if (v >  32767) v = 32767;
                    *volp++ = v;
                }
            }
        }
        if (rate_emu) {
            int64_t pts = av_rescale(ist->pts, 1000000, AV_TIME_BASE);
            int64_t now = av_gettime() - ist->start;
            if (pts > now)
                usleep(pts - now);
        }
        if (start_time == 0 || ist->pts >= start_time)
            for(i=0;i<nb_ostreams;i++) {
                int frame_size;
                ost = ost_table[i];
                if (ost->source_index == ist_index) {
#if CONFIG_AVFILTER
                frame_available = ist->st->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
                    !ost->output_video_filter || avfilter_poll_frame(ost->output_video_filter->inputs[0]);
                while (frame_available) {
                    AVRational ist_pts_tb;
                    if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ost->output_video_filter)
                        get_filtered_video_frame(ost->output_video_filter, &picture, &ost->picref, &ist_pts_tb);
                    if (ost->picref)
                        ist->pts = av_rescale_q(ost->picref->pts, ist_pts_tb, AV_TIME_BASE_Q);
#endif
                    os = output_files[ost->file_index];
                    if (ost->encoding_needed) {
                        av_assert0(ist->decoding_needed);
                        switch(ost->st->codec->codec_type) {
                        case AVMEDIA_TYPE_AUDIO:
                            do_audio_out(os, ost, ist, decoded_data_buf, decoded_data_size);
                            break;
                        case AVMEDIA_TYPE_VIDEO:
#if CONFIG_AVFILTER
                            if (ost->picref->video && !ost->frame_aspect_ratio)
                                ost->st->codec->sample_aspect_ratio = ost->picref->video->pixel_aspect;
#endif
                            do_video_out(os, ost, ist, &picture, &frame_size,
                                         same_quant ? quality : ost->st->codec->global_quality);
                            if (vstats_filename && frame_size)
                                do_video_stats(os, ost, frame_size);
                            break;
                        case AVMEDIA_TYPE_SUBTITLE:
                            do_subtitle_out(os, ost, ist, &subtitle,
                                            pkt->pts);
                            break;
                        default:
                            abort();
                        }
                    } else {
                        AVFrame avframe;
                        AVPacket opkt;
                        int64_t ost_tb_start_time= av_rescale_q(start_time, AV_TIME_BASE_Q, ost->st->time_base);
                        av_init_packet(&opkt);
                        if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && !copy_initial_nonkeyframes)
#if !CONFIG_AVFILTER
                            continue;
#else
                            goto cont;
#endif
                        avcodec_get_frame_defaults(&avframe);
                        ost->st->codec->coded_frame= &avframe;
                        avframe.key_frame = pkt->flags & AV_PKT_FLAG_KEY;
                        if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
                            audio_size += data_size;
                        else if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
                            video_size += data_size;
                            ost->sync_opts++;
                        }
                        opkt.stream_index= ost->index;
                        if(pkt->pts != AV_NOPTS_VALUE)
                            opkt.pts= av_rescale_q(pkt->pts, ist->st->time_base, ost->st->time_base) - ost_tb_start_time;
                        else
                            opkt.pts= AV_NOPTS_VALUE;
                        if (pkt->dts == AV_NOPTS_VALUE)
                            opkt.dts = av_rescale_q(ist->pts, AV_TIME_BASE_Q, ost->st->time_base);
                        else
                            opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->st->time_base);
                        opkt.dts -= ost_tb_start_time;
                        opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->st->time_base);
                        opkt.flags= pkt->flags;
                        if(   ost->st->codec->codec_id != CODEC_ID_H264
                           && ost->st->codec->codec_id != CODEC_ID_MPEG1VIDEO
                           && ost->st->codec->codec_id != CODEC_ID_MPEG2VIDEO
                           ) {
                            if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & AV_PKT_FLAG_KEY))
                                opkt.destruct= av_destruct_packet;
                        } else {
                            opkt.data = data_buf;
                            opkt.size = data_size;
                        }
                        write_frame(os, &opkt, ost->st->codec, ost->bitstream_filters);
                        ost->st->codec->frame_number++;
                        ost->frame_number++;
                        av_free_packet(&opkt);
                    }
#if CONFIG_AVFILTER
                    cont:
                    frame_available = (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
                                       ost->output_video_filter && avfilter_poll_frame(ost->output_video_filter->inputs[0]);
                    if (ost->picref)
                        avfilter_unref_buffer(ost->picref);
                }
#endif
                }
            }
        av_free(buffer_to_free);
        if (subtitle_to_free) {
            avsubtitle_free(subtitle_to_free);
            subtitle_to_free = NULL;
        }
    }
 discard_packet:
    if (pkt == NULL) {
        for(i=0;i<nb_ostreams;i++) {
            ost = ost_table[i];
            if (ost->source_index == ist_index) {
                AVCodecContext *enc= ost->st->codec;
                os = output_files[ost->file_index];
                if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <=1)
                    continue;
                if(ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE))
                    continue;
                if (ost->encoding_needed) {
                    for(;;) {
                        AVPacket pkt;
                        int fifo_bytes;
                        av_init_packet(&pkt);
                        pkt.stream_index= ost->index;
                        switch(ost->st->codec->codec_type) {
                        case AVMEDIA_TYPE_AUDIO:
                            fifo_bytes = av_fifo_size(ost->fifo);
                            ret = 0;
                            if (fifo_bytes > 0) {
                                int osize = av_get_bytes_per_sample(enc->sample_fmt);
                                int fs_tmp = enc->frame_size;
                                av_fifo_generic_read(ost->fifo, audio_buf, fifo_bytes, NULL);
                                if (enc->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
                                    enc->frame_size = fifo_bytes / (osize * enc->channels);
                                } else {
                                    int frame_bytes = enc->frame_size*osize*enc->channels;
                                    if (allocated_audio_buf_size < frame_bytes)
                                        exit_program(1);
                                    generate_silence(audio_buf+fifo_bytes, enc->sample_fmt, frame_bytes - fifo_bytes);
                                }
                                ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, (short *)audio_buf);
                                pkt.duration = av_rescale((int64_t)enc->frame_size*ost->st->time_base.den,
                                                          ost->st->time_base.num, enc->sample_rate);
                                enc->frame_size = fs_tmp;
                            }
                            if(ret <= 0) {
                                ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, NULL);
                            }
                            if (ret < 0) {
                                fprintf(stderr, "Audio encoding failed\n");
                                exit_program(1);
                            }
                            audio_size += ret;
                            pkt.flags |= AV_PKT_FLAG_KEY;
                            break;
                        case AVMEDIA_TYPE_VIDEO:
                            ret = avcodec_encode_video(enc, bit_buffer, bit_buffer_size, NULL);
                            if (ret < 0) {
                                fprintf(stderr, "Video encoding failed\n");
                                exit_program(1);
                            }
                            video_size += ret;
                            if(enc->coded_frame && enc->coded_frame->key_frame)
                                pkt.flags |= AV_PKT_FLAG_KEY;
                            if (ost->logfile && enc->stats_out) {
                                fprintf(ost->logfile, "%s", enc->stats_out);
                            }
                            break;
                        default:
                            ret=-1;
                        }
                        if(ret<=0)
                            break;
                        pkt.data= bit_buffer;
                        pkt.size= ret;
                        if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)
                            pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
                        write_frame(os, &pkt, ost->st->codec, ost->bitstream_filters);
                    }
                }
            }
        }
    }
    return 0;
}
['static int output_packet(InputStream *ist, int ist_index,\n                         OutputStream **ost_table, int nb_ostreams,\n                         const AVPacket *pkt)\n{\n    AVFormatContext *os;\n    OutputStream *ost;\n    int ret, i;\n    int got_output;\n    AVFrame picture;\n    void *buffer_to_free = NULL;\n    static unsigned int samples_size= 0;\n    AVSubtitle subtitle, *subtitle_to_free;\n    int64_t pkt_pts = AV_NOPTS_VALUE;\n#if CONFIG_AVFILTER\n    int frame_available;\n#endif\n    float quality;\n    AVPacket avpkt;\n    int bps = av_get_bytes_per_sample(ist->st->codec->sample_fmt);\n    if(ist->next_pts == AV_NOPTS_VALUE)\n        ist->next_pts= ist->pts;\n    if (pkt == NULL) {\n        av_init_packet(&avpkt);\n        avpkt.data = NULL;\n        avpkt.size = 0;\n        goto handle_eof;\n    } else {\n        avpkt = *pkt;\n    }\n    if(pkt->dts != AV_NOPTS_VALUE)\n        ist->next_pts = ist->pts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);\n    if(pkt->pts != AV_NOPTS_VALUE)\n        pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);\n    while (avpkt.size > 0 || (!pkt && got_output)) {\n        uint8_t *data_buf, *decoded_data_buf;\n        int data_size, decoded_data_size;\n    handle_eof:\n        ist->pts= ist->next_pts;\n        if(avpkt.size && avpkt.size != pkt->size &&\n           ((!ist->showed_multi_packet_warning && verbose>0) || verbose>1)){\n            fprintf(stderr, "Multiple frames in a packet from stream %d\\n", pkt->stream_index);\n            ist->showed_multi_packet_warning=1;\n        }\n        decoded_data_buf = NULL;\n        decoded_data_size= 0;\n        data_buf  = avpkt.data;\n        data_size = avpkt.size;\n        subtitle_to_free = NULL;\n        if (ist->decoding_needed) {\n            switch(ist->st->codec->codec_type) {\n            case AVMEDIA_TYPE_AUDIO:{\n                if(pkt && samples_size < FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE)) {\n                    samples_size = FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE);\n                    av_free(samples);\n                    samples= av_malloc(samples_size);\n                }\n                decoded_data_size= samples_size;\n                ret = avcodec_decode_audio3(ist->st->codec, samples, &decoded_data_size,\n                                            &avpkt);\n                if (ret < 0)\n                    return ret;\n                avpkt.data += ret;\n                avpkt.size -= ret;\n                data_size   = ret;\n                got_output  = decoded_data_size > 0;\n                if (!got_output) {\n                    continue;\n                }\n                decoded_data_buf = (uint8_t *)samples;\n                ist->next_pts += ((int64_t)AV_TIME_BASE/bps * decoded_data_size) /\n                    (ist->st->codec->sample_rate * ist->st->codec->channels);\n                break;}\n            case AVMEDIA_TYPE_VIDEO:\n                    decoded_data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;\n                    avcodec_get_frame_defaults(&picture);\n                    avpkt.pts = pkt_pts;\n                    avpkt.dts = ist->pts;\n                    pkt_pts = AV_NOPTS_VALUE;\n                    ret = avcodec_decode_video2(ist->st->codec,\n                                                &picture, &got_output, &avpkt);\n                    quality = same_quant ? picture.quality : 0;\n                    if (ret < 0)\n                        return ret;\n                    if (!got_output) {\n                        goto discard_packet;\n                    }\n                    ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx, picture.pkt_pts, picture.pkt_dts);\n                    if (ist->st->codec->time_base.num != 0) {\n                        int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame;\n                        ist->next_pts += ((int64_t)AV_TIME_BASE *\n                                          ist->st->codec->time_base.num * ticks) /\n                            ist->st->codec->time_base.den;\n                    }\n                    avpkt.size = 0;\n                    buffer_to_free = NULL;\n                    pre_process_video_frame(ist, (AVPicture *)&picture, &buffer_to_free);\n                    break;\n            case AVMEDIA_TYPE_SUBTITLE:\n                ret = avcodec_decode_subtitle2(ist->st->codec,\n                                               &subtitle, &got_output, &avpkt);\n                if (ret < 0)\n                    return ret;\n                if (!got_output) {\n                    goto discard_packet;\n                }\n                subtitle_to_free = &subtitle;\n                avpkt.size = 0;\n                break;\n            default:\n                return -1;\n            }\n        } else {\n            switch(ist->st->codec->codec_type) {\n            case AVMEDIA_TYPE_AUDIO:\n                ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) /\n                    ist->st->codec->sample_rate;\n                break;\n            case AVMEDIA_TYPE_VIDEO:\n                if (ist->st->codec->time_base.num != 0) {\n                    int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame;\n                    ist->next_pts += ((int64_t)AV_TIME_BASE *\n                                      ist->st->codec->time_base.num * ticks) /\n                        ist->st->codec->time_base.den;\n                }\n                break;\n            }\n            ret = avpkt.size;\n            avpkt.size = 0;\n        }\n#if CONFIG_AVFILTER\n        if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {\n            for (i = 0; i < nb_ostreams; i++) {\n                ost = ost_table[i];\n                if (ost->input_video_filter && ost->source_index == ist_index) {\n                    AVRational sar;\n                    if (ist->st->sample_aspect_ratio.num)\n                        sar = ist->st->sample_aspect_ratio;\n                    else\n                        sar = ist->st->codec->sample_aspect_ratio;\n                    av_vsrc_buffer_add_frame(ost->input_video_filter, &picture,\n                                             ist->pts,\n                                             sar);\n                }\n            }\n        }\n#endif\n        if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {\n            if (audio_volume != 256) {\n                short *volp;\n                volp = samples;\n                for(i=0;i<(decoded_data_size / sizeof(short));i++) {\n                    int v = ((*volp) * audio_volume + 128) >> 8;\n                    if (v < -32768) v = -32768;\n                    if (v >  32767) v = 32767;\n                    *volp++ = v;\n                }\n            }\n        }\n        if (rate_emu) {\n            int64_t pts = av_rescale(ist->pts, 1000000, AV_TIME_BASE);\n            int64_t now = av_gettime() - ist->start;\n            if (pts > now)\n                usleep(pts - now);\n        }\n        if (start_time == 0 || ist->pts >= start_time)\n            for(i=0;i<nb_ostreams;i++) {\n                int frame_size;\n                ost = ost_table[i];\n                if (ost->source_index == ist_index) {\n#if CONFIG_AVFILTER\n                frame_available = ist->st->codec->codec_type != AVMEDIA_TYPE_VIDEO ||\n                    !ost->output_video_filter || avfilter_poll_frame(ost->output_video_filter->inputs[0]);\n                while (frame_available) {\n                    AVRational ist_pts_tb;\n                    if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ost->output_video_filter)\n                        get_filtered_video_frame(ost->output_video_filter, &picture, &ost->picref, &ist_pts_tb);\n                    if (ost->picref)\n                        ist->pts = av_rescale_q(ost->picref->pts, ist_pts_tb, AV_TIME_BASE_Q);\n#endif\n                    os = output_files[ost->file_index];\n                    if (ost->encoding_needed) {\n                        av_assert0(ist->decoding_needed);\n                        switch(ost->st->codec->codec_type) {\n                        case AVMEDIA_TYPE_AUDIO:\n                            do_audio_out(os, ost, ist, decoded_data_buf, decoded_data_size);\n                            break;\n                        case AVMEDIA_TYPE_VIDEO:\n#if CONFIG_AVFILTER\n                            if (ost->picref->video && !ost->frame_aspect_ratio)\n                                ost->st->codec->sample_aspect_ratio = ost->picref->video->pixel_aspect;\n#endif\n                            do_video_out(os, ost, ist, &picture, &frame_size,\n                                         same_quant ? quality : ost->st->codec->global_quality);\n                            if (vstats_filename && frame_size)\n                                do_video_stats(os, ost, frame_size);\n                            break;\n                        case AVMEDIA_TYPE_SUBTITLE:\n                            do_subtitle_out(os, ost, ist, &subtitle,\n                                            pkt->pts);\n                            break;\n                        default:\n                            abort();\n                        }\n                    } else {\n                        AVFrame avframe;\n                        AVPacket opkt;\n                        int64_t ost_tb_start_time= av_rescale_q(start_time, AV_TIME_BASE_Q, ost->st->time_base);\n                        av_init_packet(&opkt);\n                        if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && !copy_initial_nonkeyframes)\n#if !CONFIG_AVFILTER\n                            continue;\n#else\n                            goto cont;\n#endif\n                        avcodec_get_frame_defaults(&avframe);\n                        ost->st->codec->coded_frame= &avframe;\n                        avframe.key_frame = pkt->flags & AV_PKT_FLAG_KEY;\n                        if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)\n                            audio_size += data_size;\n                        else if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {\n                            video_size += data_size;\n                            ost->sync_opts++;\n                        }\n                        opkt.stream_index= ost->index;\n                        if(pkt->pts != AV_NOPTS_VALUE)\n                            opkt.pts= av_rescale_q(pkt->pts, ist->st->time_base, ost->st->time_base) - ost_tb_start_time;\n                        else\n                            opkt.pts= AV_NOPTS_VALUE;\n                        if (pkt->dts == AV_NOPTS_VALUE)\n                            opkt.dts = av_rescale_q(ist->pts, AV_TIME_BASE_Q, ost->st->time_base);\n                        else\n                            opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->st->time_base);\n                        opkt.dts -= ost_tb_start_time;\n                        opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->st->time_base);\n                        opkt.flags= pkt->flags;\n                        if(   ost->st->codec->codec_id != CODEC_ID_H264\n                           && ost->st->codec->codec_id != CODEC_ID_MPEG1VIDEO\n                           && ost->st->codec->codec_id != CODEC_ID_MPEG2VIDEO\n                           ) {\n                            if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & AV_PKT_FLAG_KEY))\n                                opkt.destruct= av_destruct_packet;\n                        } else {\n                            opkt.data = data_buf;\n                            opkt.size = data_size;\n                        }\n                        write_frame(os, &opkt, ost->st->codec, ost->bitstream_filters);\n                        ost->st->codec->frame_number++;\n                        ost->frame_number++;\n                        av_free_packet(&opkt);\n                    }\n#if CONFIG_AVFILTER\n                    cont:\n                    frame_available = (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&\n                                       ost->output_video_filter && avfilter_poll_frame(ost->output_video_filter->inputs[0]);\n                    if (ost->picref)\n                        avfilter_unref_buffer(ost->picref);\n                }\n#endif\n                }\n            }\n        av_free(buffer_to_free);\n        if (subtitle_to_free) {\n            avsubtitle_free(subtitle_to_free);\n            subtitle_to_free = NULL;\n        }\n    }\n discard_packet:\n    if (pkt == NULL) {\n        for(i=0;i<nb_ostreams;i++) {\n            ost = ost_table[i];\n            if (ost->source_index == ist_index) {\n                AVCodecContext *enc= ost->st->codec;\n                os = output_files[ost->file_index];\n                if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <=1)\n                    continue;\n                if(ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE))\n                    continue;\n                if (ost->encoding_needed) {\n                    for(;;) {\n                        AVPacket pkt;\n                        int fifo_bytes;\n                        av_init_packet(&pkt);\n                        pkt.stream_index= ost->index;\n                        switch(ost->st->codec->codec_type) {\n                        case AVMEDIA_TYPE_AUDIO:\n                            fifo_bytes = av_fifo_size(ost->fifo);\n                            ret = 0;\n                            if (fifo_bytes > 0) {\n                                int osize = av_get_bytes_per_sample(enc->sample_fmt);\n                                int fs_tmp = enc->frame_size;\n                                av_fifo_generic_read(ost->fifo, audio_buf, fifo_bytes, NULL);\n                                if (enc->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {\n                                    enc->frame_size = fifo_bytes / (osize * enc->channels);\n                                } else {\n                                    int frame_bytes = enc->frame_size*osize*enc->channels;\n                                    if (allocated_audio_buf_size < frame_bytes)\n                                        exit_program(1);\n                                    generate_silence(audio_buf+fifo_bytes, enc->sample_fmt, frame_bytes - fifo_bytes);\n                                }\n                                ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, (short *)audio_buf);\n                                pkt.duration = av_rescale((int64_t)enc->frame_size*ost->st->time_base.den,\n                                                          ost->st->time_base.num, enc->sample_rate);\n                                enc->frame_size = fs_tmp;\n                            }\n                            if(ret <= 0) {\n                                ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, NULL);\n                            }\n                            if (ret < 0) {\n                                fprintf(stderr, "Audio encoding failed\\n");\n                                exit_program(1);\n                            }\n                            audio_size += ret;\n                            pkt.flags |= AV_PKT_FLAG_KEY;\n                            break;\n                        case AVMEDIA_TYPE_VIDEO:\n                            ret = avcodec_encode_video(enc, bit_buffer, bit_buffer_size, NULL);\n                            if (ret < 0) {\n                                fprintf(stderr, "Video encoding failed\\n");\n                                exit_program(1);\n                            }\n                            video_size += ret;\n                            if(enc->coded_frame && enc->coded_frame->key_frame)\n                                pkt.flags |= AV_PKT_FLAG_KEY;\n                            if (ost->logfile && enc->stats_out) {\n                                fprintf(ost->logfile, "%s", enc->stats_out);\n                            }\n                            break;\n                        default:\n                            ret=-1;\n                        }\n                        if(ret<=0)\n                            break;\n                        pkt.data= bit_buffer;\n                        pkt.size= ret;\n                        if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)\n                            pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);\n                        write_frame(os, &pkt, ost->st->codec, ost->bitstream_filters);\n                    }\n                }\n            }\n        }\n    }\n    return 0;\n}']