proper intro addition
This commit is contained in:
parent
19abb65860
commit
38c220c7de
@ -1,5 +1,5 @@
|
||||
import moviepy.editor as mp
|
||||
from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
|
||||
|
||||
|
||||
def get_subclips(source_video_path, moments):
|
||||
vid = mp.VideoFileClip(source_video_path)
|
||||
@ -8,15 +8,17 @@ def get_subclips(source_video_path, moments):
|
||||
clips.append(vid.subclip(m.start, m.stop))
|
||||
return clips, vid
|
||||
|
||||
|
||||
def render_moments(moments, input_video_path, output_path, intro_path=None, outro_path=None, parallelism=1):
|
||||
clips, vid = get_subclips(input_video_path, moments)
|
||||
clips, _ = get_subclips(input_video_path, moments)
|
||||
if intro_path is not None:
|
||||
size = clips[0].size
|
||||
if intro_path is not None:
|
||||
iclip = mp.VideoFileClip(intro_path)
|
||||
clips.insert(0, iclip)
|
||||
composite = CompositeVideoClip(clips, size=size)
|
||||
composite.preview()
|
||||
composite.write_videofile(output_path, logger=None, threads=parallelism)
|
||||
iclip = mp.VideoFileClip(intro_path)
|
||||
iclip.resize(height=size[1])
|
||||
clips.insert(0, iclip)
|
||||
composite = mp.concatenate_videoclips(clips, method='compose')
|
||||
composite.write_videofile(output_path, logger=None, threads=parallelism)
|
||||
|
||||
|
||||
def filter_moments(moments, min_length, max_length):
|
||||
return [m for m in moments if m.get_duration() > min_length and m.get_duration() < max_length]
|
||||
|
Loading…
Reference in New Issue
Block a user