0

I'm looking for a way to remove some frames of video or cut some sequences of video clips and then concatenate them. Is there any way to do so in Moviepy?

I know one possible solution is to compute the duration of each frame based on the fps of the video and use it as a time unit in the subclip method of the VideoFileClip object, but it's not too accurate and there are some situations that the result is not correct.

clip = VideoFileClip('sample.mp4')
fps = clip.fps
frame_duration = 1 / fps
# subclip from second frame to fifth frame
clip.subclip(t_start=2*frame_duration, t_end=5*frame_duration)
  • 1
    Here's how moviepy converts the time you give it into a frame number: https://github.com/Zulko/moviepy/blob/db19920764b5cb1d8aa6863019544fd8ae0d3cce/moviepy/video/io/ffmpeg_reader.py#L169 Some testing finds it's consistently one frame too high. – Nick ODell Aug 09 '22 at 17:48
  • thanks @NickODell, you're right. I think it could be ok if in the worst case a frame is missed. but I still wonder why moviepy doesn't have such a subclip method to do this on the sequence of frames rather than time intervals. do you have any idea? – AmirMohammad Babaei Aug 13 '22 at 12:15
  • I also came across the same issue. The number of frames is correct but each video is about 0.02 seconds longer. There doesn't seem to be a bug lugged for this?! – uwe Apr 20 '23 at 23:51
  • Did you check the frame rate? I'm not sure Maybe it has been changed. – AmirMohammad Babaei Apr 25 '23 at 12:07

0 Answers0