Use the -sseof . From the doc:
-sseof position (input / output)
Like the -ss , but relative to the "end of file". These are negative values โโpreviously in the file, 0 in EOF.
Example:
ffmpeg -sseof -10 -i input.mp4 output.mp4
Please note that in stream copy mode (using -c copy or equivalent), the cut will be performed on the nearest keyframe, so it can be cut to your exact time. If more accuracy is required, you will have to transcode rather than copy the stream.
source share