[gst-devel] accuracy of seek event in MPEG1 video

Jeremy Gwinnup jgwinnup at mbvlab.wpafb.af.mil
Wed Nov 12 14:42:11 CET 2003


Hey all,

It's geen a while (Been busy with other tasks), but I've figured out how
to performing seeking in my application.

The question I have now is how to improve the accuracy of seek events. 
I require to seek to a given frame in my MPEG1 datafile, so I can
overlay a particular frame's metadata. 

These videos are 25 Mbit I frame MPEG1 encoded videos with a null audio
track, and are recorded at a 29.97 fps rate (dropframe video) Each frame
of the video is an I frame, which means we should be able to directly
seek to any given frame.

My pipeline looks like the following:

filesrc -> mpeg2dec -> "videosink"

On starting the application, I create an index on the pipeline (like the
indexing example in gstreamer/examples) to determine the length of the
clip (since querying total length in time on the decoder element returns
zero)

After the index is created, I reset the stream and allow the user to
start playback.

If the user slides the seek bar, I pause the pipeline and do the
following: (where offset is the new framenumber multiplied by the
time-per-frame constant, which is 33366666 for 29.97 frames/sec)
offset and result are gint64, and id is the index writer ID of the
decoder element

    entry = gst_index_get_assoc_entry (idx,
				       id,
				       GST_INDEX_LOOKUP_EXACT,
				       0,
				       GST_FORMAT_TIME,
				       offset);
    
    gst_index_entry_assoc_map (entry, GST_FORMAT_TIME, &result);
    

    event = gst_event_new_seek (GST_FORMAT_TIME | 
				GST_SEEK_METHOD_SET |
				GST_SEEK_FLAG_FLUSH |
				GST_SEEK_FLAG_ACCURATE |
				GST_SEEK_FLAG_KEY_UNIT, result);

    g_print("Think: %lld  Want: %lld\n", offset, result);
    
    g_print("Event accuracy: %lld\n", GST_EVENT_SEEK_ACCURACY(event));
    g_print("Event offset:   %lld\n", GST_EVENT_SEEK_OFFSET(event));

result and order wind up being equal (which is expected)

The event accuracy appears to be way off. Here is an example:

Seeking to 967
Think: 32265566022  Want: 32265566022
Event accuracy: 30064771072
Event offset:   32265566022

I expect accuracy to either be zero, or the amount of the offset.  Since
it's neither, the seek event goes to some portion of the video other
than where it should be. This causes discrepancies for my metadata
display, since that portion expects to be at frame 967, not somewhere
around frame 901.

So my big question is: How can I get the seek event accuracy higher? Do
I use a higher resolution GstClock? I am not worried about playback
speed, just playback accuracy.

Thanks for your help
-Jeremy


-- 
Jeremy Gwinnup
Software/Systems Engineer
General Dynamics Advanced Information Systems
phone: (937) 904-9023
fax:   (937) 656-7425
email: jgwinnup at mbvlab.wpafb.af.mil





More information about the gstreamer-devel mailing list