|
|
|
@ -73,7 +73,7 @@ def make_final_video(
|
|
|
|
|
clip_start: float,
|
|
|
|
|
) -> 'AudioFileClip':
|
|
|
|
|
return (
|
|
|
|
|
AudioFileClip(f'assets/audio/{clip_title}.mp3')
|
|
|
|
|
AudioFileClip(f'assets/temp/mp3/{clip_title}.mp3')
|
|
|
|
|
.set_start(clip_start)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -90,32 +90,27 @@ def make_final_video(
|
|
|
|
|
audio_clips.append(audio_title)
|
|
|
|
|
indexes_for_videos = list()
|
|
|
|
|
|
|
|
|
|
for audio in track(
|
|
|
|
|
indexes_of_clips,
|
|
|
|
|
for idx, audio in track(
|
|
|
|
|
enumerate(indexes_of_clips),
|
|
|
|
|
description='Gathering audio clips...',
|
|
|
|
|
):
|
|
|
|
|
temp_audio_clip = create_audio_clip(
|
|
|
|
|
audio,
|
|
|
|
|
video_duration,
|
|
|
|
|
)
|
|
|
|
|
if video_duration + temp_audio_clip.duration > max_length:
|
|
|
|
|
continue
|
|
|
|
|
if video_duration + temp_audio_clip.duration <= max_length:
|
|
|
|
|
video_duration += temp_audio_clip.duration
|
|
|
|
|
audio_clips.append(temp_audio_clip)
|
|
|
|
|
indexes_for_videos.append(audio)
|
|
|
|
|
indexes_for_videos.append(idx)
|
|
|
|
|
|
|
|
|
|
for idx in indexes_of_clips:
|
|
|
|
|
audio_clips.append(AudioFileClip(f'assets/temp/mp3/{idx}.mp3'))
|
|
|
|
|
audio_composite = concatenate_audioclips(audio_clips)
|
|
|
|
|
|
|
|
|
|
console.log(f'[bold green] Video Will Be: {audio_composite.length} Seconds Long')
|
|
|
|
|
# add title to video
|
|
|
|
|
image_clips = list()
|
|
|
|
|
console.log(f'[bold green] Video Will Be: {video_duration} Seconds Long')
|
|
|
|
|
|
|
|
|
|
# Gather all images
|
|
|
|
|
new_opacity = 1 if opacity is None or float(opacity) >= 1 else float(opacity) # TODO move to pydentic and percents
|
|
|
|
|
|
|
|
|
|
def create_image_clip(
|
|
|
|
|
self,
|
|
|
|
|
image_title: str | int,
|
|
|
|
|
audio_start: float,
|
|
|
|
|
audio_end: float,
|
|
|
|
@ -123,30 +118,32 @@ def make_final_video(
|
|
|
|
|
) -> 'ImageClip':
|
|
|
|
|
return (
|
|
|
|
|
ImageClip(f'assets/temp/png/{image_title}.png')
|
|
|
|
|
.set_start(audio_start - self.time_before_tts)
|
|
|
|
|
.set_end(audio_end + self.time_before_tts)
|
|
|
|
|
.set_duration(self.time_before_tts * 2 + audio_duration, change_end=False)
|
|
|
|
|
.set_start(audio_start)
|
|
|
|
|
.set_end(audio_end)
|
|
|
|
|
.set_duration(audio_duration, change_end=False)
|
|
|
|
|
.set_opacity(new_opacity)
|
|
|
|
|
.resize(width=W - 100)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
index_offset = 1
|
|
|
|
|
# add title to video
|
|
|
|
|
image_clips = list()
|
|
|
|
|
|
|
|
|
|
image_clips.insert(
|
|
|
|
|
0,
|
|
|
|
|
ImageClip('assets/temp/png/title.png')
|
|
|
|
|
.set_duration(audio_clips[0].duration)
|
|
|
|
|
.resize(width=W - 100)
|
|
|
|
|
.set_opacity(new_opacity),
|
|
|
|
|
image_clips.append(
|
|
|
|
|
create_image_clip(
|
|
|
|
|
'title',
|
|
|
|
|
audio_clips[0].start,
|
|
|
|
|
audio_clips[0].end,
|
|
|
|
|
audio_clips[0].duration
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
for photo_idx in indexes_of_clips:
|
|
|
|
|
for photo_idx in indexes_for_videos:
|
|
|
|
|
image_clips.append(
|
|
|
|
|
create_image_clip(
|
|
|
|
|
f'comment_{photo_idx}',
|
|
|
|
|
audio_clips[photo_idx + index_offset].start,
|
|
|
|
|
audio_clips[photo_idx + index_offset].end,
|
|
|
|
|
audio_clips[photo_idx + index_offset].duration
|
|
|
|
|
audio_clips[photo_idx].start,
|
|
|
|
|
audio_clips[photo_idx].end,
|
|
|
|
|
audio_clips[photo_idx].duration
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -218,7 +215,7 @@ def make_final_video(
|
|
|
|
|
'assets/temp/temp_audio.mp4',
|
|
|
|
|
0,
|
|
|
|
|
video_duration,
|
|
|
|
|
targetname=f"results/{subreddit}/{filename}",
|
|
|
|
|
targetname=f'results/{subreddit}/{filename}',
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
print('debug duck')
|
|
|
|
|