GNOME Bugzilla – Bug 674934
Snapping direction flags for seeking
Last modified: 2012-04-30 09:40:16 UTC
Created attachment 212947 [details] [review] Add the new seeking snap flags This is for 0.10 for now, it does not apply on master, I'll do it when a final form has been agreed. Two new flags added, GST_SEEK_FLAG_KEY_UNIT_SNAP_{FOR,BACK}WARD, which may be used to tell a seeking implementation which keyframe is preferred. Selecting both causes the nearest to be snapped to, selecting none leaves the decision to the demuxer. Comments welcome.
My 2¢: GST_SEEK_FLAG_KEY_UNIT = (1 << 2), GST_SEEK_FLAG_SNAP_BEFORE = (1 << 5), GST_SEEK_FLAG_SNAP_AFTER = (1 << 6), GST_SEEK_FLAG_SNAP_NEAREST = GST_SEEK_FLAG_SNAP_BEFORE | GST_SEEK_FLAG_SNAP_AFTER, KEY_UNIT = go to a keyframe, demuxer chooses which one SNAP_BEFORE = go to a location before the requested position, if KEY_UNIT this means the keyframe at or before the requested position SNAP_AFTER = go to a location after the requested position, if KEY_UNIT this means the keyframe at of after the requested position SNAP_NEAREST = go to a position near the requested position, if KEY_UNIT this means the keyframe closest to the requested position, if both keyframes are at an equal distance, behaves like SNAP_BEFORE BEFORE/AFTER always refers to the position in stream-time. BEFORE/AFTER, seems more natural than BACKWARDS/FORWARDS to express a position relative to the requested position. SNAP_* instead of SNAP_KEY_UNIT_* because the snapping might also make sense when not doing a keyframe seek (like going to the nearest frame boundary).
(In reply to comment #1) > BEFORE/AFTER always refers to the position in stream-time. That should be running-time, ie, the media that will be played BEFORE/AFTER the one at the requested position.
Created attachment 212967 [details] [review] updated seek flags patch with wim's comments Comments included. I'll also attach two patches (for avi and matroska) using these flags for keyframe seeks with an index.
Created attachment 212968 [details] [review] avi seeking with snap flags
Created attachment 212969 [details] [review] matroska seeking with snap flags
Looks good to me.
Pushed (0.10 and 0.11). commit 477636479cc0171a3a3fad4a5c17ac47e39cd7e6 Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk> Date: Mon Apr 30 09:58:09 2012 +0100 event: add new seek snap flags They can be used to select snapping behavior (to previous, next, or nearest location, where relevant) when seeking. The seeking implementation (eg, demuxer) may currently ignore some or all of these flags. commit cc242a656348fd0c5d7cbc2fc34de43aa3a33304 Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk> Date: Thu Apr 26 12:47:27 2012 +0100 matroska: implement forward snapping keyframe seeking Requires an index. commit 048b91b303b963920b9668e50065f16c62608506 Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk> Date: Thu Apr 26 12:46:11 2012 +0100 avi: implement forward snapping keyframe seeking In pull mode with an index.