Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Entertainment » microsoft.public.windowsmedia.sdk
Thread: How to get wmv file duration?

HTVi
TV Discussion Newsgroups

How to get wmv file duration?
Olivier Antoine 4/23/2007 8:08:03 AM
Hello,

I have got a stupid question : I am reading wmv files using the
IWMSyncReader interface of the WM 9 Format SDK, and I am not able to figure
how to get the wmv file duration (in number of frames, seconds,
100-nanoseconds or whatever, I will perform the conversion).

I saw there is an metadata attribute named 'Duration' but not all wmv files
seem to have this attribute set.

Thank you in advance,

Olivier

Re: How to get wmv file duration?
sasha <abc[ at ]fox.net> 4/23/2007 7:13:57 PM
Olivier Antoine wrote:
[Quoted Text]
> Hello,
>
> I have got a stupid question : I am reading wmv files using the
> IWMSyncReader interface of the WM 9 Format SDK, and I am not able to figure
> how to get the wmv file duration (in number of frames, seconds,
> 100-nanoseconds or whatever, I will perform the conversion).
>
> I saw there is an metadata attribute named 'Duration' but not all wmv files
> seem to have this attribute set.
>
> Thank you in advance,
>
> Olivier
>


Here is a sample code you can use:

C_ComPtr <IWMReader> _reader;
C_ComPtr <IWMHeaderInfo> _readerHeaderInfo;

hr = _reader->QueryInterface( IID_IWMHeaderInfo, (void
**)&_readerHeaderInfo );


WMT_ATTR_DATATYPE enumType;
WORD cbLength = sizeof( duration );
WORD stream = 0;
QWORD duration;

HRESULT hr = _readerHeaderInfo->GetAttributeByName( &stream,
g_wszWMDuration, &enumType,
(BYTE *)&duration, &cbLength );
if ( FAILED( hr ) ) {
LOG_ERR( _T( "Error getting reader attribures %x" ), hr );
return eSomeError;
}


Good luck,
..a
Re: How to get wmv file duration?
Olivier 4/25/2007 8:34:04 AM
Ok, thanks Sasha, my mistake was to get the 'Duration' attribute from the
video stream instead of taking it from the #0 stream. I do not know why one
have to read this attribute from an invalid stream index (I think stream #
are 1-based).

"sasha" wrote:

[Quoted Text]
> Olivier Antoine wrote:
> > Hello,
> >
> > I have got a stupid question : I am reading wmv files using the
> > IWMSyncReader interface of the WM 9 Format SDK, and I am not able to figure
> > how to get the wmv file duration (in number of frames, seconds,
> > 100-nanoseconds or whatever, I will perform the conversion).
> >
> > I saw there is an metadata attribute named 'Duration' but not all wmv files
> > seem to have this attribute set.
> >
> > Thank you in advance,
> >
> > Olivier
> >
>
>
> Here is a sample code you can use:
>
> C_ComPtr <IWMReader> _reader;
> C_ComPtr <IWMHeaderInfo> _readerHeaderInfo;
>
> hr = _reader->QueryInterface( IID_IWMHeaderInfo, (void
> **)&_readerHeaderInfo );
>
>
> WMT_ATTR_DATATYPE enumType;
> WORD cbLength = sizeof( duration );
> WORD stream = 0;
> QWORD duration;
>
> HRESULT hr = _readerHeaderInfo->GetAttributeByName( &stream,
> g_wszWMDuration, &enumType,
> (BYTE *)&duration, &cbLength );
> if ( FAILED( hr ) ) {
> LOG_ERR( _T( "Error getting reader attribures %x" ), hr );
> return eSomeError;
> }
>
>
> Good luck,
> ..a
>
Re: How to get wmv file duration?
"Alessandro Angeli" <nobody[ at ]nowhere.in.the.net> 4/25/2007 11:16:45 AM
From: "Olivier"

[Quoted Text]
> Ok, thanks Sasha, my mistake was to get the 'Duration'
> attribute from the video stream instead of taking it from
> the #0 stream. I do not know why one have to read this
> attribute from an invalid stream index (I think stream #
> are 1-based).

The documentation clearly states that you must use the
stream number 0 for global attributes, since they do not
belong to any stream. 0 means "for the file" while != 0
means "for this specific stream".


--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm



Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen