moved the input file before the start time to improve precision
The behaviour of ffmpeg depends on the order of the command line arguments and I found that when trimming a clip the precision on the start time and duration is much improved when the input file is given as an argument before the start time and end time.
For example during my test the command:
ffmpeg -y -ss 1 -t 3 -i input.mp4 -strict -2 output.mp4
trim a clip with 4 seconds duration while the command:
ffmpeg -y -i input.mp4 -ss 1 -t 3 -strict -2 output.mp4
output a video with exactly 3 seconds duration.
Therefore I suggest this small change to the code or at least to give the option to reorder the arguments if needed.
@e-massa i think the time depends on the video itself,for some video ,all frame is key frame,so it can be very exactly,but others may be not ,so the best solution is to convert the video frames to all key frames,and then clip it .the word key frame may be not correct ,but i just mean it. you can try the following cmd to convert the video frame to all key frame.
//for older ffmpeg
ffmpeg -i INPUT -sameq -intra OUTPUT
//for new ffmpeg like 3.0+
ffmpeg -i output.mp4 -strict -2 -qscale 0 -intra keyoutput.mp4