ffmpeg – How to cut a video by time into two pieces losssless and fast?
I have input.mp4 of length 30 minutes.
I want to cut it at roughly 24:35, as losssless as possible, as fast as possible.
So, the first output is from 0 inclusive to 24:35 exclusive. The second output is from 24:35 inclusive to 30:00 exclusive.
I’m totally fine if the keyframe is at 24:30 or 24:40, as long as the merged video has no dropped frames and no duplicated frames.
I crafted this command lines.
ffmpeg -y -ss 0 -to 24:35 -i input.mp4 -c copy input-1.mp4
ffmpeg -y -ss 24:35 -i input.mp4 -c copy input-2.mp4
However, I’m not fond of it because I have to specify 24:35 twice. If I have more splitting points, the command lines will be lengthy and repetitive.
Also, I’m concerned about the length difference between the original video and the merged video.
$ ffprobe -i input.mp4 2>&1 | grep "Duration"
Duration: 00:29:40.18, start: 0.000000, bitrate: 10598 kb/s
$ ffprobe -i merge.mp4 2>&1 | grep "Duration"
Duration: 00:29:40.26, start: 0.000000, bitrate: 10603 kb/s
I know time seeking is inaccurate without re-encoding, but is the inaccuracy deterministic for -to and -ss?
Read more here: Source link
