本文主要是介绍FFmpeg解码封装为类以及Opencv显示播放,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
解码函数接口头文件
//#ifndef __FFMPEG_DECODE_H__
//#define __FFMPEG_DECODE_H__// Opencv
#include <opencv/cv.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>extern "C"
{
#include "libavutil/avutil.h"
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"//新版本里的图像转换结构需要引入的头文件
#include "libswscale/swscale.h"
};using namespace cv;//#pragma comment(lib, "avcodec.lib")
//#pragma comment(lib, "avformat.lib ")
//#pragma comment(lib, "avutil.lib ")
//#pragma comment(lib, "avdevice.lib ")
//#pragma comment(lib, "avfilter.lib ")
//#pragma comment(lib, "postproc.lib ")
//#pragma comment(lib, "swresample.lib")
//#pragma comment(lib, "swscale.lib ")class ffmpegDecode
{
public:ffmpegDecode(char * file = NULL);~ffmpegDecode();cv::Mat getDecodedFrame();cv::Mat getLastFrame();int readOneFrame();int getFrameInterval();private:AVFrame *pAvFrame;AVFormatContext *pFormatCtx;AVCodecContext *pCodecCtx;AVCodec *pCodec;int i; int videoindex;char *filepath;int ret, got_picture;SwsContext *img_convert_ctx;int y_size;AVPacket *packet;cv::Mat *pCvMat;void init();void openDecode();void prepare();void get(AVCodecContext *pCodecCtx, SwsContext *img_convert_ctx,AVFrame *pFr
这篇关于FFmpeg解码封装为类以及Opencv显示播放的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!