本文整理汇总了C++中AVIFileOpen函数的典型用法代码示例。如果您正苦于以下问题:C++ AVIFileOpen函数的具体用法?C++ AVIFileOpen怎么用?C++ AVIFileOpen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AVIFileOpen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: close
bool CvCaptureAVI_VFW::open( const char* filename )
{
close();
icvInitCapture_VFW();
if( !filename )
return false;
HRESULT hr = AVIFileOpen( &avifile, filename, OF_READ, NULL );
if( SUCCEEDED(hr))
{
hr = AVIFileGetStream( avifile, &avistream, streamtypeVIDEO, 0 );
if( SUCCEEDED(hr))
{
hr = AVIStreamInfo( avistream, &aviinfo, sizeof(aviinfo));
if( SUCCEEDED(hr))
{
size.width = aviinfo.rcFrame.right - aviinfo.rcFrame.left;
size.height = aviinfo.rcFrame.bottom - aviinfo.rcFrame.top;
BITMAPINFOHEADER bmihdr = icvBitmapHeader( size.width, size.height, 24 );
film_range.start_index = (int)aviinfo.dwStart;
film_range.end_index = film_range.start_index + (int)aviinfo.dwLength;
fps = (double)aviinfo.dwRate/aviinfo.dwScale;
pos = film_range.start_index;
getframe = AVIStreamGetFrameOpen( avistream, &bmihdr );
if( getframe != 0 )
return true;
}
}
}
close();
return false;
}
示例2: test_ash1_corruption2
static void test_ash1_corruption2(void)
{
COMMON_AVI_HEADERS cah;
char filename[MAX_PATH];
PAVIFILE pFile;
int res;
PAVISTREAM pStream1;
AVISTREAMINFO asi1;
GetTempPath(MAX_PATH, filename);
strcpy(filename+strlen(filename), testfilename);
/* Corrupt the block alignment in the audio format header */
init_test_struct(&cah);
cah.pcmwf.wf.nBlockAlign = 0xdead;
create_avi_file(&cah, filename);
res = AVIFileOpen(&pFile, filename, OF_SHARE_DENY_WRITE, 0L);
ok(res == 0, "Unable to open file: error=%u\n", res);
res = AVIFileGetStream(pFile, &pStream1, 0, 1);
ok(res == 0, "Unable to open audio stream: error=%u\n", res);
ok(AVIStreamInfo(pStream1, &asi1, sizeof(AVISTREAMINFO)) == 0, "Unable to read stream info\n");
/* The result will also be the corrupt value, as explained above. */
ok(asi1.dwSampleSize == 0xdead, "got 0x%x (expected 0xdead)\n", asi1.dwSampleSize);
AVIStreamRelease(pStream1);
AVIFileRelease(pFile);
ok(DeleteFile(filename) !=0, "Deleting file %s failed\n", filename);
}
示例3: test_ash1_corruption
static void test_ash1_corruption(void)
{
COMMON_AVI_HEADERS cah;
char filename[MAX_PATH];
PAVIFILE pFile;
int res;
PAVISTREAM pStream1;
AVISTREAMINFO asi1;
GetTempPath(MAX_PATH, filename);
strcpy(filename+strlen(filename), testfilename);
/* Corrupt the sample size in the audio stream header */
init_test_struct(&cah);
cah.ash1.dwSampleSize = 0xdeadbeef;
create_avi_file(&cah, filename);
res = AVIFileOpen(&pFile, filename, OF_SHARE_DENY_WRITE, 0L);
ok(res == 0, "Unable to open file: error=%u\n", res);
res = AVIFileGetStream(pFile, &pStream1, 0, 1);
ok(res == 0, "Unable to open audio stream: error=%u\n", res);
res = AVIStreamInfo(pStream1, &asi1, sizeof(AVISTREAMINFO));
ok(res == 0, "Unable to read stream info: error=%u\n", res);
/* The result will still be 2, because the value is dynamically replaced with the nBlockAlign
value from the stream format header. The next test will prove this */
ok(asi1.dwSampleSize == 2, "got %u (expected 2)\n", asi1.dwSampleSize);
AVIStreamRelease(pStream1);
AVIFileRelease(pFile);
ok(DeleteFile(filename) !=0, "Deleting file %s failed\n", filename);
}
示例4: CreateAvi
HAVI CreateAvi (const TCHAR *filename, int frameperiod, const WAVEFORMATEX *wfx)
{
PAVIFILE pfile;
HRESULT hr;
TAviUtil *au;
AVIFileInit();
hr = AVIFileOpen(&pfile, filename, OF_WRITE | OF_CREATE, NULL);
if (hr)
{
AVIFileExit();
return NULL;
}
au = (TAviUtil *)malloc(sizeof(TAviUtil));
au->pfile = pfile;
if (wfx)
CopyMemory(&au->wfx, wfx, sizeof(WAVEFORMATEX));
else ZeroMemory(&au->wfx, sizeof(WAVEFORMATEX));
au->period = frameperiod;
au->audStream = NULL;
au->vidStream = NULL;
au->vidStreamComp = NULL;
au->nframe = 0;
au->nsamp = 0;
au->iserr = FALSE;
return (HAVI)au;
}
示例5: FileDlg
void CMainFrame::InitAVIWriteOpt()
{
CString filename;
CFileDialog FileDlg(FALSE,_T("avi"));
if (FileDlg.DoModal()==IDOK)
{
filename = FileDlg.GetPathName();
//capGetVideoFormat(m_hWndCap,&m_InInfo,sizeof(m_InInfo));
m_Frame = 0 ;
//AVI文件初始化
AVIFileInit() ;
bSaveAVI = TRUE;
//打开文件
AVIFileOpen(&m_pFile,filename,OF_WRITE | OF_CREATE,NULL);
memset(&strhdr, 0, sizeof(strhdr)) ;
strhdr.fccType = streamtypeVIDEO;
strhdr.fccHandler = 0 ;
strhdr.dwScale = 1 ;
strhdr.dwRate = 25 ;
strhdr.dwSuggestedBufferSize = lpbiIn->bmiHeader.biSizeImage;
SetRect(&strhdr.rcFrame, 0, 0, lpbiIn->bmiHeader.biWidth, lpbiIn->bmiHeader.biHeight);
ps = NULL;
//文件文件流
AVIFileCreateStream(m_pFile,&ps,&strhdr);
//开始捕捉
capCaptureSequenceNoFile(m_hWndCap);
}
}
示例6: AVIFileInit
int imFileFormatAVI::New(const char* file_name)
{
/* initializes avi file library, can be called many times */
AVIFileInit();
/* creates a new file */
HRESULT hr = AVIFileOpen(&file, file_name, OF_WRITE | OF_CREATE, NULL);
if (hr != 0)
{
AVIFileExit();
if (hr == AVIERR_FILEOPEN)
return IM_ERR_OPEN;
else if (hr == AVIERR_BADFORMAT || hr == REGDB_E_CLASSNOTREG)
return IM_ERR_FORMAT;
else
return IM_ERR_ACCESS;
}
this->frame = 0;
this->stream = 0;
this->use_compressor = 0;
this->dib = 0;
return IM_ERR_NONE;
}
示例7: Open
bool CBmpToAvi::Open( LPCTSTR szFile, LPBITMAPINFO lpbmi )
{
if (szFile == NULL)
return false;
m_nFrames = 0;
if (AVIFileOpen(&m_pfile, szFile, OF_WRITE | OF_CREATE, NULL))
return false;
m_si.fccType = streamtypeVIDEO;
m_si.fccHandler = BI_RGB;
m_si.dwScale = 1;
m_si.dwRate = 5; // 每秒5帧
SetRect(&m_si.rcFrame, 0, 0, lpbmi->bmiHeader.biWidth, lpbmi->bmiHeader.biHeight);
m_si.dwSuggestedBufferSize = lpbmi->bmiHeader.biSizeImage;
if (AVIFileCreateStream(m_pfile, &m_pavi, &m_si))
return false;
if (AVIStreamSetFormat(m_pavi, 0, lpbmi, sizeof(BITMAPINFO)) != AVIERR_OK)
return false;
return true;
}
示例8: AVIFileInit
bool CAviHelper::AVI_resolution(const wstring& strAviFileName, int& width, int& height)
{
AVIFileInit();
PAVIFILE avi;
int res = AVIFileOpen(&avi, WS2S(strAviFileName).c_str(), OF_READ, NULL);
int n = GetLastError();
if (res!=AVIERR_OK)
{
//an error occures
if (avi!=NULL)
AVIFileRelease(avi);
return false;
}
AVIFILEINFO avi_info;
memset(&avi_info, 0, sizeof(AVIFILEINFO));
res = AVIFileInfo(avi, &avi_info, sizeof(AVIFILEINFO));
if( res != AVIERR_OK)
{
AVIFileExit();
return false;
}
width = avi_info.dwWidth;
height = avi_info.dwHeight;
AVIFileExit();
return true;
}
示例9: AVIFileOpen
bool CAVIFile::Open(const char *filename)
{
HRESULT hr = AVIFileOpen(&pfile, // returned file pointer
filename, // file name
OF_WRITE | OF_CREATE, // mode to open file with
NULL); // use handler determined
// from file extension....
if (hr != AVIERR_OK) {
bOK = false;
return false;
}
memset(&strhdr, 0, sizeof(strhdr));
strhdr.fccType = streamtypeVIDEO;// stream type
strhdr.fccHandler = 0;
strhdr.dwScale = 1;
strhdr.dwRate = rate;
strhdr.dwSuggestedBufferSize = bitmap.biSizeImage;
SetRect(&strhdr.rcFrame,
0,
0, // rectangle for stream
(int) bitmap.biWidth,
(int) bitmap.biHeight);
// And create the stream;
hr = AVIFileCreateStream(pfile, // file pointer
&ps, // returned stream pointer
&strhdr); // stream header
if (hr != AVIERR_OK) {
bOK = false;
return false;
}
memset(&opts, 0, sizeof(opts));
if(!AVISaveOptions(hWindow, 0, 1, &ps, aopts)) {
bOK = false;
return false;
}
hr = AVIMakeCompressedStream(&psCompressed, ps, &opts, NULL);
if (hr != AVIERR_OK) {
bOK = false;
return false;
}
hr = AVIStreamSetFormat(psCompressed, 0,
&bitmap, // stream format
bitmap.biSize + // format size
bitmap.biClrUsed * sizeof(RGBQUAD));
if (hr != AVIERR_OK) {
bOK = false;
return false;
}
return true;
}
示例10: OpenSoundFile
BOOL OpenSoundFile(HWND hWnd,PAVISTREAM *pavi)
{
#ifndef INTERIM_64_BIT // CCJ
OPENFILENAME ofn;
char filter[256];
AVIBuildFilter(filter,sizeof(filter),FALSE);
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.hInstance = NULL;
ofn.lpstrTitle = GetResString(IDS_RB_OPENSOUND);
ofn.lpstrFilter = filter;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 0;
ofn.lpstrFile = fileName;
ofn.nMaxFile = sizeof(fileName);
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = NULL;
ofn.lCustData = 0;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
if (GetOpenFileNamePreview(&ofn)) {
HRESULT hr;
PAVIFILE pfile;
PAVISTREAM pstream;
BOOL res = TRUE;
hr = AVIFileOpen(&pfile,fileName,OF_READ,NULL);
if (hr) return FALSE;
if (AVIFileGetStream(
pfile,&pstream,streamtypeAUDIO,0) != AVIERR_OK) {
res = FALSE;
goto done;
}
*pavi = pstream;
done:
AVIFileRelease(pfile);
return res;
} else {
return FALSE;
}
#else // INTERIM_64_BIT
return FALSE;
#endif // INTERIM_64_BIT
}
示例11: _Open
bool AviFrameGraber::_Open(void){
//thread_handle_ !=NULL means it is already opened
if (thread_handle_!=NULL) return false;
int res=AVIFileOpen(&avi_file_, file_path_.c_str(), OF_READ, NULL);
if (res!=AVIERR_OK){
woodychang0611::diagnostics::SendError(_T("AviFrameGraber Open File Fail"));
_Close();
return false;
}
res=AVIFileGetStream(avi_file_, &stream_, streamtypeVIDEO, 0/*first stream*/);
if (res!=AVIERR_OK){
woodychang0611::diagnostics::SendError(_T("AviFrameGraber Get Stream Fail"));
_Close();
return false;
}
if (AVIStreamStart(stream_)==-1 || AVIStreamLength(stream_)==-1){
woodychang0611::diagnostics::SendError(_T("AviFrameGraber Stream Start or Length no correct"));
_Close();
return false;
}
AVIFileInfo(avi_file_, &avi_info_, sizeof(AVIFILEINFO));
BITMAPINFOHEADER bih;
bih.biSize = sizeof(BITMAPINFOHEADER);
bih.biWidth = avi_info_.dwWidth;
bih.biHeight = avi_info_.dwHeight;
bih.biPlanes = 1;
bih.biBitCount = 24;
bih.biCompression = BI_RGB;
bih.biSizeImage = 0;
bih.biXPelsPerMeter = 0;
bih.biYPelsPerMeter = 0;
bih.biClrUsed = 0;
bih.biClrImportant = 0;
frame_=AVIStreamGetFrameOpen(stream_, (LPBITMAPINFOHEADER) &bih);
if (frame_ !=NULL){
start_frame_ = AVIStreamStart(stream_);
frame_length_ = AVIStreamLength(stream_);
current_frame_ = start_frame_;
//Set Frame info
frame_info_.start_frame_=start_frame_;
frame_info_.frame_length_ =frame_length_;
frame_info_.frame_per_second_=(FLOAT32)avi_info_.dwRate/avi_info_.dwScale;
frame_info_.frame_width_=(UINT16) avi_info_.dwWidth;
frame_info_.frame_height_=(UINT16) avi_info_.dwHeight;
_status = FRAME_SUBJECT_PAUSE;
thread_handle_ =CreateThread(NULL ,0,this->_ThreadFunc,this,0,NULL);
return true;
}else{
woodychang0611::diagnostics::SendError(_T("AviFrameGraber Get Frame Failed"));
}
return false;
}
示例12: Open
bool AVIWrite::Open(const char *filename)
{
// create the AVI file
if(FAILED(AVIFileOpen(&m_file,
filename,
OF_WRITE | OF_CREATE,
NULL))) {
m_failed = true;
return false;
}
// setup the video stream information
ZeroMemory(&m_header, sizeof(AVISTREAMINFO));
m_header.fccType = streamtypeVIDEO;
m_header.dwScale = 1;
m_header.dwRate = m_fps;
m_header.dwSuggestedBufferSize = m_bitmap.biSizeImage;
// create the video stream
if(FAILED(AVIFileCreateStream(m_file,
&m_stream,
&m_header))) {
m_failed = true;
return false;
}
ZeroMemory(&m_options, sizeof(AVICOMPRESSOPTIONS));
m_arrayOptions[0] = &m_options;
// call the dialog to setup the compress options to be used
if(!AVISaveOptions(AfxGetApp()->m_pMainWnd->GetSafeHwnd(), 0, 1, &m_stream, m_arrayOptions)) {
m_failed = true;
return false;
}
// create the compressed stream
if(FAILED(AVIMakeCompressedStream(&m_streamCompressed, m_stream, &m_options, NULL))) {
m_failed = true;
return false;
}
// setup the video stream format
if(FAILED( AVIStreamSetFormat(m_streamCompressed, 0,
&m_bitmap,
m_bitmap.biSize +
m_bitmap.biClrUsed * sizeof(RGBQUAD)))) {
m_failed = true;
return false;
}
return true;
}
示例13: CreateAvi
HAVI CreateAvi(const char *fn, int frameperiod, const WAVEFORMATEX *wfx)
{ IAVIFile *pfile;
AVIFileInit();
HRESULT hr = AVIFileOpen(&pfile, fn, OF_WRITE|OF_CREATE, NULL);
if (hr!=AVIERR_OK) {AVIFileExit(); return NULL;}
TAviUtil *au = new TAviUtil;
au->pfile = pfile;
if (wfx==NULL) ZeroMemory(&au->wfx,sizeof(WAVEFORMATEX)); else CopyMemory(&au->wfx,wfx,sizeof(WAVEFORMATEX));
au->period = frameperiod;
au->as=0; au->ps=0; au->psCompressed=0;
au->nframe=0; au->nsamp=0;
au->iserr=false;
return (HAVI)au;
}
示例14: AVIFileInit
void VideoReader::Open(CString strFilePath)
{
AVIFileInit();
LONG hr;
hr = AVIStreamOpenFromFile(&m_pAviStream, strFilePath, streamtypeVIDEO, 0, OF_READ, NULL);
if (hr != 0){
// Handle failure.
AfxMessageBox(L"Failed to open file, file must be an uncompressed video.");
}
else
{
HRESULT hr;
AVISTREAMINFO strhdr;
LONG lStreamSize;
// Determine the size of the format data using
// AVIStreamFormatSize.
AVIStreamFormatSize(m_pAviStream, 0, &lStreamSize);
if (lStreamSize > sizeof(m_bi)) // Format too large?
return;
lStreamSize = sizeof(m_bi);
hr = AVIStreamReadFormat(m_pAviStream, 0, &m_bi, &lStreamSize); // Read format
if (m_bi.biCompression != BI_RGB) // Wrong compression format?
return;
hr = AVIStreamInfo(m_pAviStream, &strhdr, sizeof(strhdr));
// Create new AVI file using AVIFileOpen.
hr = AVIFileOpen(&m_pf, strFilePath + L".Processed.avi", OF_WRITE | OF_CREATE, NULL);
if (hr != 0)
return;
m_currentSize = AVIStreamStart(m_pAviStream);
// Allocate memory for the bitmaps.
m_lpBuffer = (BYTE *)malloc(m_bi.biSizeImage);
}
}
示例15: test_amh_corruption
static void test_amh_corruption(void)
{
COMMON_AVI_HEADERS cah;
char filename[MAX_PATH];
PAVIFILE pFile;
int res;
GetTempPath(MAX_PATH, filename);
strcpy(filename+strlen(filename), testfilename);
/* Make sure only AVI files with the proper headers will be loaded */
init_test_struct(&cah);
cah.fh[3] = mmioFOURCC('A', 'V', 'i', ' ');
create_avi_file(&cah, filename);
res = AVIFileOpen(&pFile, filename, OF_SHARE_DENY_WRITE, 0L);
ok(res != 0, "Able to open file: error=%u\n", res);
ok(DeleteFile(filename) !=0, "Deleting file %s failed\n", filename);
}