怎么把一个AVI转成MPG格式的文件
如何把一个AVI转成MPG格式的文件
使用pBuilder-> SetOutputFileName(
&MEDIASUBTYPE_MPEG1Video,//这里好象只能使用MEDIASUBTYPE_Avi和MEDIASUBTYPE_Asf
T2W(szOutFilename),
&pMux,
&pWriter);
不知道如何实现?
望老大们能给我一个简单的Sample Code!
我的信箱:njhjb@hotmail.com
收到结贴,不够补分!
------解决方案--------------------
#include "stdafx.h "
#include "getframe.h "
#include "getframeapi.h "
#include <vfw.h>
BOOL ExtractAVIFrames(CString szFileName)
{
AVIFileInit();
PAVIFILE avi;
int res=AVIFileOpen(&avi, szFileName, OF_READ, NULL);
if (res!=AVIERR_OK)
{
//an error occures
if (avi!=NULL)
AVIFileRelease(avi);
return FALSE;
}
AVIFILEINFO avi_info;
AVIFileInfo(avi, &avi_info, sizeof(AVIFILEINFO));
CString szFileInfo;
szFileInfo.Format( "Dimention: %dx%d\n "
"Length: %d frames\n "
"Max bytes per second: %d\n "
"Samples per second: %d\n "
"Streams: %d\n "
"File Type: %d ", avi_info.dwWidth,
avi_info.dwHeight,
avi_info.dwLength,
avi_info.dwMaxBytesPerSec,
(DWORD) (avi_info.dwRate / avi_info.dwScale),
avi_info.dwStreams,
avi_info.szFileType);
AfxMessageBox(szFileInfo, MB_ICONINFORMATION | MB_OK);
PAVISTREAM pStream;
res=AVIFileGetStream(avi, &pStream, streamtypeVIDEO /*video stream*/,
0 /*first stream*/);
if (res!=AVIERR_OK)
{
if (pStream!=NULL)
AVIStreamRelease(pStream);
AVIFileExit();
return FALSE;
}
//do some task with the stream
int iNumFrames;
int iFirstFrame;
iFirstFrame=AVIStreamStart(pStream);
if (iFirstFrame==-1)
{
//Error getteing the frame inside the stream
if (pStream!=NULL)
AVIStreamRelease(pStream);
AVIFileExit();
return FALSE;
}
iNumFrames=AVIStreamLength(pStream);
if (iNumFrames==-1)
{
//Error getteing the number of frames inside the stream
使用pBuilder-> SetOutputFileName(
&MEDIASUBTYPE_MPEG1Video,//这里好象只能使用MEDIASUBTYPE_Avi和MEDIASUBTYPE_Asf
T2W(szOutFilename),
&pMux,
&pWriter);
不知道如何实现?
望老大们能给我一个简单的Sample Code!
我的信箱:njhjb@hotmail.com
收到结贴,不够补分!
------解决方案--------------------
#include "stdafx.h "
#include "getframe.h "
#include "getframeapi.h "
#include <vfw.h>
BOOL ExtractAVIFrames(CString szFileName)
{
AVIFileInit();
PAVIFILE avi;
int res=AVIFileOpen(&avi, szFileName, OF_READ, NULL);
if (res!=AVIERR_OK)
{
//an error occures
if (avi!=NULL)
AVIFileRelease(avi);
return FALSE;
}
AVIFILEINFO avi_info;
AVIFileInfo(avi, &avi_info, sizeof(AVIFILEINFO));
CString szFileInfo;
szFileInfo.Format( "Dimention: %dx%d\n "
"Length: %d frames\n "
"Max bytes per second: %d\n "
"Samples per second: %d\n "
"Streams: %d\n "
"File Type: %d ", avi_info.dwWidth,
avi_info.dwHeight,
avi_info.dwLength,
avi_info.dwMaxBytesPerSec,
(DWORD) (avi_info.dwRate / avi_info.dwScale),
avi_info.dwStreams,
avi_info.szFileType);
AfxMessageBox(szFileInfo, MB_ICONINFORMATION | MB_OK);
PAVISTREAM pStream;
res=AVIFileGetStream(avi, &pStream, streamtypeVIDEO /*video stream*/,
0 /*first stream*/);
if (res!=AVIERR_OK)
{
if (pStream!=NULL)
AVIStreamRelease(pStream);
AVIFileExit();
return FALSE;
}
//do some task with the stream
int iNumFrames;
int iFirstFrame;
iFirstFrame=AVIStreamStart(pStream);
if (iFirstFrame==-1)
{
//Error getteing the frame inside the stream
if (pStream!=NULL)
AVIStreamRelease(pStream);
AVIFileExit();
return FALSE;
}
iNumFrames=AVIStreamLength(pStream);
if (iNumFrames==-1)
{
//Error getteing the number of frames inside the stream