[FFmpeg-user] Reducing seek time when start time offset (-ss) is large
mbradshaw at sorensonmedia.com
Sat Aug 11 05:53:29 CEST 2012
On Fri, Aug 10, 2012 at 4:27 PM, Nicolas George
<nicolas.george at normalesup.org> wrote:
> Le quartidi 24 thermidor, an CCXX, Robert Krüger a écrit :
>> I suggested this:
>> on the ffmbc list for the exact same problem (if I understand your
>> posting correctly). Not a pretty solution but for use cases like yours
>> (and mine) it does the job. I was going to make a patch against ffmpeg
>> before posting this here but have not had time yet to do it but I'll
>> try to do that in the next few days. I hope this is at least going to
>> get a discussion about this started because I think this may be a
>> practical problem many people have.
> Let me recap, and correct me if I am wrong:
> -ss before -i uses seeking, and is inaccurate since it seeks only to
> keyframes; -ss after -i uses skipping and is very slow, you want a new
> option that does most of the work by seeking and then skips from the last
> keyframe until the target time.
> I do not think it is necessary.
> The thing is -ss seeks with the "backwards" flag: if there is no keyframe
> exactly at the requested time, it will look for a keyframe before it, not
> after. On the other hand, the timestamps are adjusted according to the
> target time, not the found keyframe, which means that timestamps will
> usually begin slightly negative.
I just want to point out a few things here: this is not entirely
correct. In FFmpeg, seeking actually may not be done by keyframe (even
if AVSEEK_FLAG_ANY is not set) (for example, mpg files don't seek by
keyframe). Also, the "backwards" flag is not always respected (again,
like with mpg files, it may seek to a non keyframe, but then stop
there (and not seek further back to the proper keyframe)).
There's actually some discussion regarding this here:
https://ffmpeg.org/trac/ffmpeg/ticket/1607 where I reported the bug,
but it doesn't look like it's close to being fixed.
More information about the ffmpeg-user