Files
SimpleRemoter/server/2015Remote/Bmp2Video.h
T
yuanyuanxiang 92bf9c9ccb Fix(record): correct MJPEG upside-down playback
and remove 0-byte AVI residue on encoder open failure
2026-05-23 13:37:28 +02:00

58 lines
1.7 KiB
C++

#pragma once
#include <Vfw.h>
#pragma comment(lib,"Vfw32.lib")
#include "LangManager.h"
#define ERR_INVALID_PARAM 1
#define ERR_NO_ENCODER 2
#define ERR_INTERNAL 3
#define ERR_NOT_SUPPORT 4
enum FCCHandler {
ENCODER_BMP = BI_RGB,
ENCODER_MJPEG = mmioFOURCC('M', 'J', 'P', 'G'),
// 安装x264vfw编解码器: https://sourceforge.net/projects/x264vfw/
ENCODER_H264 = mmioFOURCC('X', '2', '6', '4'),
};
/************************************************************************
* @class CBmpToAvi
* @brief 位图转AVI帧
************************************************************************/
class CBmpToAvi
{
public:
CBmpToAvi();
virtual ~CBmpToAvi();
int Open(LPCTSTR szFile, LPBITMAPINFO lpbmi, int rate = 4, FCCHandler h = ENCODER_BMP);
bool Write(unsigned char* lpBuffer);
void Close();
static std::string GetErrMsg(int result)
{
switch (result) {
case ERR_INVALID_PARAM:
return _L("无效参数").GetString();
case ERR_NOT_SUPPORT:
return _L("不支持的位深度,需要24位或32位").GetString();
case ERR_NO_ENCODER:
return _L("未安装x264编解码器 \n下载地址:https://sourceforge.net/projects/x264vfw").GetString();
case ERR_INTERNAL:
return _L("创建AVI文件失败").GetString();
default:
return "succeed";
}
}
private:
FCCHandler m_fccHandler;
PAVIFILE m_pfile;
PAVISTREAM m_pavi;
int m_nFrames;
static AVISTREAMINFO m_si; // 这个参数需要是静态的
int m_bitCount = 24;
int m_width = 1920;
int m_height = 1080;
int m_quality = 90;
HIC m_hic = NULL;
};