📄 subject_32347.htm
字号:
<blockquote><p>
回复者:Creator 回复日期:2003-03-24 13:32:12
<br>内容:ICaptureGraphBuilder2 *pBuild =NULL;<BR>................<BR>hr=CoCreateInstance(CLSID_CaptureGraphBuilder,NULL,CLSCTX_INPROC,<BR> IID_ICaptureGraphBuilder,(void **)&pBuild);<BR><BR><BR>另你的主要意图是干吗?<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:jacky 回复日期:2003-03-24 15:56:39
<br>内容:ICaptureGraphBuilder2 *pBuild =NULL;<BR>................<BR>hr=CoCreateInstance(CLSID_CaptureGraphBuilder,NULL,CLSCTX_INPROC,<BR> IID_ICaptureGraphBuilder,(void **)&pBuild);(如果此处是用CLSID_CaptureGraphBuilder2,则hr返回的不是S_OK,出错!这个例子是directx8.0 c++中的,稍改的!原代码在下!#include <dshow.h><BR>#include <stdio.h><BR><BR>void __cdecl main(void)<BR>{<BR> ICaptureGraphBuilder2 *pBuild = NULL;<BR> IGraphBuilder *pGraph = NULL;<BR> IBaseFilter *pSrc = NULL; // Source filter<BR> IBaseFilter *pMux = NULL; // MUX filter<BR> IBaseFilter *pVComp = NULL; // Video compressor filter<BR><BR> CoInitialize(NULL);<BR><BR> // Create the capture graph builder.<BR> CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC, <BR> IID_ICaptureGraphBuilder2, (void **)&pBuild);<BR><BR> // Make the rendering section of the graph.<BR> pBuild->SetOutputFileName(<BR> &MEDIASUBTYPE_Avi, // File type. <BR> L"C:\\Output.avi", // File name.<BR> &pMux, // Receives a pointer to the multiplexer.<BR> NULL); // Receives a pointer to the file writer. <BR> <BR> // Load the source file.<BR> pBuild->GetFiltergraph(&pGraph);<BR> pGraph->AddSourceFilter(L"C:\\Input.avi", L"Source Filter", &pSrc);<BR><BR> // Add the compressor filter.<BR> CoCreateInstance(CLSID_AVICo, NULL, CLSCTX_INPROC, <BR> IID_IBaseFilter, (void **)&pVComp); <BR> pGraph->AddFilter(pVComp, L"Compressor");<BR><BR> // Render the video stream, through the compressor.<BR> pBuild->RenderStream(<BR> NULL, // Output pin category<BR> NULL, // Media type<BR> pSrc, // Source filter<BR> pVComp, // Compressor filter<BR> pMux); // Sink filter (the AVI Mux)<BR><BR> // Render the audio stream.<BR> pBuild->RenderStream(NULL, NULL, pSrc, NULL, pMux);<BR><BR> // Set video compression properties.<BR> IAMStreamConfig *pStreamConfig = NULL;<BR> IAMVideoCompression *pCompress = NULL;<BR><BR> // Compress at 100k/second data rate.<BR> AM_MEDIA_TYPE *pmt;<BR> pBuild->FindInterface(NULL, NULL, pVComp, IID_IAMStreamConfig, (void **)&pStreamConfig); <BR> pStreamConfig->GetFormat(&pmt);<BR> if (pmt->formattype == FORMAT_VideoInfo) <BR> {<BR> ((VIDEOINFOHEADER *)(pmt->pbFormat))->dwBitRate = 100000;<BR> pStreamConfig->SetFormat(pmt);<BR> }<BR> DeleteMediaType(pmt);<BR><BR> // Request key frames every four frames.<BR> pStreamConfig->QueryInterface(IID_IAMVideoCompression, (void **)&pCompress);<BR> pCompress->put_KeyFrameRate(4);<BR> pCompress->Release();<BR> pStreamConfig->Release();<BR><BR> // Run the graph.<BR> IMediaControl *pControl = NULL;<BR> IMediaSeeking *pSeek = NULL;<BR> IMediaEvent *pEvent = NULL;<BR> pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);<BR> pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);<BR> <BR> HRESULT hr = pMux->QueryInterface(IID_IMediaSeeking, (void**)&pSeek);<BR><BR> pControl->Run();<BR> printf("Recompressing... \n");<BR><BR> long evCode;<BR> if (SUCCEEDED(hr)) // IMediaSeeking is supported<BR> {<BR> REFERENCE_TIME rtTotal, rtNow = 0;<BR> pSeek->GetDuration(&rtTotal);<BR> while ((pEvent->WaitForCompletion(1000, &evCode)) == E_ABORT)<BR> {<BR> pSeek->GetCurrentPosition(&rtNow);<BR> printf("%d%%\n", (rtNow * 100)/rtTotal);<BR> }<BR> pSeek->Release();<BR> }<BR> else // Cannot update the progress.<BR> {<BR> pEvent->WaitForCompletion(INFINITE, &evCode);<BR> }<BR> pControl->Stop();<BR> printf("All done\n"); <BR><BR> pSrc->Release();<BR> pMux->Release();<BR> pVComp->Release();<BR> pControl->Release();<BR> pEvent->Release();<BR> pBuild->Release();<BR> pGraph->Release();<BR> CoUninitialize();<BR>}<BR><BR> 真的需要你的帮助!谢谢你兄台!望快点回应!谢谢!<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:Creator 回复日期:2003-03-25 08:57:46
<br>内容:我看了一下,你的意图是要将avi经过压缩后重新生成avi文件,你一定是参考的Building the Recompression Graph 文章,但你没有完全理解其过程。请仔细参考SDK给出的FILTER GRAPH。实在没招,晚上给写你一个DEMO。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:jacky 回复日期:2003-03-25 10:28:47
<br>内容:非常感谢你的热心帮助!如果你能给我提供一个DEMO !那真的万分感谢了!<BR>我是想把一个普通的*.avi转为MPEG4的*.avi和*.mpg转为MPEG4的*.avi.<BR>而且把*.vob文件通过这种方式转为MPEG4的*.avi是否更难些啊!<BR> 再次谢谢你!急盼回音! <BR> 新手上路
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -