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

来源:互联网 发布:监控端口号怎么查看 编辑:程序博客网 时间:2024/06/05 18:18


// 解码单路视频,并保存解码后的yuv数据到文件中去

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


#include "iostream"#include <tchar.h>#include "windows.h"#include "../header/cudaDecodeInterface.h"//#pragma comment(lib,"cudaDecode.lib") // 链接到cudaDecode.libusing 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");}elseprintf("-->打开文件失败\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;}



0 0
原创粉丝点击