[vlc-devel] anybody know how to get the frame number or movie clock in vlc

Rémi Denis-Courmont rdenis at simphalempin.com
Wed Aug 6 17:13:33 CEST 2008

Le mercredi 6 août 2008 07:02:13 zhou jerrifer, vous avez écrit :
> I'm a totally freshman to vlc. I just compiled a libvlc by cygwin and want
> to use it as a decoder.
> However, the problem is, I need the frame number or movie clock to tag a
> frame uniquely in my project.

That's the decoder's job to figure out. It creates/sends a new picture each 
times it decodes a new freame.

> While, in vlc, it seems you can just get the PTS or DTS time -- UTC time
> from 1970, which means, you'll get different time when you decode the same
> movie in different date. 

First, the VLC clock has an arbitrary zero. On most platforms, the time origin 
is _NOT_ the Unix epoch.

Second, the PTS and DTS origin are usually demuxer-specific. When reading from 
the same file, most demuxers will always re-create the _same_ PTS and DTS, 
typically starting at 0 for the beginning of file. This depends on the file 

> Furthermore, I ever think about to use the pts or dts time before the
> decoder in EsOutSend function. Unfortunately, sometimes, when I try to play
> DVD files or TS  files, both the pts and dts time in EsOutSend are 0.

They are zero when the demuxer cannot determine what they are. In that case, 
the codec has got to be able to compute the values from the previous blocks. 
For instance, RTP only conveys the PTS, but fails to provide the DTS, so 
there is no way that the RTP demuxer could know the DTS.

> So is there anyone can tell me how to get the frame number or movie
> clock in vlc?

The movie clock is easily available by querying the input time position. It is 
even printed by the UI...

Rémi Denis-Courmont

More information about the vlc-devel mailing list