ffmpeg: cut multiple input files with seeking to one output file

Posted by Josef Kufner on Programmers See other posts from Programmers or by Josef Kufner
Published on 2014-05-31T13:28:58Z Indexed on 2014/05/31 15:58 UTC
Read the original article Hit count: 282

Filed under:
|

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.

© Programmers or respective owner

Related posts about php

Related posts about video