ffmpeg: cut multiple input files with seeking to one output file
- by Josef Kufner
I have list of video files (loaded from database), each with start and end time of requested interval:
# file begin end
v1.mp4 1:01 2:01
v2.mp4 3:02 3:32
v3.mp4 2:03 5:23
And I need to create single video file containing these intervals:
[0:00]---v1---[2:00]---v2---[2:30]---v3---[5:50]
I preffer usig ffmpeg, since it is installed on server. Caller program is written in PHP.
It is easy to cut one input to one output (argument escaping removed for clarity):
exec("ffmpeg -ss $begin -i $input_file -ss $begin -c copy $output_file");
I there any easier way than executing ffmpeg for each interval and then execute it once more to concatenate prepared clips together? I really do not like to have a lot of temporary files or dealing with complex process handling.