|
I'm tring to save video in WMV format.
Adding this code
IFileSinkFilter *pSink = NULL;
IBaseFilter *pMux = NULL;
hr = m_pCaptureMoniker->SetOutputFileName(&MEDIASUBTYPE_Avi,L"C:\\Example.avi",&pMux,&pSink);
hr = m_pCaptureMoniker->RenderStream (&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,pBaseFilter, NULL, pMux);
video stream is saved in Avi file, changing SetOutputFileName arguments in (&MEDIASUBTYPE_Asf,L"C:\\Example.wmv",&pAsfWriter,NULL);
the graph couldn't run
Please, could someone explain me why, or give me a way to save video to WMV file or better MPG file?
thanks
|
|
|
|
|
The easiest way to build this graph is by specifing MEDIASUBTYPE_Asf in the ICaptureGraphBuilder2::SetOutputFileName method:
IBaseFilter* pASFWriter = 0;
hr = pBuild->SetOutputFileName(
&MEDIASUBTYPE_Asf, // Create a Windows Media file.
L"C:\\VidCap.wmv", // File name.
&pASFWriter, // Receives a pointer to the filter.
NULL); // Receives an IFileSinkFilter interface pointer (optional).
The value MEDIASUBTYPE_Asf tells the Capture Graph Builder to use the WM ASF Writer filter as the file sink. The Capture Graph Builder creates the filter, adds it to the graph, and calls IFileSinkFilter::SetFileName to set the name of the output file. It returns a pointer to the filter as an outgoing parameter (pASFWriter in the previous example).
Use the IConfigAsfWriter interface on the WM ASF Writer to set the Windows Media profile. You must do this before you connect any pins on the WM ASF Writer.
IConfigAsfWriter *pConfig = 0;
hr = pASFWriter->QueryInterface(IID_IConfigAsfWriter, (void**)&pConfig);
if (SUCCEEDED(hr))
{
// Configure the ASF Writer filter.
pConfig->Release();
}
For more information about setting the profile, see Creating ASF Files in DirectShow.
Call ICaptureGraphBuilder2::RenderStream to connect the capture filter to the ASF Writer:
hr = pBuild->RenderStream(
&PIN_CATEGORY_CAPTURE, // Capture pin.
&MEDIATYPE_Video, // Video. Use MEDIATYPE_Audio for audio.
pCap, // Pointer to the capture filter.
0,
pASFWriter); // Pointer to the sink filter (ASF Writer).
Each input pin on the WM ASF Writer filter corresponds to a stream in the Windows Media profile. You must connect every pin, so that the file content matches the profile.
|
|
|
|
|
could any one copy and paste the code for dshow.h here or attach it to me
|
|
|
|
|
You find it in \DXSDK\Include
|
|
|
|
|
Hi, I Want to capture live video with dimension 720x576, thanks.
|
|
|
|
|
Hi,
I have a little problem!!!
When i build this API with MVS++ 6.0, it can't find all the file.h (afxres.h, ect...)!!!
It work if i give the good way (c:\fjhfv\csdhbvj.....)!!
Can you help me thanks!!
Cyril
|
|
|
|
|
subject says it all....Basically I tried to complie the project but it says it can't find dshow.h
Any help?
|
|
|
|
|
"You need to install DirectX, which is available freely from Microsoft. You can download DirectX 9.0 from Microsoft.
For development, install DirectX 9.0 SDK. You can download DirectX 9.0 SDK from Microsoft. "
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Also be aware that DirectShow has been removed from the latest update to DirectX (April 2005) and is now part of the Platform SDK.
You can get it by downloading the Microsoft® Windows Server 2003 SP1 Platform SDK - April 2005 Edition if you are not using an earlier version of DirectX. If you use the web installation package you can just download the DirectShow elements of the SDK.
Cheers,
Jason.
Melbourne. Australia.
modified 10-Jul-19 21:02pm.
|
|
|
|
|
thanks guys I never would have known... all these things.
|
|
|
|
|
|
Hi, it is possible to capture video from different sources at the same time using only one capture card?
Excellent
|
|
|
|
|
Does anyone know how I could modify the CCaptureVideo class to call a callback function when each frame of video is grabbed, and if so how would it be done? This would be useful for me as I’m writing an application to grab and buffer images for storage rather than display live images. I could use the callback function to trigger image storage code when each new frame of video arrives.
Nice code btw. CPU sits idle grabbing live video.
Cheers,
Matt.
|
|
|
|
|
Hi palm,
I got your source codes for live video and when I tryed to compile it .. I got the following messages:
--------------------Configuration: LiveVideo - Win32 Debug--------------------
Compiling...
CaptureVideo.cpp
c:\arquivos de programas\microsoft directx 9.0 sdk (december 2004)\include\strmif.h(1024) : error C2146: syntax error : missing ';' before identifier 'HSEMAPHORE'
c:\arquivos de programas\microsoft directx 9.0 sdk (december 2004)\include\strmif.h(1024) : fatal error C1004: unexpected end of file found
LiveVideo.cpp
c:\arquivos de programas\microsoft directx 9.0 sdk (december 2004)\include\strmif.h(1024) : error C2146: syntax error : missing ';' before identifier 'HSEMAPHORE'
c:\arquivos de programas\microsoft directx 9.0 sdk (december 2004)\include\strmif.h(1024) : fatal error C1004: unexpected end of file found
LiveVideoDlg.cpp
c:\arquivos de programas\microsoft directx 9.0 sdk (december 2004)\include\strmif.h(1024) : error C2146: syntax error : missing ';' before identifier 'HSEMAPHORE'
c:\arquivos de programas\microsoft directx 9.0 sdk (december 2004)\include\strmif.h(1024) : fatal error C1004: unexpected end of file found
Generating Code...
Error executing cl.exe.
LiveVideo.exe - 6 error(s), 0 warning(s)
I wonder if you could help me out with that couse i don't understando what's going on.
thank you... by the way great work on the code ...
Marcus Augustus
|
|
|
|
|
I have same errors....
|
|
|
|
|
I have same problems.Did you solve this problem, plesa give information about this problem.
shayirli@yahoo.com
Sezgin
Shayirli
|
|
|
|
|
Please somebody that has the error i have the same error and i dont know how can i do it?
please give us the solution ???
my email is santano@hotmail.com
i dont care of the trobble
|
|
|
|
|
It will be terrible, I replace functions
e.g.
// ICaptureGraphBuilder2* m_pCapture ;
ICaptureGraphBuilder* m_pCapture ;
and
// hr = CoCreateInstance (CLSID_CaptureGraphBuilder2 , NULL, CLSCTX_INPROC,
// IID_ICaptureGraphBuilder2, (void **) &m_pCapture);
hr = CoCreateInstance (CLSID_CaptureGraphBuilder , NULL, CLSCTX_INPROC,
IID_ICaptureGraphBuilder, (void **) &m_pCapture);
// hr = CoCreateInstance (CLSID_CaptureGraphBuilder2 , NULL, CLSCTX_INPROC,
// IID_ICaptureGraphBuilder2, (void **) &m_pCaptureMoniker);
hr = CoCreateInstance (CLSID_CaptureGraphBuilder , NULL, CLSCTX_INPROC,
IID_ICaptureGraphBuilder, (void **) &m_pCaptureMoniker);
// hr = m_pCaptureMoniker->RenderStream (&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
// pBaseFilter, NULL, NULL);
hr = m_pCaptureMoniker->RenderStream (&PIN_CATEGORY_PREVIEW,
pBaseFilter, NULL, NULL);
// hr = m_pCapture->FindInterface(&PIN_CATEGORY_CAPTURE,
// &MEDIATYPE_Interleaved, pSrcF,
// IID_IAMCrossbar, (void **)&pX);
hr = m_pCapture->FindInterface(&PIN_CATEGORY_CAPTURE,
pSrcF,
IID_IAMCrossbar, (void **)&pX);
// if(hr != NOERROR)
// hr = m_pCapture->FindInterface(&PIN_CATEGORY_CAPTURE,
// &MEDIATYPE_Video, pSrcF,
// IID_IAMCrossbar, (void **)&pX);
if(hr != NOERROR)
hr = m_pCapture->FindInterface(&PIN_CATEGORY_CAPTURE,
pSrcF,
IID_IAMCrossbar, (void **)&pX);
/*
hr = m_pCapture->FindInterface(&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Interleaved, pSrcF,
IID_IAMCrossbar, (void **)&pX);
if(hr != NOERROR)
hr = m_pCapture->FindInterface(&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video, pSrcF,
IID_IAMCrossbar, (void **)&pX);
*/
hr = m_pCapture->FindInterface(&PIN_CATEGORY_CAPTURE,
pSrcF,
IID_IAMCrossbar, (void **)&pX);
if(hr != NOERROR)
hr = m_pCapture->FindInterface(&PIN_CATEGORY_CAPTURE,
pSrcF,
IID_IAMCrossbar, (void **)&pX);
Delete
// wsprintfW(wsz, L"FilterGraph %08x pid %08x\0", (DWORD_PTR)pUnkGraph,
// GetCurrentProcessId());
// _vsntprintf(szBuffer, NUMCHARS - 1, szFormat, pArgs);
// va_end(pArgs);
Dillian
|
|
|
|
|
I have the same errors as well.
Does anyone now why?
|
|
|
|
|
ME too!!! some one plz send what to do?????????
|
|
|
|
|
You must have an older version of SDK
Only those that were published before Summer 2004 work with VisualC++6.
Download the right one on the Microsoft Site , by looking for " Directx SDK"
|
|
|
|
|
Nice peace of code.
Would it be possible to easily stream the video content to file? Like an AVI or MPEG file for example?
Sorry not up on DirectX things!
Cheers
--
The Obliterator
|
|
|
|
|
Generally, yes, but not in this example. You might have to look out for custom DirectShow filters, if you want streaming into MPEG format, but that's up one's toes with DirectShow
C++ libraries at a give-away price on www.neatcpp.com: TWAIN, DirectShow, Interprocess Communications, etc...
|
|
|
|
|
The work is excellent. But how to get the video send to other network.
Waiting for your reply soon. I want to create the live video conference.
|
|
|
|
|
Hi , I just downloaded the code but there is no demo (exe file ) there .Actually I am new to directx and when i downloaded the source code , and tried to build it , i got the following errors :
Deleting intermediate files and output files for project 'LiveVideo - Win32 Debug'.
--------------------Configuration: LiveVideo - Win32 Debug--------------------
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
CaptureVideo.cpp
c:\bala\livevideo_demo\capturevideo.h(114) : error C2143: syntax error : missing ';' before '*'
c:\bala\livevideo_demo\capturevideo.h(114) : error C2501: 'ICaptureGraphBuilder2' : missing storage-class or type specifiers
c:\bala\livevideo_demo\capturevideo.h(114) : error C2501: 'm_pCapture' : missing storage-class or type specifiers
c:\bala\livevideo_demo\capturevideo.h(122) : error C2143: syntax error : missing ';' before '*'
c:\bala\livevideo_demo\capturevideo.h(122) : error C2501: 'ICaptureGraphBuilder2' : missing storage-class or type specifiers
c:\bala\livevideo_demo\capturevideo.h(122) : error C2501: 'm_pCaptureMoniker' : missing storage-class or type specifiers
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(33) : error C2065: 'm_pCapture' : undeclared identifier
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(40) : error C2065: 'm_pCaptureMoniker' : undeclared identifier
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(104) : error C2065: 'CLSID_CaptureGraphBuilder2' : undeclared identifier
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(105) : error C2065: 'IID_ICaptureGraphBuilder2' : undeclared identifier
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(315) : error C2065: 'LONG_PTR' : undeclared identifier
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(315) : error C2059: syntax error : ')'
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(316) : error C2143: syntax error : missing ';' before '{'
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(342) : error C2227: left of '->SetFiltergraph' must point to class/struct/union
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(381) : error C2227: left of '->RenderStream' must point to class/struct/union
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(442) : error C2065: 'wsprintfW_instead_use_StringCbPrintfW_or_StringCchPrintfW' : undeclared identifier
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(442) : error C2065: 'DWORD_PTR' : undeclared identifier
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(442) : error C2146: syntax error : missing ')' before identifier 'pUnkGraph'
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(443) : error C2059: syntax error : ')'
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(509) : error C2227: left of '->Release' must point to class/struct/union
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(538) : error C2227: left of '->Release' must point to class/struct/union
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(713) : error C2227: left of '->SetFiltergraph' must point to class/struct/union
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(721) : error C2227: left of '->RenderStream' must point to class/struct/union
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(862) : error C2059: syntax error : ')'
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(863) : error C2143: syntax error : missing ';' before '{'
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(868) : error C2065: 'EC_DEVICE_LOST' : undeclared identifier
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(868) : error C2051: case expression not constant
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(920) : error C2146: syntax error : missing ')' before identifier 'pUnkGraph'
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(921) : error C2059: syntax error : ')'
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(964) : error C2065: '_vsntprintf_instead_use_StringCbVPrintf_or_StringCchVPrintf' : undeclared identifier
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(1001) : error C2227: left of '->FindInterface' must point to class/struct/union
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(1005) : error C2227: left of '->FindInterface' must point to class/struct/union
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(1067) : error C2227: left of '->FindInterface' must point to class/struct/union
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(1071) : error C2227: left of '->FindInterface' must point to class/struct/union
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(1145) : error C2227: left of '->FindInterface' must point to class/struct/union
C:\Bala\LiveVideo_demo\CaptureVideo.cpp(1149) : error C2227: left of '->FindInterface' must point to class/struct/union
LiveVideo.cpp
c:\bala\livevideo_demo\capturevideo.h(114) : error C2143: syntax error : missing ';' before '*'
c:\bala\livevideo_demo\capturevideo.h(114) : error C2501: 'ICaptureGraphBuilder2' : missing storage-class or type specifiers
c:\bala\livevideo_demo\capturevideo.h(114) : error C2501: 'm_pCapture' : missing storage-class or type specifiers
c:\bala\livevideo_demo\capturevideo.h(122) : error C2143: syntax error : missing ';' before '*'
c:\bala\livevideo_demo\capturevideo.h(122) : error C2501: 'ICaptureGraphBuilder2' : missing storage-class or type specifiers
c:\bala\livevideo_demo\capturevideo.h(122) : error C2501: 'm_pCaptureMoniker' : missing storage-class or type specifiers
LiveVideoDlg.cpp
c:\bala\livevideo_demo\capturevideo.h(114) : error C2143: syntax error : missing ';' before '*'
c:\bala\livevideo_demo\capturevideo.h(114) : error C2501: 'ICaptureGraphBuilder2' : missing storage-class or type specifiers
c:\bala\livevideo_demo\capturevideo.h(114) : error C2501: 'm_pCapture' : missing storage-class or type specifiers
c:\bala\livevideo_demo\capturevideo.h(122) : error C2143: syntax error : missing ';' before '*'
c:\bala\livevideo_demo\capturevideo.h(122) : error C2501: 'ICaptureGraphBuilder2' : missing storage-class or type specifiers
c:\bala\livevideo_demo\capturevideo.h(122) : error C2501: 'm_pCaptureMoniker' : missing storage-class or type specifiers
Generating Code...
Error executing cl.exe.
LiveVideo.exe - 48 error(s), 0 warning(s)
I ahve installed DirectX9 SDK as well as I have Visual Studio 6.0 but as soon as I build it , these errors come up .
Could you guide me as to how to rectify these errors ?
Regards ,
Joshilay
|
|
|
|
|