This is a sample python script to cut/trim a video file without decoding/re-encoding. Remember to save and run the script from the same directory,  where you have your video files, otherwise add an extra line to fetch the directory.

"""
Video Cutter
"""

# Import the following tools from moviepy library
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip

# Convert hour:minute:seconds to seconds only
start_hr = 0    # write starting hours, from where you want to start
start_mi = 17   # write starting minutes
start_sc = 0    # write starting seconds

# Total start time in seconds
start_time = (start_hr*3600) + (start_mi*60) + start_sc

end_hr = 1      # write ending hours, from where you want to start
end_mi = 34     # write ending minutes
end_sc = 2      # write ending seconds

# Total end time in seconds
end_time = (end_hr*3600) + (end_mi*60) + end_sc

# This is code to cut/trim the old file and save a new one.
ffmpeg_extract_subclip("old_file.mp4", start_time, end_time, targetname="new_file.mp4")

This python script is to join the multiple parts of a video.

"""
Video Joiner
"""

# Import the following tools from moviepy library
from moviepy.editor import VideoFileClip, concatenate_videoclips

# Add all the clips you want to join
video_1 = VideoFileClip("clip1.mp4")
video_2 = VideoFileClip("clip2.mp4")

# Take of the order of concatenation
final_video = concatenate_videoclips([video_1, video_2])
final_video.write_videofile("final_video.mp4")
Share: