How to measure the seeking time

From RidgeRun Developer Wiki

Introduction

Sometimes it is important to measure the time needed to seek to different points in a video file. In the following page, you can find how to do it using the gstperf element.


New gstreamer time event

We added a new event named GST_EVENT_CUSTOM_TIME used to tell the gstperf when the v4l2sink element is processing a valid buffer. Also, the v4l2sink has a new property to enable the support to send the time event to the pipeline. So, if this property (measure-time) is in true, the v4l2sink element sends the event to the pipeline every time that it receives and processes a new valid buffer.

Measure seeking time

The gstperf element has a property named measure-time. You can set it to true if you want to measure the seeking time. If this is the case, when the gstperf receives a seek event, it gets the current time and saves it. After this, when the gstperf changes to play state and receives the GST_EVENT_CUSTOM_TIME (this means that the v4l2sink receives a valid buffer after the seek event), it gets the current time again and calculates the time elapsed between the seek event and the time event.

You can use gstd to measure the seeking time. In the following example, we use gstd to measure the time needed to seek to 10s using a transport stream video and the tsdemux:

FILE=video.m2t

gst-client create "filesrc location= $FILE ! tsdemux name=mux mux. ! queue ! h264parse ! \
capsfilter caps=video/x-h264,stream-format=byte-stream,alignment=au,framerate=(fraction)60000/1001 ! \
omx_h264dec peer-alloc=false input-buffers=4 ! omx_hdeiscaler peer-alloc=false name=hd hd.src_00 ! \
gstperf measure-time=true ! v4l2sink device=/dev/video1 sync=true async=true enable-last-buffer=false measure-time=true"

gst-client -p 0 pause
gst-client -p 0 seek 10000
gst-client -p 0 play

One important thing is that you have to run gstd with gstperf debug:

GST_DEBUG_FILE=/dev/console GST_DEBUG=*perf*:4 /usr/bin/gstd --system &

You will see a debug message with the time elapsed:

0:02:09.668877703   529   0x141e60 DEBUG                   perf ../../src/omx/gstperf.c:83:gst_perf_handle_time_event:<perf2> Total time elapsed : 1.160599 s