extracting subclips and connotation with ffmpeg

2018-06-05 08:25:49

I have a video of a speaker. In certain parts of the clip he isn't speaking. I'd like to be able to make subclips of him speaking and them append them all back together.

For MoviePy I've written the following code:

def moviepy_conectate(parent_video, output_video, *timestamp_list):

from moviepy.editor import VideoFileClip, concatenate_videoclips

timestamps = []

for t in timestamp_list:

if timestamps == []: timestamps.append([t])

elif len(timestamps[-1]) == 1: timestamps[-1].append(t)

elif len(timestamps[-1]) == 2: timestamps.append([t])

clip_list = []

for t in timestamps:

if len(t) == 2:

clip_list.append(VideoFileClip(parent_video).subclip(t[0], t[1]))

elif len(t) == 1:

clip_list.append(VideoFileClip(parent_video).subclip(t[0]))

concat_clip = concatenate_videoclips(clip_list)

concat_clip.write_videofile(output_video)

concat_clip.close()