How to convert between “double” timestamp from DirectShow sample grabber and FillBuffer REFERENCE_TIME?

The IMediaSample SetTime() function expects two REFERENCE_TIME parameters. REFERENCE_TIME is defined as type "LongLong" in Delphi 6, the programming language I am using for my DirectShow application. However, the first parameter of the Callback method that the DirectShow sample grabber filter uses to pass the sample time of a new media sample is cast as double. How do I convert between these two values so I can compare the sample time's between media sample's I receive from the sample grabber filter and the REFERENCE_TIME values that I generate in my push source filter's FillBuffer() method?

Also, would the sample time that is provided by the Sample Grabber filter in the callback method be considered the Start time of a media sample, or the End time?


Simple part: double is in seconds, and REFERENCE_TIME is in 100 ns units. Hence the conversion is simple: multiple or divide by 1E+7.

Not so simple one: you capture some time in grabber in one filter graph, and you time stamp data in your filter in another graph. Both graphs have time stamps to indicate streaming/presentation time, which is relative to graph "run time". That is, when media sample is passed between graphs, there might also a time stamp offset involved.

As for end time, with video media samples, sample stop time may be omitted or set equal to start time; with audio stop time is normally something you can compute by adding start time to time of payload data the buffer holds.

Bonus reading on MSDN: Time and Clocks in DirectShow

Need Your Help

why is there a margin introduced at the top as I move from iPhone startup image to same image as background on UIView?

iphone ios uiview uinavigationcontroller uiimageview

why is there a margin introduced as I move from iPhone startup image to same image as background on UIView?

What is the intended use of the DEFAULT section in config files used by ConfigParser?

python parsing configuration-files

I've used ConfigParser for quite a while for simple configs. One thing that's bugged me for a long time is the DEFAULT section. I'm not really sure what's an appropriate use. I've read the document...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.