您的位置:首页 > 其它

解码单个视频及保存yuv数据到文件中

2015-06-19 09:10 309 查看
// 解码单路视频,并保存解码后的yuv数据到文件中去

// cudaDecode.lib是静态库文件,本程序实例展示如何调用此库文件相应接口实现解码功能

#include "iostream"
#include <tchar.h>
#include "windows.h"
#include "../header/cudaDecodeInterface.h"
//#pragma comment(lib,"cudaDecode.lib") // 链接到cudaDecode.lib

using namespace std;

HANDLE hand_cuda   = NULL;
bool   cuda_decodeEnd	= false;
FILE *fp = fopen("../decodePic/VideoSingle/videoSingle.yuv","wb");

int number = 0;

int CudaDecodeNotify(unsigned char* pDecodeData,int nDataSize,DWORD timestamp,int nEof)
{

//	fwrite(pDecodeData,1,nDataSize,fp);
	if(nEof)
	{
		OutputDebugString("thread 1 读包结束!!!\n");
		printf("-->thread 1 读包结束!!!\n");
//		fclose(fp);
		cuda_decodeEnd = true;
	}
	return 0;
}

void OnCuda()
{
	bool nstate = Cuda_SupportDecode();
	hand_cuda = Cuda_CreateDecoder();

	DWORD nTime = 0;
	if(Cuda_OpenFile(hand_cuda, "../data/720P/video0.m2v", CudaDecodeNotify)==1)
	{
		nTime = GetTickCount();
		printf("-->打开文件成功\n");
	}
	else
		printf("-->打开文件失败\n");

	while (!cuda_decodeEnd)
	{
		Sleep(1);
	}
	nTime = GetTickCount() - nTime;
	printf("-->解码完成   nTime = %d ms\n",nTime);
	int nRet = Cuda_DestroyDecoder(hand_cuda);
	printf("-->Cuda_DestroyDecoder = %d\n",nRet);
}

int _tmain(int argc, _TCHAR* argv[])
{
	printf("cuda Decoder....\n");

	OnCuda();

	fflush(stdin);
	getchar();
	return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: