int ret = avcodec_encode_video2(pCodecCtx, &pkt, pFrame, &got_picture);
Encode a frame of video. That is, AVFrame (storing YUV pixel data) is encoded into AVPacket (storing bit stream data in H.264 and other formats).
Return 0 on success, return a negative error code on failure, return an error return code on failure