Put the last X seconds of a video file into a new one
February 23, 2016

It is often useful to be able to seperate the last X number of seconds from a video file. This is how to do it from a linux terminal using ffmpeg:

END=$(ffprobe -i $FILENAME -show_format -v quiet | sed -n 's/duration=//p' | awk '{printf("%.0f\n", $1)}')
ffmpeg -i $FILENAME -ss 00:00:$START -t 00:00:$END -async 1 $NEWFILENAME

This would put the last 20 seconds of video.mp4 into a new file called videolastfewsecs.mp4, leaving the original file untouched.

Just change the first 3 varibles to change the settings.