From 33f78bf7aae1499fd0640b7ee579f1202d0e9ae6 Mon Sep 17 00:00:00 2001 From: emil314 <80203534+emil314@users.noreply.github.com> Date: Wed, 8 Jun 2022 16:29:10 +0200 Subject: [PATCH] Fixed background video choping issue Fixed issue #348 --- video_creation/background.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/video_creation/background.py b/video_creation/background.py index dce46bd..96ca399 100644 --- a/video_creation/background.py +++ b/video_creation/background.py @@ -6,7 +6,7 @@ from pathlib import Path from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip from moviepy.editor import VideoFileClip from utils.console import print_step, print_substep - +from moviepy.video.io.VideoFileClip import VideoFileClip def get_start_and_end_times(video_length, length_of_clip): @@ -42,10 +42,9 @@ def chop_background_video(video_length): background = VideoFileClip("assets/mp4/background.mp4") start_time, end_time = get_start_and_end_times(video_length, background.duration) - ffmpeg_extract_subclip( - "assets/mp4/background.mp4", - start_time, - end_time, - targetname="assets/mp4/clip.mp4", - ) + + with VideoFileClip("assets/mp4/background.mp4") as video: + new = video.subclip(start_time, end_time) + new.write_videofile("assets/mp4/clip.mp4") + print_substep("Background video chopped successfully!", style="bold green")