How to know if the stream is an Audio (wma) or Video (wmv) stream ?

How to know if the stream is an Audio (wma) or Video (wmv) stream ?

Post by David Scravaglie » Thu, 28 Nov 2002 19:54:29



I am using vmvcopy source code, I modified the code to get uncompressed
samples by passing FALSE to the method above:
hr = pReaderAdvanced->SetReceiveStreamSamples( wStreamNumber, FALSE);

So I get the samples in OnSample.
And there I need to know what type of sample I have Audio only (wma) or
AudioVideo (wmv).

 
 
 

How to know if the stream is an Audio (wma) or Video (wmv) stream ?

Post by Alex Zambelli [MS » Thu, 05 Dec 2002 13:43:52


A common way to do this is to check the width and height of the loaded
media. If those are greater than zero, then it is a video stream. However,
make sure you check this only AFTER you loaded the media, otherwise you
might end up trying to access properties of a nonexistant object.

--
Alex Zambelli [MS]
WMP Test Team
------------------------------
Please do not send e-mail directly to this alias. This address is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no
rights.
You assume all risk for your use.
WMP FAQ: http://www.nwlink.com/~zachd/pss/pss.html


Quote:> I am using vmvcopy source code, I modified the code to get uncompressed
> samples by passing FALSE to the method above:
> hr = pReaderAdvanced->SetReceiveStreamSamples( wStreamNumber, FALSE);

> So I get the samples in OnSample.
> And there I need to know what type of sample I have Audio only (wma) or
> AudioVideo (wmv).


 
 
 

How to know if the stream is an Audio (wma) or Video (wmv) stream ?

Post by Gary Zhou [M » Wed, 11 Dec 2002 04:48:56


Hi, David,

Thanks for using Windows Media Format SDK. By default, the SDK reader will
decompress samples for you so that you will get uncompressed samples from
IWMReader::OnSample(). If you need to receive compressed samples, you then
need to call IWMReaderAdvanced::SetReceiveStreamSamples( wStreamNum, TRUE )
and you also need to implement IWMReaderCallbackAdvanced interface.

Now assume you would like to get uncompressed samples from the SDK reader.
After you open the file, you can use IWMReader::GetOutputCount() along with
IWMReader::GetOutputProps() to enumerate the outputs and their properties.
For IWMReader::GetOutputProps() call, you will get an IWMOutputMediaProps()
pointer, which inherits from IWMMediaProps. Then you can call
IWMMediaProps::GetType() or IWMMediaProps::GetMediaType() to check the
media type (audio, video, etc) for that output. You can keep this info in
some data structure. Then in IWMReader::OnSample() call, the first
parameter is dwOutputNum, from which you can tell the media type from your
data structure mentioned above.

For details, please see Windows Media Format SDK help documention
"Programming Guide" section.

Hope this helps,

Gary Zhou

============================================================================
This posting is provided "AS IS" with no warranties, and confers no rights.