|
|
I am struggling to get this right. I have a application that creates it own audio and streams this along with some screen capture bitmaps. The audio streams fine, the video is always just black screen. I am obviously doing something wrong and have now tried changeing almost every header and parameter but no luck. I read the "streaming video images" article in the sdk and believe I am implementing the correct process. One thing that doesnt seem to work as documents is setting the input profile subtype as documented so based on other internet examples I am using the RGB32 subtype. Using the recommended input profile fails on writer->beginwriting with an "invalid path error"
For now I am using GDI screen capture which I believe is a 32 bit uncompressed rgb bitmap image
I have tried 3 times to post this question along with the src code extracts but the post dissapears after a short while for no reason.
Any one who can give me an example of the input profile and video sample header known to work plse help.
rgds
|
|
From: "Derekm"
[Quoted Text] > I read the "streaming video images" article in the sdk
I can find any article in the SDK docs with that title. You should post a link to the on-line docs.
> and believe I am implementing the correct process. One > thing that doesnt seem to work as documents is setting > the input profile subtype as documented so based on other > internet examples I am using the RGB32 subtype.
Are you configuring an image stream or a video stream? If the latter, are you trying to mux the RGB images or to have the writer compress them to WMV? What is your exact profile? What is your input WM_MEDIA_TYPE? If you are trying to mux RGB, have you told the write *not* to compress the images and are you setting the necessary clean-point flags? Are you setting the correct timestamps?
> Using the > recommended input profile fails on writer->beginwriting > with an "invalid path error"
That seems a totally unrelated error. What is the actual HRESULT in hex?
> For now I am using GDI screen capture which I believe is > a 32 bit uncompressed rgb bitmap image
GDI uses RGB. The bit-depth depends on the display settings.
-- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm
|
|
"Alessandro Angeli" wrote:
TKS for responding!!!
[Quoted Text] > From: "Derekm" > > > I read the "streaming video images" article in the sdk > > I can find any article in the SDK docs with that title. You > should post a link to the on-line docs.
Here is the link. I didnt qoute the heading correctly. It is "writing video image samples" http://msdn.microsoft.com/en-us/library/aa392242(VS.85).aspx
> > > and believe I am implementing the correct process. One > > thing that doesnt seem to work as documents is setting > > the input profile subtype as documented so based on other > > internet examples I am using the RGB32 subtype. > > Are you configuring an image stream or a video stream? If > the latter, are you trying to mux the RGB images or to have > the writer compress them to WMV? What is your exact profile? > What is your input WM_MEDIA_TYPE? If you are trying to mux > RGB, have you told the write *not* to compress the images > and are you setting the necessary clean-point flags? Are you > setting the correct timestamps? > I am trying to configure an image stream. I want to compress to wmv. This is the input profile:
VideoFmt.rcSource.left = 0; VideoFmt.rcSource.top = 0; int nScreenWidth = GetSystemMetrics(SM_CXSCREEN); int nScreenHeight = GetSystemMetrics(SM_CYSCREEN); VideoFmt.rcSource.bottom =nScreenHeight; VideoFmt.rcSource.right = nScreenWidth; VideoFmt.rcTarget = VideoFmt.rcSource; VideoFmt.dwBitRate=2048; //??? VideoFmt.dwBitErrorRate = 0; VideoFmt.AvgTimePerFrame = 0; VideoFmt.bmiHeader.biSize = sizeof( BITMAPINFOHEADER ); VideoFmt.bmiHeader.biWidth = nScreenWidth; VideoFmt.bmiHeader.biHeight = nScreenHeight; VideoFmt.bmiHeader.biPlanes = 1; VideoFmt.bmiHeader.biBitCount = 32; VideoFmt.bmiHeader.biCompression =0; VideoFmt.bmiHeader.biSizeImage = (nScreenWidth * nScreenHeight * 32)/8 ; VideoFmt.bmiHeader.biXPelsPerMeter = 0; VideoFmt.bmiHeader.biYPelsPerMeter = 0; VideoFmt.bmiHeader.biClrUsed = 0; VideoFmt.bmiHeader.biClrImportant = 0;
MediaFmt.majortype = WMMEDIATYPE_Video; MediaFmt.subtype = WMMEDIASUBTYPE_RGB32; MediaFmt.bFixedSizeSamples = pImageMediatype->bFixedSizeSamples; MediaFmt.bTemporalCompression = pImageMediatype->bTemporalCompression; MediaFmt.lSampleSize = pImageMediatype->lSampleSize; MediaFmt.formattype = WMFORMAT_VideoInfo; //pImageMediatype->formattype; MediaFmt.pUnk = pImageMediatype->pUnk; MediaFmt.cbFormat = sizeof( WMVIDEOINFOHEADER ); MediaFmt.pbFormat = (unsigned char *) &VideoFmt; result = ppInput->SetMediaType(&MediaFmt); result = ppWriter->SetInputProps(dwScrInputNumber, ppInput); ppInput->Release();
The stream profile is reconfigured using the WMMEDIASUBTYPE_WMVP subtype stream as follows:
ppProfile->GetStreamCount(&pcStreams);
for (i = 0;i < pcStreams;i++) {
result = ppProfile->GetStream(i,&ppConfig); result = ppConfig->QueryInterface(IID_IWMMediaProps, (void **) &pMediaProps); pMediaProps->GetMediaType(0,&pcbType); lpMedia = (char *) malloc(pcbType); pMediaProps->GetMediaType((WM_MEDIA_TYPE *) lpMedia,&pcbType); memcpy(&MediaFmt,lpMedia,sizeof(MediaFmt));
if (MediaFmt.majortype == WMMEDIATYPE_Audio) { dwAudioOutputNumber = i; pMediaProps->Release();
} else { dwScrOutputNumber = i; pImageMediatype = getcodec(); // // pImageMediatype->majortype = WMMEDIATYPE_Video; pImageMediatype->subtype = WMMEDIASUBTYPE_VIDEOIMAGE; result = pMediaProps->SetMediaType(&MediaFmt); result = ppProfile->ReconfigStream(ppConfig); pMediaProps->Release(); } }
result = ppWriter->SetProfile(ppProfile);
> > Using the > > recommended input profile fails on writer->beginwriting > > with an "invalid path error" >
This problem has been resolved - I was not setting the input and not the stream with WMMEDIASUBTYPE_VIDEOIMAGE subtype. For reference the error code was 80040205.
I NOW HAVE A NEW PROBLEM not even getting to begin writing samples. The ReconfigStream returns and error - C00D003C NS_E_INVALID_STREAM and I cant figure out why.
> That seems a totally unrelated error. What is the actual > HRESULT in hex? > > > For now I am using GDI screen capture which I believe is > > a 32 bit uncompressed rgb bitmap image > > GDI uses RGB. The bit-depth depends on the display settings.
Tks, I realised this after playing with my settings. I only have 256 colors, 16bit or 32 bit on my PC - so I am using 32.
> > > -- > // Alessandro Angeli > // MVP :: DirectShow / MediaFoundation > // mvpnews at riseoftheants dot com > // http://www.riseoftheants.com/mmx/faq.htm > > >
|
|
|
|
"Alessandro Angeli" wrote:
[Quoted Text] I do this in getcodec();
> > 2. for each codec, get its first format until you find a > codec with a subtype of WMMEDIASUBTYPE_WVP2 > > <http://msdn.microsoft.com/en-us/library/aa384772(VS.85).aspx> >
Do this too in getcodec().
> 3. enumerate the codec's formats, choosing the one you like > and fill in its media type (only the empty fields) >
This is where i think I stray...I just chose the first format.
hr = pCodecInfo->GetCodecInfoCount(WMMEDIATYPE_Video, &cCodecs);
DWORD dwCodecIndex;
// Loop through the video codecs. for(dwCodecIndex = 0; dwCodecIndex < cCodecs; dwCodecIndex++) { pCodecInfo->GetCodecFormat(WMMEDIATYPE_Video,dwCodecIndex,0, &pIStreamConfig); result = pIStreamConfig->QueryInterface(IID_IWMMediaProps, (void **) &pImediaprops ); result = pImediaprops->GetMediaType(0x00, &pcbType); pMediaType = (WM_MEDIA_TYPE*) new BYTE[pcbType]; result = pImediaprops->GetMediaType(pMediaType, &pcbType); if(pMediaType->subtype == WMMEDIASUBTYPE_WMVP ) return pMediaType; delete[] pMediaType; } return 0x00;
> 4. set the IWMStreamConfig's media type > > <http://msdn.microsoft.com/en-us/library/aa384565(VS.85).aspx> > <http://msdn.microsoft.com/en-us/library/aa391173(VS.85).aspx> >
I do this.
> 5. use the IWMStreamConfig to add a stream to the profile >
Dont do this exactly. I initially load a default profile with a windows media 9 audio and video stream setting , I assume that I can reconfigure the video stream and dont need to create a new one.
> 6. set the profile > > <http://msdn.microsoft.com/en-us/library/aa392211(VS.85).aspx> >
I do this in the code, after the stream is reconfigured. But at runtime the reconfigure is failing.
> 7. enumerate the writer's input formats corresponding to the > configured stream and select the one that matches your input > format > > <http://msdn.microsoft.com/en-us/library/aa392242(VS.85).aspx> >
I do this.
> 8. start writing >
I wish i was doing this succesfully!
Tks for the help. I have a few things to look at. It is 11:30 pm here now so I will try again tomorrow!
> -- > // Alessandro Angeli > // MVP :: DirectShow / MediaFoundation > // mvpnews at riseoftheants dot com > // http://www.riseoftheants.com/mmx/faq.htm > > > > >
|
|
From: "Derekm"
[...]
[Quoted Text] > Tks for the help. I have a few things to look at. > It is 11:30 pm here now so I will try again tomorrow!
Both the GenProfile and the UncompAVIToWMV samples in the SDK show how to create a profile.
-- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm
|
|
|