Discussion:
No video color
(too old to reply)
David
2009-06-17 14:53:01 UTC
Permalink
I have develop an application that takes live video streams and combines them
into one and writes the stream to a WMV file using IWMWriter. I create a
buffer large enough for all video streams to fit in. Periodically, 1 of the
videos will drop off (no video input) while the others will continue to
stream video. Or, at the start of a video stream, until the vdeo decompressor
gets enough data to out put the video the screen is initial green, pink or
gray. When one of these videos stop streaming I have logic to blank out that
portion of the video so that its section doesn’t look frozen.
I have found that filling the buffer with 0x00 the video area turns Green,
0xff turns it Pink and 0x80 turns it gray. I have played around with
different numbers, but it appears that these colors are the only colors
available. Is the previous statement true? Is there any way to make the video
area black?

I am using Windows Media Foundation 9.5 SDK.
IWMWriter interface to write a WMV file.
“Windows Media Video V7 “ using CBR mode

The WMV file being created works properly, I am just trying to control the
video color when no video is being streamed. That is, when video is no longer
being sent the area it is using on the buffer will be set to a hex value and
will remain set to this value until video returns. The only colors I have
been able to achieve is green, pink and gray. Is this color limited to these
colors?
--
Best Regards

"Failure is the opportunity to begin again more intelligently" – Henry Ford
David
2009-06-17 17:08:07 UTC
Permalink
It depends on the format of the uncompressed video you send
to the WMWriter's input. You should post the complete
WM_MEDIA_TYPE structure, including the format block.
nWidth = 640;
nHeight = 480;

DecHeader.bmiHeader.biSize = sizeof(DecHeader.bmiHeader);
DecHeader.bmiHeader.biWidth = nWidth;
DecHeader.bmiHeader.biHeight = nHeight;
DecHeader.bmiHeader.biPlanes = 1;
DecHeader.bmiHeader.biBitCount = 16;
DecHeader.bmiHeader.biCompression = mmioFOURCC('Y', 'U', 'Y', '2');
DecHeader.bmiHeader.biSizeImage = nWidth * nHeight;

ZeroMemory (&VidHeader, sizeof(VidHeader));
VidHeader.bmiHeader = DecHeader.bmiHeader;
MediaTypeOutput.majortype = MEDIATYPE_Video;
MediaTypeOutput.subtype = MEDIASUBTYPE_YUY2;
MediaTypeOutput.formattype = FORMAT_VideoInfo;
MediaTypeOutput.bFixedSizeSamples = TRUE;
MediaTypeOutput.bTemporalCompression = FALSE;
MediaTypeOutput.lSampleSize = nWidth * nHeight;
MediaTypeOutput.cbFormat = sizeof(VidHeader);
MediaTypeOutput.pbFormat = (BYTE*) &VidHeader;
MediaTypeOutput.pUnk = NULL;
--
Best Regards

"Failure is the opportunity to begin again more intelligently" – Henry Ford
Alessandro Angeli
2009-06-17 15:58:16 UTC
Permalink
From: "David"
Post by David
I have found that filling the buffer with 0x00 the video
area turns Green, 0xff turns it Pink and 0x80 turns it
gray. I have played around with different numbers, but it
appears that these colors are the only colors available.
Is the previous statement true? Is there any way to make
the video area black?
It depends on the format of the uncompressed video you send
to the WMWriter's input. You should post the complete
WM_MEDIA_TYPE structure, including the format block.
--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
David
2009-06-17 19:41:02 UTC
Permalink
It depends on the format of the uncompressed video you send
to the WMWriter's input. You should post the complete
WM_MEDIA_TYPE structure, including the format block.
I chose poorly earlier. This is correct information the video input for the
WMVWriter is looking for. What I posted before is the format the video is in
before it is passed to the WMVWriter instance. I just wasn't what was asked
for. Please forgive my confussion. :)


WM_MEDIA_TYPE* pType = NULL;
pProps->GetMediaType(NULL, &cbSize);
pType = (WM_MEDIA_TYPE*) new BYTE[cbSize];
pProps->GetMediaType(pType, &cbSize);

pType->majortype = {73646976-0000-0010-8000-00AA00389B71}
pType->subtype = {32595559-0000-0010-8000-00AA00389B71}
pType->bFixedSizeSamples = 1
pType->bTemporalCompression = 0
pType->lSampleSize = 614400
pType->formattype = {CLSID_WDM Streaming Capture VideoInfoHeader Data Type
Handler}
pType->pUnk = 0x00000000
pType->cbFormat = 88


BITMAPINFOHEADER* pFormatHeader = (BITMAPINFOHEADER*) pType->pbFormat;

pFormatHeader->biSize = 0
pFormatHeader->biWidth = 0
pFormatHeader->biWidth = 0
pFormatHeader->biWidth = 0
pFormatHeader->biWidth = 0
pFormatHeader->biWidth = 0
pFormatHeader->biWidth = 0
pFormatHeader->biXPelsPerMeter = 640
pFormatHeader->biYPelsPerMeter = 480
pFormatHeader->biClrUsed = 0
pFormatHeader->biClrImportant = 0
--
Best Regards

"Failure is the opportunity to begin again more intelligently" – Henry Ford
Alessandro Angeli
2009-06-17 20:03:20 UTC
Permalink
From: "David"
Post by David
It depends on the format of the uncompressed video you
send to the WMWriter's input. You should post the
complete WM_MEDIA_TYPE structure, including the format
block.
I chose poorly earlier. This is correct information the
video input for the WMVWriter is looking for. What I
posted before is the format the video is in before it is
passed to the WMVWriter instance. I just wasn't what was
asked for. Please forgive my confussion. :)
pType->subtype = {32595559-0000-0010-8000-00AA00389B71}
The subtype says YUY2, so it is the same format as the other
post.
Post by David
pFormatHeader->biSize = 0
pFormatHeader->biWidth = 0
pFormatHeader->biWidth = 0
pFormatHeader->biWidth = 0
pFormatHeader->biWidth = 0
pFormatHeader->biWidth = 0
pFormatHeader->biWidth = 0
pFormatHeader->biXPelsPerMeter = 640
pFormatHeader->biYPelsPerMeter = 480
pFormatHeader->biClrUsed = 0
pFormatHeader->biClrImportant = 0
This BIH looks weird :-)

Anyway, it doesn't matter. The following articles will
explain how to convert a black RGB value (0,0,0) into a
black YUV value and how YUY2 data is packed in memory:

http://msdn.microsoft.com/en-us/library/dd391027.aspx
http://msdn.microsoft.com/en-us/library/dd206750.aspx
http://msdn.microsoft.com/en-us/library/aa917087.aspx
http://msdn.microsoft.com/en-us/library/bb530104.aspx
--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm
Richard Russell
2009-06-19 16:43:47 UTC
Permalink
Post by David
I have found that filling the buffer with 0x00 the video area turns Green,
0xff turns it Pink and 0x80 turns it gray.
I'm guessing your buffer contains '2vuy' data (UYVYUYVY....). If
that's right, to get black you will need to fill the buffer with 80 10
80 10 80 10 ...... i.e. fill all 'even' addresses with 0x80 and all
'odd' addresses with 0x10. If that doesn't work try reversing them
(0x80 in the odd addresses, 0x10 in the even addresses).

Richard.
http://www.rtrussell.co.uk/
To reply by email change 'news' to my forename.

Loading...