How to keep record of the current frame when playing video?

Marcus Nascimento marcus.cps at gmail.com
Mon Nov 11 12:56:16 PST 2013


I'm working on a media platform and I have to implement a wrapper to
GStreamer that offers the following interface:

- SetStartTime: Set the start position (in time)
- SetEndTime: Set the end position (in time)
- SetStartFrame: Set the start position (in frames)
- SetEndFrame: Set the end position (in frames)
- SetStartSample: Set the start position (in samples)
- SetEndSample: Set the end position (in samples)
- AddTimeAlarm: A listener will be notified when a given time is reached.
- AddFrameAlarm: A listener will be notified when a given frame is reached.
- AddSampleAlarm: A listener will be notified when a given sample is
reached.

I'll never play streamming media nor remote media, but only local files.

The biggest problem up to now cames from the fact it is possible to set
Start/End position in time, and add frame alarms, for instance.

I'm using STEP events to set the start position. It is just a matter of
using gst_event_new_step passing the right parameters for that
(GST_FORMAT_TIME for time, GST_FORMAT_DEFAULT for samples and
GST_FORMAT_BUFFERS for frames).

In any case, I need to know which frame corresponds to the step destination.
To do that, I'm incrementing the frame counter everytime I receive a QOS
message durring the STEP execution. I do that until I receive a STEP_DONE
message. By that time, I know what is the current time and current frame.
It seems to work fine. Does anyone know if that is not correct?

After the STEP is complete, I'm using a pad probe (buffer probe) to keep
counting the frames.
This way, I can know for sure when a frame alarm has expired.

Strange thing is: When I set the StartFrame to 300, the corresponding time
is a little after 9s.
But, when I schedule an alarm to the same frame 300, the corresponding time
is around 7s.
It is very strange for me.

Can anyone help me understanding what's going on?

Thanks very much,
Marcus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20131111/12cf2277/attachment.html>


More information about the gstreamer-devel mailing list