[MPlayer-dev-eng] [PATCH] mencoder precised/exact seeking

Sam Wong sam at hellosam.net
Wed Apr 11 17:57:01 CEST 2007

Attached is the patch (against -r {2007-04-04}) to faciliate precisied
and exact seeking on video (with or without audio) stream. I didn't add
any new options, and -hr-edl-seek will make the mencoder using this new
code instead.

This patch makes EDL seeking, -ss change to use the new code when
-hr-edl-seek is enabled.

A executive summary of the patch:
1. Make edl_seek/slowseek to starts its work from the nearest keyframe,
instead of from the very beginning.
2. Make -ss use edl_seek. (Actually I introduced a seek_wrapper to
handle all seek.)

The working principle behind:
1) use demux_seek to seek to some point behind the desired target time
2) repeat in a bisection/binary search way to approach the seeking to
the target time (but not seek to the future), goal is to seek to the
keyframe (or I should say, any demux_seekable frame) right before the
target time.
3) start slowseek from that frame.

I am still actively testing it, and I think it's stable enough for me to
share. However, I never hack to mplayer code, so actually most of the
work are just copy-and-paste without understanding much. I suspect there
are some off-by-one-frame error inside, and I hope someone experienced
could take a look at it. I believe this is a really nice to have
feature, and requested by people from time to time, and should worth the
time to fine tune it. =)

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mencoder.seek.patch
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20070411/4434a2ec/attachment.asc>

More information about the MPlayer-dev-eng mailing list