Big video often need clip to small one to transfer on internet. In this tutorial, we will introduce how to clip video to small one with a start time and end time, which is easy to used. You can learn how to clip by referring to our tutorial.
Install MoviePy
pip install moviepy
Import library
from moviepy.editor import VideoFileClip
Create a VideoFileClip object with video file
video = 'D:\\demo.mp4' clip = VideoFileClip(video)
Set start time and end time
start_time = '00:01:00' # one minute end_time = '00:05:00' # five minute
It means we will clip a big video from its 01:00 — 05:00, which means the new clip video duration is 4 minutes.
Clip video by start time and end time
newclip = clip.subclip(start_time,end_time) newclip.write_videofile("D:\\demo-small.mp4") newclip.close() clip.close()
The we will save the new small video to demo-small.mp4, the duration of which is 4 minutes.
Comparing the result.
Before:
After:
From the result, we will find the duration of small video is 4 minutes.