ffmpeg.c:3000: error: Null Dereference
  pointer `st` last assigned on line 2995 could be null and is dereferenced at line 3000, column 35.

ffmpeg.c:2989:1: start of procedure new_video_stream()
2987. }
2988. 
2989. static void new_video_stream(AVFormatContext *oc)
      ^
2990. {
2991.     AVStream *st;

ffmpeg.c:2995:5: 
2993.     int codec_id;
2994. 
2995.     st = av_new_stream(oc, oc->nb_streams);
          ^
2996.     if (!st) {
2997.         fprintf(stderr, "Could not alloc stream\n");

libavformat/utils.c:2341:1: start of procedure av_new_stream()
  2339. }
  2340. 
  2341. AVStream *av_new_stream(AVFormatContext *s, int id)
        ^
  2342. {
  2343.     AVStream *st;

libavformat/utils.c:2346:9: Taking true branch
  2344.     int i;
  2345. 
  2346.     if (s->nb_streams >= MAX_STREAMS)
                ^
  2347.         return NULL;
  2348. 

libavformat/utils.c:2347:9: 
  2345. 
  2346.     if (s->nb_streams >= MAX_STREAMS)
  2347.         return NULL;
                ^
  2348. 
  2349.     st = av_mallocz(sizeof(AVStream));

libavformat/utils.c:2381:1: return from a call to av_new_stream
  2379.     s->streams[s->nb_streams++] = st;
  2380.     return st;
  2381. }
        ^
  2382. 
  2383. AVProgram *av_new_program(AVFormatContext *ac, int id)

ffmpeg.c:2996:10: Taking true branch
2994. 
2995.     st = av_new_stream(oc, oc->nb_streams);
2996.     if (!st) {
               ^
2997.         fprintf(stderr, "Could not alloc stream\n");
2998.         av_exit(1);

ffmpeg.c:2997:9: 
2995.     st = av_new_stream(oc, oc->nb_streams);
2996.     if (!st) {
2997.         fprintf(stderr, "Could not alloc stream\n");
              ^
2998.         av_exit(1);
2999.     }

ffmpeg.c:2998:9: Skipping av_exit(): empty list of specs
2996.     if (!st) {
2997.         fprintf(stderr, "Could not alloc stream\n");
2998.         av_exit(1);
              ^
2999.     }
3000.     avcodec_get_context_defaults2(st->codec, CODEC_TYPE_VIDEO);

ffmpeg.c:3000:5: 
2998.         av_exit(1);
2999.     }
3000.     avcodec_get_context_defaults2(st->codec, CODEC_TYPE_VIDEO);
          ^
3001.     bitstream_filters[nb_output_files][oc->nb_streams - 1]= video_bitstream_filters;
3002.     video_bitstream_filters= NULL;

static void new_video_stream(AVFormatContext *oc)
{
    AVStream *st;
    AVCodecContext *video_enc;
    int codec_id;
    st = av_new_stream(oc, oc->nb_streams);
    if (!st) {
        fprintf(stderr, "Could not alloc stream\n");
        av_exit(1);
    }
    avcodec_get_context_defaults2(st->codec, CODEC_TYPE_VIDEO);
    bitstream_filters[nb_output_files][oc->nb_streams - 1]= video_bitstream_filters;
    video_bitstream_filters= NULL;
    if(thread_count>1)
        avcodec_thread_init(st->codec, thread_count);
    video_enc = st->codec;
    if(video_codec_tag)
        video_enc->codec_tag= video_codec_tag;
    if(   (video_global_header&1)
       || (video_global_header==0 && (oc->oformat->flags & AVFMT_GLOBALHEADER))){
        video_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
        avcodec_opts[CODEC_TYPE_VIDEO]->flags|= CODEC_FLAG_GLOBAL_HEADER;
    }
    if(video_global_header&2){
        video_enc->flags2 |= CODEC_FLAG2_LOCAL_HEADER;
        avcodec_opts[CODEC_TYPE_VIDEO]->flags2|= CODEC_FLAG2_LOCAL_HEADER;
    }
    if (video_stream_copy) {
        st->stream_copy = 1;
        video_enc->codec_type = CODEC_TYPE_VIDEO;
        video_enc->sample_aspect_ratio =
        st->sample_aspect_ratio = av_d2q(frame_aspect_ratio*frame_height/frame_width, 255);
    } else {
        const char *p;
        int i;
        AVCodec *codec;
        AVRational fps= frame_rate.num ? frame_rate : (AVRational){25,1};
        if (video_codec_name) {
            codec_id = find_codec_or_die(video_codec_name, CODEC_TYPE_VIDEO, 1);
            codec = avcodec_find_encoder_by_name(video_codec_name);
            output_codecs[nb_ocodecs] = codec;
        } else {
            codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, CODEC_TYPE_VIDEO);
            codec = avcodec_find_encoder(codec_id);
        }
        video_enc->codec_id = codec_id;
        set_context_opts(video_enc, avcodec_opts[CODEC_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
        if (codec && codec->supported_framerates && !force_fps)
            fps = codec->supported_framerates[av_find_nearest_q_idx(fps, codec->supported_framerates)];
        video_enc->time_base.den = fps.num;
        video_enc->time_base.num = fps.den;
        video_enc->width = frame_width + frame_padright + frame_padleft;
        video_enc->height = frame_height + frame_padtop + frame_padbottom;
        video_enc->sample_aspect_ratio = av_d2q(frame_aspect_ratio*video_enc->height/video_enc->width, 255);
        video_enc->pix_fmt = frame_pix_fmt;
        st->sample_aspect_ratio = video_enc->sample_aspect_ratio;
        if(codec && codec->pix_fmts){
            const enum PixelFormat *p= codec->pix_fmts;
            for(; *p!=-1; p++){
                if(*p == video_enc->pix_fmt)
                    break;
            }
            if(*p == -1)
                video_enc->pix_fmt = codec->pix_fmts[0];
        }
        if (intra_only)
            video_enc->gop_size = 0;
        if (video_qscale || same_quality) {
            video_enc->flags |= CODEC_FLAG_QSCALE;
            video_enc->global_quality=
                st->quality = FF_QP2LAMBDA * video_qscale;
        }
        if(intra_matrix)
            video_enc->intra_matrix = intra_matrix;
        if(inter_matrix)
            video_enc->inter_matrix = inter_matrix;
        video_enc->thread_count = thread_count;
        p= video_rc_override_string;
        for(i=0; p; i++){
            int start, end, q;
            int e=sscanf(p, "%d,%d,%d", &start, &end, &q);
            if(e!=3){
                fprintf(stderr, "error parsing rc_override\n");
                av_exit(1);
            }
            video_enc->rc_override=
                av_realloc(video_enc->rc_override,
                           sizeof(RcOverride)*(i+1));
            video_enc->rc_override[i].start_frame= start;
            video_enc->rc_override[i].end_frame  = end;
            if(q>0){
                video_enc->rc_override[i].qscale= q;
                video_enc->rc_override[i].quality_factor= 1.0;
            }
            else{
                video_enc->rc_override[i].qscale= 0;
                video_enc->rc_override[i].quality_factor= -q/100.0;
            }
            p= strchr(p, '/');
            if(p) p++;
        }
        video_enc->rc_override_count=i;
        if (!video_enc->rc_initial_buffer_occupancy)
            video_enc->rc_initial_buffer_occupancy = video_enc->rc_buffer_size*3/4;
        video_enc->me_threshold= me_threshold;
        video_enc->intra_dc_precision= intra_dc_precision - 8;
        if (do_psnr)
            video_enc->flags|= CODEC_FLAG_PSNR;
        if (do_pass) {
            if (do_pass == 1) {
                video_enc->flags |= CODEC_FLAG_PASS1;
            } else {
                video_enc->flags |= CODEC_FLAG_PASS2;
            }
        }
    }
    nb_ocodecs++;
    video_disable = 0;
    av_freep(&video_codec_name);
    video_stream_copy = 0;
}
['static void new_video_stream(AVFormatContext *oc)\n{\n    AVStream *st;\n    AVCodecContext *video_enc;\n    int codec_id;\n    st = av_new_stream(oc, oc->nb_streams);\n    if (!st) {\n        fprintf(stderr, "Could not alloc stream\\n");\n        av_exit(1);\n    }\n    avcodec_get_context_defaults2(st->codec, CODEC_TYPE_VIDEO);\n    bitstream_filters[nb_output_files][oc->nb_streams - 1]= video_bitstream_filters;\n    video_bitstream_filters= NULL;\n    if(thread_count>1)\n        avcodec_thread_init(st->codec, thread_count);\n    video_enc = st->codec;\n    if(video_codec_tag)\n        video_enc->codec_tag= video_codec_tag;\n    if(   (video_global_header&1)\n       || (video_global_header==0 && (oc->oformat->flags & AVFMT_GLOBALHEADER))){\n        video_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;\n        avcodec_opts[CODEC_TYPE_VIDEO]->flags|= CODEC_FLAG_GLOBAL_HEADER;\n    }\n    if(video_global_header&2){\n        video_enc->flags2 |= CODEC_FLAG2_LOCAL_HEADER;\n        avcodec_opts[CODEC_TYPE_VIDEO]->flags2|= CODEC_FLAG2_LOCAL_HEADER;\n    }\n    if (video_stream_copy) {\n        st->stream_copy = 1;\n        video_enc->codec_type = CODEC_TYPE_VIDEO;\n        video_enc->sample_aspect_ratio =\n        st->sample_aspect_ratio = av_d2q(frame_aspect_ratio*frame_height/frame_width, 255);\n    } else {\n        const char *p;\n        int i;\n        AVCodec *codec;\n        AVRational fps= frame_rate.num ? frame_rate : (AVRational){25,1};\n        if (video_codec_name) {\n            codec_id = find_codec_or_die(video_codec_name, CODEC_TYPE_VIDEO, 1);\n            codec = avcodec_find_encoder_by_name(video_codec_name);\n            output_codecs[nb_ocodecs] = codec;\n        } else {\n            codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, CODEC_TYPE_VIDEO);\n            codec = avcodec_find_encoder(codec_id);\n        }\n        video_enc->codec_id = codec_id;\n        set_context_opts(video_enc, avcodec_opts[CODEC_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM);\n        if (codec && codec->supported_framerates && !force_fps)\n            fps = codec->supported_framerates[av_find_nearest_q_idx(fps, codec->supported_framerates)];\n        video_enc->time_base.den = fps.num;\n        video_enc->time_base.num = fps.den;\n        video_enc->width = frame_width + frame_padright + frame_padleft;\n        video_enc->height = frame_height + frame_padtop + frame_padbottom;\n        video_enc->sample_aspect_ratio = av_d2q(frame_aspect_ratio*video_enc->height/video_enc->width, 255);\n        video_enc->pix_fmt = frame_pix_fmt;\n        st->sample_aspect_ratio = video_enc->sample_aspect_ratio;\n        if(codec && codec->pix_fmts){\n            const enum PixelFormat *p= codec->pix_fmts;\n            for(; *p!=-1; p++){\n                if(*p == video_enc->pix_fmt)\n                    break;\n            }\n            if(*p == -1)\n                video_enc->pix_fmt = codec->pix_fmts[0];\n        }\n        if (intra_only)\n            video_enc->gop_size = 0;\n        if (video_qscale || same_quality) {\n            video_enc->flags |= CODEC_FLAG_QSCALE;\n            video_enc->global_quality=\n                st->quality = FF_QP2LAMBDA * video_qscale;\n        }\n        if(intra_matrix)\n            video_enc->intra_matrix = intra_matrix;\n        if(inter_matrix)\n            video_enc->inter_matrix = inter_matrix;\n        video_enc->thread_count = thread_count;\n        p= video_rc_override_string;\n        for(i=0; p; i++){\n            int start, end, q;\n            int e=sscanf(p, "%d,%d,%d", &start, &end, &q);\n            if(e!=3){\n                fprintf(stderr, "error parsing rc_override\\n");\n                av_exit(1);\n            }\n            video_enc->rc_override=\n                av_realloc(video_enc->rc_override,\n                           sizeof(RcOverride)*(i+1));\n            video_enc->rc_override[i].start_frame= start;\n            video_enc->rc_override[i].end_frame  = end;\n            if(q>0){\n                video_enc->rc_override[i].qscale= q;\n                video_enc->rc_override[i].quality_factor= 1.0;\n            }\n            else{\n                video_enc->rc_override[i].qscale= 0;\n                video_enc->rc_override[i].quality_factor= -q/100.0;\n            }\n            p= strchr(p, \'/\');\n            if(p) p++;\n        }\n        video_enc->rc_override_count=i;\n        if (!video_enc->rc_initial_buffer_occupancy)\n            video_enc->rc_initial_buffer_occupancy = video_enc->rc_buffer_size*3/4;\n        video_enc->me_threshold= me_threshold;\n        video_enc->intra_dc_precision= intra_dc_precision - 8;\n        if (do_psnr)\n            video_enc->flags|= CODEC_FLAG_PSNR;\n        if (do_pass) {\n            if (do_pass == 1) {\n                video_enc->flags |= CODEC_FLAG_PASS1;\n            } else {\n                video_enc->flags |= CODEC_FLAG_PASS2;\n            }\n        }\n    }\n    nb_ocodecs++;\n    video_disable = 0;\n    av_freep(&video_codec_name);\n    video_stream_copy = 0;\n}', 'AVStream *av_new_stream(AVFormatContext *s, int id)\n{\n    AVStream *st;\n    int i;\n    if (s->nb_streams >= MAX_STREAMS)\n        return NULL;\n    st = av_mallocz(sizeof(AVStream));\n    if (!st)\n        return NULL;\n    st->codec= avcodec_alloc_context();\n    if (s->iformat) {\n        st->codec->bit_rate = 0;\n    }\n    st->index = s->nb_streams;\n    st->id = id;\n    st->start_time = AV_NOPTS_VALUE;\n    st->duration = AV_NOPTS_VALUE;\n    st->cur_dts = 0;\n    st->first_dts = AV_NOPTS_VALUE;\n    st->probe_packets = MAX_PROBE_PACKETS;\n    av_set_pts_info(st, 33, 1, 90000);\n    st->last_IP_pts = AV_NOPTS_VALUE;\n    for(i=0; i<MAX_REORDER_DELAY+1; i++)\n        st->pts_buffer[i]= AV_NOPTS_VALUE;\n    st->reference_dts = AV_NOPTS_VALUE;\n    st->sample_aspect_ratio = (AVRational){0,1};\n    s->streams[s->nb_streams++] = st;\n    return st;\n}']