源码工程:S26_Test3
H264/5编码案例实战
AVPacket, AVFrame
解码:
While(av_read_frame(..))
avcodec_send_packet
avcodec_receive_frame
编码:
While(read_camera(..))
avcodec_send_frame
avcodec_receive_packet
源码参考:
extern "C"
{
#include "libavutil/opt.h"
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavutil/imgutils.h"
};
//encode one frame
static int encode(AVCodecContext *pCodecCtx, AVFrame *pFrame, AVPacket *pPkt, FILE *out_file) {
int got_packet = 0;
int ret = avcodec_send_frame(pCodecCtx, pFrame);
if (ret < 0) {
//failed to send frame for encoding
return -1;
}
while (!re