相关
问题
编解码h264流时,会发现末尾丢帧。以ffmpeg为例,调用如下接口
int avcodec_encode_video2 ( AVCodecContext * avctx, AVPacket * avpkt, const AVFrame * frame, int * got_packet_ptr )
Encode a frame of video.
Takes input raw video data from frame and writes the next output packet, if available, to avpkt. The output packet does not necessarily contain data for the most recent frame, as encoders can delay and reorder input frames internally as needed.
int avcodec_decode_video2 ( AVCodecContext * avctx, AVFrame * picture, int * got_picture_ptr, const AVPacket * avpkt )
Decode the video frame of size avpkt->size from avpkt->data into picture.
Some decoders may support multiple frames in a single AVPacket, such decoders would then just decode the first frame.
官网api的提到:
Takes input raw video data from frame and writes the next output packet, if available, to avpkt. The