c->pix_fmt = STREAM_PIX_FMT;
AVStream *add_video_stream(AVFormatContext *oc, int codec_id){    AVCodecContext *c;    AVStream *st;    st = av_new_stream(oc, 0);    if (!st) {        fprintf(stderr, "Could not alloc stream\n");        exit(1);    }        c = &st->codec;    c->codec_id = codec_id;    c->codec_type = CODEC_TYPE_VIDEO;    /* put sample parameters */    c->bit_rate = 400000;    /* resolution must be a multiple of two */    c->width = 352;      c->height = 288;    /* frames per second */    c->time_base.den = STREAM_FRAME_RATE;      c->time_base.num = 1;    c->gop_size = 12; /* emit one intra frame every twelve frames at most */    if (c->codec_id == CODEC_ID_MPEG2VIDEO) {        /* just for testing, we also add B frames */        c->max_b_frames = 2;    }    if (c->codec_id == CODEC_ID_MPEG1VIDEO){        /* needed to avoid using macroblocks in which some coeffs overflow            this doesnt happen with normal video, it just happens here as the            motion of the chroma plane doesnt match the luma plane */        c->mb_decision=2;    }    // some formats want stream headers to be seperate    if(!strcmp(oc->oformat->name, "mp4") || !strcmp(oc->oformat->name, "mov") || !strcmp(oc->oformat->name, "3gp"))        c->flags |= CODEC_FLAG_GLOBAL_HEADER;        return st;}