用SetASFWriterProfile函数设置了捕获视频的大小后,音频信息不能捕获,请问怎么解决,谢谢。(100分送上)(100)

  • 主题发起人 主题发起人 u9085
  • 开始时间 开始时间
U

u9085

Unregistered / Unconfirmed
GUEST, unregistred user!
用SetASFWriterProfile函数设置了捕获视频的大小后,音频信息不能捕获,请问怎么解决,谢谢。SetASFWriterProfile函数如下。function SetASFWriterProfile(pWriter: TASFWriter;
lWidth, lHeight, bitRate: Integer): HRESULT;var hr: HRESULT;
pvi: PVideoInfoHeader;
pProfile: IWMProfile;
pProfileMgr: IWMProfileManager;
pStream: IWMStreamConfig;
pMediaProps: IWMVideoMediaProps;
pMediaType: PWMMediaType;
cbMediaType: Cardinal;
ConfigAsfWriter: IConfigAsfWriter;
begin
{ hr = m_pWMVEncoder-> QueryInterface(IID_IConfigAsfWriter, (void**)&pConfig);
hr=LoadCustomProfile( "D1.prx ",&pProfile );
hr=pProfile-> GetStream(1,&pStreamConfig);
hr=pStreamConfig-> QueryInterface(IID_IWMMediaProps,(void**)&pProps);
hr=pProps-> GetMediaType(pType,&size);
BITMAPINFOHEADER* pBitmap=(BITMAPINFOHEADER*)&pHeader-> bmiHeader;
pBitmap-> biWidth=720;
pBitmap-> biHeight=576;
hr=pProps-> SetMediaType(pType);
hr=pProfile-> ReconfigStream(pStreamConfig);
hr=pConfig-> ConfigureFilterUsingProfile(pProfile);
} hr:=WMCreateProfileManager(pProfileMgr);
if FAILED(hr) then
begin
ShowMessage(format( 'Error on Call WMCreateProfileManager (%x)',
));
Result := hr;
exit;
end;

hr:= pProfileMgr.CreateEmptyProfile(WMT_VER_9_0,pProfile);
if FAILED(hr) then
begin
ShowMessage(format( 'Error on Call pProfileMgr.CreateEmptyProfile (%x) ',
));
Result:=hr;
exit;
end;

hr:= pProfile.SetName( 'Video1 ');
if FAILED(hr) then
begin
ShowMessage(format( 'Error on Call pProfile.SetName (%x) ',
));
Result := hr;
exit;
end;

hr := pProfile.SetDescription( 'LYSoft WMV ProFiles ');
if FAILED(hr) then
begin
ShowMessage(format( 'Error on Call pProfile.SetDescription (%x) ',
));
Result := hr;
exit;
end;

hr := pProfile.CreateNewStream(WMMEDIATYPE_Video, pStream);
if FAILED(hr) then
begin
ShowMessage(format( 'Error on Call pProfile.CreatenewStream (%x) ',
));
Result := hr;
exit;
end;
// Get the media properties interface for the new stream. hr := pStream.QueryInterface(IID_IWMVideoMediaProps, pMediaProps);
if FAILED(hr) then
begin
ShowMessage(format( 'Error on Call pStream.QueryInterface (%x) ',
));
Result := hr;
exit;
end;
// Get the media-type structure.// First, get the size of the media-type structure. hr := pMediaProps.GetMediaType(nil, cbMediaType);
if FAILED(hr) then
begin
ShowMessage(format( 'Error on Call pMediaProps.GetMediaType (%x) ',
));
Result := hr;
exit;
end;
// Allocate memory for the structure based on the retrieved size. pMediaType := AllocMem(cbMediatype);// Retrieve the media-type structure. hr := pMediaProps.GetMediaType(pMediaType, cbMediaType);
if FAILED(hr) then
begin
ShowMessage(format( 'Error on Call pMediaProps.GetMediaType (1) (%x) ',
));
Result := hr;
exit;
end;
// Change the video size pvi:=PVideoInfoHeader(pMediaType.pbFormat);
//ShowMessage(format( '%d,%d,%d,%d ',[pvi.bmiHeader.biWidth,pvi.bmiheader.biHeight,pvi.bmiHeader.biBitCount,pvi.bmiHeader.biSizeImage]));
pvi.bmiHeader.biWidth := lWidth;
pvi.bmiHeader.biHeight := lHeight;
pvi.bmiHeader.biSizeImage := pvi.bmiHeader.biWidth * pvi.bmiHeader.biHeight * pvi.bmiHeader.biBitCount div 8;
pvi.rcSource := RECT(0, 0, lWidth, lHeight);
pvi.rcTarget := RECT(0, 0, lWidth, lHeight);
pvi.dwBitRate := bitRate;
pvi.AvgTimePerFrame := Round(10000000 / 15);
// PFS = 15 pvi.bmiHeader.biCompression := WMMEDIASUBTYPE_WMV1.D1;
pMediaType.subtype := WMMEDIASUBTYPE_WMV1;
pMediaProps.SetMaxKeyFrameSpacing(30000000);
pMediaProps.SetQuality(100);
hr := pMediaProps.SetMediaType(pMediaType);
if FAILED(hr) then
begin
ShowMessage(format( 'Error on Call pMediaProps.SetMediaType (%x) ',
));
Result := hr;
exit;
end;
// Release the media properties interface and delete the structure. pMediaProps := nil;
FreeMem(pMediaType);
pMediaType := nil;
hr := pStream.SetBitrate(bitRate);
if FAILED(hr) then
begin
ShowMessage(format( 'Error on Call pStream.SetBitrate (%x) ',
));
Result := hr;
exit;
end;

pStream.SetBufferWindow($FFFFFFFF);// Set the stream number. hr := pStream.SetStreamNumber(1);
if FAILED(hr) then
begin
ShowMessage(format( 'Error on Call pStream.SetStreamNumber (%x) ',
));
Result := hr;
exit;
end;
// Include the new stream in the profile. hr := pProfile.AddStream(pStream);
if FAILED(hr) then
begin
ShowMessage(format( 'Error on Call pProfile.AddStream (%x) ',
));
Result := hr;
exit;
end;

pProfile.ReconfigStream(pStream);
pStream := nil;
hr := pWriter.QueryInterface(IID_IConfigAsfWriter, ConfigAsfWriter);
if FAILED(hr) then
begin
ShowMessage(format( 'Error on Call WMCreateProfileManager (%x) ',
));
Result := hr;
exit;
end;

hr := ConfigAsfWriter.ConfigureFilterUsingProfile(pProfile);
if Failed(hr) then
begin
ShowMessage(format( 'Error on Call pWriter.ConfigureFilterUsingProfile (%x) ',
));
Result := hr;
exit;
end;

ConfigAsfWriter := nil;// TODO: Save the custom profile to a string, and save the string to a file.// Release remaining interfaces. pProfile := nil;
pProfileMgr := nil;
Result := S_OK;
end;
 
后退
顶部