Seeking accurately in ffmpeg

0

I'm trying to trim a video from a given initial point in time and a duration. However, after researching, it seems that ffmpeg's seek accuracy is not sufficient most of the times, unless the video stream is re-encoded.

  1. Is there an efficient way to seek accurately without re-encoding, on most files?
  2. It seems odd since Windows Media Player succeeds in this task most of the time.

What are they implementing differently?

Edit:

For example, given sample.mp4 5 seconds long:

  1. Working (with transcoding)

    ffmpeg -ss 00:00:03 -t 1 -i sample.mp4 -c:v libx264 -movflags +faststart -c:a aac -strict -2 -b:a 192k out.mp4
    
  2. Not working (without transcoding) - Will produce a video from the start of the file.

    ffmpeg -ss 00:00:03 -t 1 -i sample.mp4 -c:v copy -c:a copy out.mp4
    

ffmpeg version used: 2.8.4

Shlomi Uziel

Posted 2016-04-12T13:55:24.040

Reputation: 101

Question was closed 2019-04-27T10:47:32.880

Through practice, I've found that adding the seeking option after the input was in some cases more precise than using fast-seeking (before). It'll be much slower since the file has to be decoded up to your seek point, but try ffmpeg -i input.mp4 -ss xx:xx:xx instead of putting the -ss before the input. – Ely – 2016-04-12T19:24:13.443

Please see http://superuser.com/questions/458761/accurately-cut-video-files-from-command-line/458804#458804 — also, what exactly have you tried with ffmpeg? How did it fail? Which version did you use? (Ideally, show the command-line output.) If you could [edit] your post to include a more specific question, we can help you better. Note that WMP will likely re-encode the file, which makes accurate seeking easy.

– slhck – 2016-04-13T08:38:13.163

No answers