d盘有一个test.264文件,我们需要从这个h264文件中提取出一帧一帧的数据,所以直接采用ffmpeg来做。
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <libswscale/swscale.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/opt.h>
#include <libavutil/time.h>
#include <libavutil/avutil.h>
#include <libavutil/imgutils.h>
#include <libavutil/hwcontext.h>
#include <libavutil/error.h>
#ifdef __cplusplus
}
#endif
int main(int argc, char *argv[])
{
AVFormatContext *input_ctx = NULL;
AVCodecContext *decoder_ctx = NULL;
AVCodec *decoder = NULL;
enum AVHWDeviceType type;
const char *dec_name = "h264_qsv";
const char *in_file = "d://test.264";
int video_stream = 0, ret;
AVPacket packet;
/* open the input file */
if (avformat_open_input(&input_ctx, in_file