[MPlayer-dev-eng] Precised/exact/to the frame seeking (-ss) in mencoder

Sam Wong sam at hellosam.net
Tue Apr 10 21:38:18 CEST 2007

What I want is -ss with precised seek point.

I know that this is a requested and love feature for many, including
me...And after some google work this question has been stayed around
since 2002 (and could be eariler). The cloest thing I can get is
-hr-edl-seek, which is very time consuming and inefficient if I just
want to cut something in the middle.

So I want to jump in to see if it's really that difficult to add...

After drilling the code for an hour or so...My initial idea is to hack
the edl_seek function. I am looking for input/comments to see if there
is any obvious errors / to correct my mis-understanding...because I am
really new to video coding thing, not to mention mplayer project itself.

My idea:
1. seek to the keyframe immediately or not so long (like within <10-20s)
before the desicred seek point. If -ss is possible this shouldn't be too
hard right?
2. start -hr-edl-seek style to drop the frame from that keyframe and
onwards, until the desired seekpoint.

let "seek_target" is the desired time point to be seeked...
0) let bisection_seek = seek_target
1) demux_seek(demuxer, bisection_seek, audio_delay, 1)
I believe the flag 1 will change the seek mode to absolute time instead
of relative time, am I correct?
2) video_read_frame(sh_video, &frame_data->frame_time,
&frame_data->start, force_fps);
In the code I often see the statement "sh_video->timer +=
frame_data->frame_time;", how ->timer is different from ->pts? And why
it's not updated in the video_read_frame function instead of updating
outside like that?
3) check if pts > seek_target, if yes, do bisection and repeat step 1.
The goal is to look for a keyframe immediately right before (or not long
before) the seek_target.
4) call slowseek(...) to finish the rest.

Does that look good?


More information about the MPlayer-dev-eng mailing list