|
Hi everybody,
just asking how am i going to go through codec (h264)... i wanted to capture live video from web camera and transmits this data over the internet... how am i going to connect the codec (h264) for encoding and decoding live video frames...dont know what to do with the source code for codec (h264)...i mean connecting the codec to my main source code..? ... please help me....
thank you,
reno
|
|
|
|
|
This is really a vague question.
What part are you having trouble with?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
i am planning to use COM interfaces... i know the basic on graph editplus i can see that i can capture live video from my camera... by the way in graph edit plus i can generate code but dont know how to handle them in my code?
thanks for your immediate reply....
reno
|
|
|
|
|
So you're using DirectShow, right?
If so, is your h264 codec already in a directshow filter or do you need to
somehow get video frames from a DirectShow stream into the codec?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
So you're using DirectShow, right?
- yes, i am
If so, is your h264 codec already in a directshow filter or do you need to
somehow get video frames from a DirectShow stream into the codec?
- yes, i ned to get video frames from directshow stream into my codec, in the outcome my directshow diagram would be like this:
-->Analog Video in Capture>------>XvidMPEG4 CODEC>--->XvidMPEG4 decoder>----->Renderer
preview>------>Renderer 0001
(hope u can picture out the directshow graph i cannot copy and paste the diagram...or even attach it here...)
and the code for this is:
<code>
//Don't forget to change project settings:
//1. C++: add include path to DirectShow include folder (such as c:\dxsdk\include)
//2. Link: add link path to DirectShow lib folder (such as c:\dxsdk\lib).
//3. Link: add strmiids.lib and quartz.lib
#include "stdafx.h"
#include <DShow.h>
#include <atlbase.h>
#include <initguid.h>
BOOL hrcheck(HRESULT hr, TCHAR* errtext)
{
if (hr >= S_OK)
return FALSE;
TCHAR szErr[MAX_ERROR_TEXT_LEN];
DWORD res = AMGetErrorText(hr, szErr, MAX_ERROR_TEXT_LEN);
if (res)
printf("Error %x: %s\n%s\n",hr, errtext,szErr);
else
printf("Error %x: %s\n", hr, errtext);
return TRUE;
}
//change this macro to fit your style of error handling
#define CHECK_HR(hr, msg) if (hrcheck(hr, msg)) return hr;
CComPtr<IBaseFilter> CreateFilter(WCHAR* displayName)
{
IBindCtx *pBindCtx;
HRESULT hr = CreateBindCtx(0, &pBindCtx);
if (hrcheck(hr, "Can't create bind context"))
return NULL;
ULONG chEaten = 0;
IMoniker *pMoniker = 0;
hr = MkParseDisplayName(pBindCtx, displayName, &chEaten, &pMoniker);
pBindCtx->Release();
if (hrcheck(hr, "Can't create parse display name of the filter"))
return NULL;
IBaseFilter *pFilter = NULL;
if (SUCCEEDED(hr))
{
hr = pMoniker->BindToObject(pBindCtx, NULL, IID_IBaseFilter, (void**)&pFilter);
pMoniker->Release();
if (hrcheck(hr, "Can't bind moniker to filter object"))
return NULL;
}
return CComPtr<IBaseFilter>(pFilter);
}
// {B87BEB7B-8D29-423F-AE4D-6582C10175AC}
DEFINE_GUID(CLSID_VideoRenderer,
0xB87BEB7B, 0x8D29, 0x423F, 0xAE, 0x4D, 0x65, 0x82, 0xC1, 0x01, 0x75, 0xAC); //quartz.dll
// {17CCA71B-ECD7-11D0-B908-00A0C9223196}
DEFINE_GUID(CLSID_Conexant2388xVideoCapture,
0x17CCA71B, 0xECD7, 0x11D0, 0xB9, 0x08, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96); //ksproxy.ax
// {64697678-0000-0010-8000-00AA00389B71}
DEFINE_GUID(CLSID_XvidMPEG4VideoDecoder,
0x64697678, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71); //xvid.ax
HRESULT BuildGraph(IGraphBuilder *pGraph)
{
HRESULT hr = S_OK;
//graph builder
CComPtr<ICaptureGraphBuilder2> pBuilder;
hr = pBuilder.CoCreateInstance(CLSID_CaptureGraphBuilder2);
CHECK_HR(hr, "Can't create Capture Graph Builder");
hr = pBuilder->SetFiltergraph(pGraph);
CHECK_HR(hr, "Can't SetFiltergraph");
//add Video Renderer
CComPtr<IBaseFilter> pVideoRenderer;
hr = pVideoRenderer.CoCreateInstance(CLSID_VideoRenderer);
CHECK_HR(hr, "Can't create Video Renderer");
hr = pGraph->AddFilter(pVideoRenderer, L"Video Renderer");
CHECK_HR(hr, "Can't add Video Renderer to graph");
//add Conexant 2388x Video Capture
CComPtr<IBaseFilter> pConexant2388xVideoCapture;
hr = pConexant2388xVideoCapture.CoCreateInstance(CLSID_Conexant2388xVideoCapture);
CHECK_HR(hr, "Can't create Conexant 2388x Video Capture");
hr = pGraph->AddFilter(pConexant2388xVideoCapture, L"Conexant 2388x Video Capture");
CHECK_HR(hr, "Can't add Conexant 2388x Video Capture to graph");
//add Xvid MPEG-4 Video Decoder
CComPtr<IBaseFilter> pXvidMPEG4VideoDecoder;
hr = pXvidMPEG4VideoDecoder.CoCreateInstance(CLSID_XvidMPEG4VideoDecoder);
CHECK_HR(hr, "Can't create Xvid MPEG-4 Video Decoder");
hr = pGraph->AddFilter(pXvidMPEG4VideoDecoder, L"Xvid MPEG-4 Video Decoder");
CHECK_HR(hr, "Can't add Xvid MPEG-4 Video Decoder to graph");
//add Xvid MPEG-4 Codec
CComPtr<IBaseFilter> pXvidMPEG4Codec = CreateFilter(L"@device:cm:{33D9A760-90C8-11D0-BD43-00A0C911CE86}\\xvid");
hr = pGraph->AddFilter(pXvidMPEG4Codec, L"Xvid MPEG-4 Codec");
CHECK_HR(hr, "Can't add Xvid MPEG-4 Codec to graph");
//add Video Renderer
CComPtr<IBaseFilter> pVideoRenderer2;
hr = pVideoRenderer2.CoCreateInstance(CLSID_VideoRenderer);
CHECK_HR(hr, "Can't create Video Renderer");
hr = pGraph->AddFilter(pVideoRenderer2, L"Video Renderer");
CHECK_HR(hr, "Can't add Video Renderer to graph");
//connect Conexant 2388x Video Capture and Xvid MPEG-4 Video Decoder
hr = pBuilder->RenderStream(NULL, &MEDIATYPE_Video, pConexant2388xVideoCapture, NULL, pXvidMPEG4VideoDecoder);
CHECK_HR(hr, "Can't connect Conexant 2388x Video Capture and Xvid MPEG-4 Video Decoder");
//connect Conexant 2388x Video Capture and Xvid MPEG-4 Codec
hr = pBuilder->RenderStream(NULL, &MEDIATYPE_Video, pConexant2388xVideoCapture, NULL, pXvidMPEG4Codec);
CHECK_HR(hr, "Can't connect Conexant 2388x Video Capture and Xvid MPEG-4 Codec");
//connect Xvid MPEG-4 Video Decoder and Video Renderer
hr = pBuilder->RenderStream(NULL, &MEDIATYPE_Video, pXvidMPEG4VideoDecoder, NULL, pVideoRenderer);
CHECK_HR(hr, "Can't connect Xvid MPEG-4 Video Decoder and Video Renderer");
//connect Conexant 2388x Video Capture and Video Renderer
hr = pBuilder->RenderStream(NULL, &MEDIATYPE_Video, pConexant2388xVideoCapture, NULL, pVideoRenderer2);
CHECK_HR(hr, "Can't connect Conexant 2388x Video Capture and Video Renderer");
//connect Xvid MPEG-4 Codec and Xvid MPEG-4 Video Decoder
hr = pBuilder->RenderStream(NULL, &MEDIATYPE_Video, pXvidMPEG4Codec, NULL, pXvidMPEG4VideoDecoder);
CHECK_HR(hr, "Can't connect Xvid MPEG-4 Codec and Xvid MPEG-4 Video Decoder");
return S_OK;
}
int main(int argc, char* argv[])
{
CoInitialize(NULL);
CComPtr<IGraphBuilder> graph;
graph.CoCreateInstance(CLSID_FilterGraph);
printf("Building graph...\n");
HRESULT hr = BuildGraph(graph);
if (hr==S_OK) {
printf("Running");
CComQIPtr<IMediaControl, &IID_IMediaControl> mediaControl(graph);
hr = mediaControl->Run();
CHECK_HR(hr, "Can't run the graph");
CComQIPtr<IMediaEvent, &IID_IMediaEvent> mediaEvent(graph);
BOOL stop = FALSE;
while(!stop)
{
long ev=0, p1=0, p2=0;
Sleep(500);
printf(".");
if (mediaEvent->GetEvent(&ev, &p1, &p2, 0)==S_OK)
{
if (ev == EC_COMPLETE || ev == EC_USERABORT)
{
printf("Done!\n");
stop = TRUE;
}
else
if (ev == EC_ERRORABORT)
{
printf("An error occured: HRESULT=%x\n", p1);
mediaControl->Stop();
stop = TRUE;
}
mediaEvent->FreeEventParams(ev, p1, p2);
}
}
}
CoUninitialize();
return 0;
}
</code>
now, my problem is how am i going to put this into my code in order that this will make sense, even just display this two video on my screen before transmitting this to the medium. i try this already but it didnt display, isnt it that i didnt envoke the Release(); function call? or etc....?
please suggest me or help me on how toget through with this....
thank you...
reno
|
|
|
|
|
Who knows?
CChildView::CWnd
CChildView2::CWnd
CChildView m_wndView;
CChildView2 m_wndView2;
How to switch between them dynamically? Any way?
It's very important to my program.
Thanks a lot.
|
|
|
|
|
How to compute the angle(skew) of the image in vc++???
|
|
|
|
|
????
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Try:
useGoniometer(image, x_axis);
i.e. As it stands, your post is a bit meaningless.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
CPallini wrote: As it stands, your post is a bit meaningless.
actually, it's not. skew = "when you scanned that document, by how much was the paper rotated?"
|
|
|
|
|
You're guessing the image was a scanned document.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
the typical case is a scanned document. but image skew is a common term, and correcting image skew is a common problem.
|
|
|
|
|
I guess it's too late to answer, but here is a link:
http://www.codeproject.com/KB/graphics/deskewimg.aspx?artkw=deskew image
|
|
|
|
|
you'll need to find an image processing toolkit that can do a Hough Transform.
i don't know of any free ones, but i do know where you can find an inexpensive non-free one...
|
|
|
|
|
Hello,
How to initialize an unsigned char* ?
Prithaa
|
|
|
|
|
You mean something like that?
unsigned char* pTemp = NULL;
|
|
|
|
|
Hello,
I have to use unsigned char* in the following
int retcode = SQLConnect(hdbc1,"MyDSN", SQL_NTS,"sa",
SQL_NTS,"MyPassWord", SQL_NTS);
where the 2nd parameter is an unsigned char*
Now I want something like this
unsigned char* MyDSN = "MyDSN";
but the above definition gives error
so how should I initialize unsigned char*?
Prithaa
|
|
|
|
|
There is an exemple in the documentation[^] (your first reflex should be to open MSDN and read some information there).
If you look at the example, a cast is enough:
int retcode = SQLConnect(hdbc1,(SQLCHAR*)"MyDSN", SQL_NTS,(SQLCHAR*)"sa", <br />
SQL_NTS,(SQLCHAR*)"MyPassWord", SQL_NTS);<br />
|
|
|
|
|
Cedric Moonen wrote: There is an exemple in the documentation[^]
Isn't that hidden?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->ßRÅhmmÃ<-·´¯`·.
|
|
|
|
|
class A<br />
{<br />
int i;<br />
<br />
public :<br />
A()<br />
{<br />
i = 0;<br />
}<br />
~A()<br />
{<br />
i = 0;<br />
}<br />
};<br />
main()<br />
{<br />
A *obj = new A[0];<br />
if( obj != NULL )<br />
{<br />
delete[] obj;<br />
obj = NULL;<br />
}<br />
}<br />
Above code work well. But when I add virtual keyword to destructor of class then my program crashes.
class A<br />
{<br />
int i;<br />
<br />
public :<br />
A()<br />
{<br />
i = 0;<br />
}<br />
virtual ~A()<br />
{<br />
i = 0;<br />
}<br />
};<br />
main()<br />
{<br />
A *obj = new A[0];<br />
if( obj != NULL )<br />
{<br />
delete[] obj;
obj = NULL;<br />
}<br />
}
Why this crash occurs? If am I doing anything wrong? Or Is there any solution to avoid the crash?
Please help me.
|
|
|
|
|
I can't guess why do you need 0 instances of A , anyway your code executes fine both with and without virtual destructor, on my system (I'm using Visual Studio 2005).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
|
To add to the other replies:
you are allocating an array of zero elements. While this should not crash (but does in VC6 debug builds) it's also not very useful.
Either allocate a single element, using
A * obj = new A;
or allocate an aray of length len :
A * obj = new A[len];
note that in the first case you need to use delete<7code>, in the second, use <code>delete []
|
|
|
|
|
Hi all,
I have few functions which that the arguments are used by reference. Just like this,
<br />
void CDBRecorder::GetFixData(const CRfMessage &Msg, _RecordsetPtr &pRecSet)<br />
{<br />
unsigned __int32 des_list;<br />
unsigned __int32 mem_ID; <br />
unsigned char dm_con; <br />
unsigned char ser_ID; <br />
unsigned short act; <br />
<br />
des_list = Msg.GetDestinationList();<br />
pRecSet->Fields->GetItem("Destination List")->PutValue(des_list);<br />
<br />
mem_ID = Msg.GetSenderID();<br />
pRecSet->Fields->GetItem("Member ID")->PutValue(mem_ID);<br />
<br />
ser_ID = Msg.GetServiceID();<br />
pRecSet->Fields->GetItem("Service ID")->PutValue(ser_ID);<br />
<br />
act = Msg.GetActivityID();<br />
pRecSet->Fields->GetItem("Activity ID")->PutValue(act);<br />
}<br />
<br />
void CDBRecorder::GetMess(const CRfMessage &Msg, _RecordsetPtr &pRecSet)<br />
{<br />
long mLength;
BYTE * mBuffer = NULL;
<br />
mLength = Msg.GetDataLength();<br />
mBuffer = Msg.GetDataBuffer();<br />
<br />
_variant_t vtData;<br />
long nRetLength = 0;<br />
<br />
_variant_t vAppendChunck = BinaryToVariant((BYTE*)mBuffer, mLength, nRetLength);<br />
pRecSet->Fields->GetItem("Bio_Data")->AppendChunk(vAppendChunck);<br />
<br />
vtData.vt = VT_I2;<br />
vtData.iVal = (int)nRetLength;<br />
pRecSet->Fields->GetItem("Bio_Size")->PutValue(vtData);<br />
}<br />
I want to call these two functions inside another function. How can I do that. Where I'm stuck is that about main/parent functions' arguments. How should I use those arguments.
I appreciate your help all the time...
Eranga
|
|
|
|
|
First thing... After the time you are in Forum, you should know about PRE tags for code snippets, it is easier to read (and keep tabulations format).
About your question... One possibility is to call the parent function giving the parameters that are going to be used in the secondary functions. I mean:
void CalledFunction1 (XXX parA, XXX parB)
{
}
;
void CalledFunction2 (XXX parY, xxx parZ)
{
}
;
void ParentFunct (XXX par1, XXX par2, XXX par3, ... , XXX parN)
{
;
;
CalledFunction1 (par2, parN);
;
;
CalledFunction2 (par1, par3);
;
}
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|