//gdiplay.cpp: 定义应用程序的入口点。
//
#include "stdafx.h"
#include "gdiplay.h"
#include <atlstr.h>
extern "C" {
#include "libavcodec\avcodec.h"
#include "libavformat\avformat.h"
#include "libavutil\channel_layout.h"
#include "libavutil\common.h"
#include "libavutil\imgutils.h"
#include "libswscale\swscale.h"
#include "libavutil\imgutils.h"
#include "libavutil\opt.h"
#include "libavutil\mathematics.h"
#include "libavutil\samplefmt.h"
#include "libavutil\timestamp.h"
#include "libavutil\log.h"
#include "libavutil\time.h"
#include "libswresample\swresample.h"
}
#define MAX_LOADSTRING 100
BOOL bOffThreadFlag = FALSE; //是否关闭当前的播放视频的线程
// 全局变量:
HINSTANCE hInst; // 当前实例
WCHAR szTitle[MAX_LOADSTRING]; // 标题栏文本
WCHAR szWindowClass[MAX_LOADSTRING]; // 主窗口类名
// 此代码模块中包含的函数的前向声明:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
HWND m_hWnd;
struct tagMediaParam
{
AVFormatContext *pFormatCtx;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
int videoindex;
SwsContext *img_convert_ctx;
RECT screenRect;
HANDLE thread;
};
tagMediaParam mParam;
CString GetFilePath(HWND* phWnd)
{
OPENFILENAME ofn; // 公共对话框结构。
TCHAR szFile[MAX_PATH]; // 保存获取文件名称的缓冲区。
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = *phWnd;
ofn.lpstrFile = szFile;
//
//
ofn.lpstrFile[0] = _T('\0');
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = _T("视频(*.*)\0*.*\0\0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
ofn.lpstrFileTitle = (LPTSTR)_T("打开");
// 显示打开选择文件对话框。
BOOL bRet = GetOpenFileName(&ofn);
if (bRet)
{
return szFile;
}
return _T("");
}
unsigned int __stdcall VideoRenderThread(LPVOID p)
{
tagMediaParam *pmParam = (tagMediaParam*)p;
AVPacket * packet = NULL;
AVFrame *pFrame = NULL;
AVFrame *pFrameRGB = NULL;
PVOID pbit = NULL;
BITMAP bmp = { 0 };
HBITMAP hBitmap = NULL;
BITMAPINFO bmpinfo = { 0 };
HDC h
简单的GDI+ffmpeg视频播放
最新推荐文章于 2023-05-20 14:59:28 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)