19

I'm trying to get the 10 last seconds of a video of which I dont know the length and then save those 10 seconds as a new video. Is this do able with the ffmpeg command prompt? And if so, how?

Thanks for the help

Greets

Gee
  • 337
  • 1
  • 2
  • 9

1 Answers1

43

Use the -sseof input option. From the documentation:

-sseof position (input)
Like the -ss option but relative to the "end of file". That is negative values are earlier in the file, 0 is at EOF.

Example:

ffmpeg -sseof -10 -i input.mp4 output.mp4

Note that in stream copy mode (by using the -c copy output option or equivalent) the cut will occur on the nearest keyframe, so it may cut on your exact desired time. If more accuracy is needed you will have to re-encode instead of stream copy.

llogan
  • 121,796
  • 28
  • 232
  • 243
  • 1
    Note, this only works if it can determine duration of the input. Fails when attempting to use it with -f concat :-( – ezwrighter Mar 20 '20 at 16:33
  • Why do I always get errors when trying to use `-sseof` as an output option, i.e. after all inputs? Is it possible to use it as an output option? – Hashim Aziz Nov 06 '21 at 19:26
  • 1
    @HashimAziz Because the documentation was incorrect. `-sseof` is only an input option. The documentation has since been fixed by Gyan. – llogan Nov 06 '21 at 19:30