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

Sebastian Dröge sebastian at centricular.com
Tue Nov 12 05:25:50 PST 2013


On Mo, 2013-11-11 at 18:56 -0200, Marcus Nascimento wrote:
> 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?

It would be useful to have some test case to explain what exactly you do
how and to have a way to reproduce it. Also which file formats are you
using and which GStreamer version on which platform? :)

How do you get "the corresponding time" when you do StartFrame(300)? And
how for the alarms? The alarms are counting the frames via a pad probe
and you get the buffer timestamp from there?

-- 
Sebastian Dröge <sebastian at centricular.com>
Centricular Ltd - http://www.centricular.com
Expertise, Straight from the Source
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 966 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20131112/9ee1fdc0/attachment.pgp>


More information about the gstreamer-devel mailing list