Spaces:
Sleeping
Sleeping
Update video_processor.py
Browse files- video_processor.py +17 -9
video_processor.py
CHANGED
|
@@ -80,20 +80,28 @@ def create_video(video_script, audio_script, summary):
|
|
| 80 |
audio_clip = AudioFileClip(audio_path)
|
| 81 |
final_video = final_video.set_audio(audio_clip)
|
| 82 |
|
| 83 |
-
#
|
| 84 |
def create_subtitle(text):
|
| 85 |
-
return
|
| 86 |
-
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
-
subtitles = [create_subtitle(scene['voiceover'])
|
| 90 |
-
for scene in scenes]
|
| 91 |
subtitles = concatenate_videoclips(subtitles)
|
| 92 |
|
| 93 |
# Add watermark
|
| 94 |
-
watermark =
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
| 96 |
|
|
|
|
| 97 |
final_video = CompositeVideoClip([final_video, subtitles, watermark])
|
| 98 |
|
| 99 |
# Export
|
|
@@ -109,4 +117,4 @@ def create_video(video_script, audio_script, summary):
|
|
| 109 |
return output_path
|
| 110 |
|
| 111 |
except Exception as e:
|
| 112 |
-
raise Exception(f"Video creation failed: {str(e)}"
|
|
|
|
| 80 |
audio_clip = AudioFileClip(audio_path)
|
| 81 |
final_video = final_video.set_audio(audio_clip)
|
| 82 |
|
| 83 |
+
# Create subtitles
|
| 84 |
def create_subtitle(text):
|
| 85 |
+
return TextClip(
|
| 86 |
+
text,
|
| 87 |
+
fontsize=40,
|
| 88 |
+
color='white',
|
| 89 |
+
font='Arial-Bold',
|
| 90 |
+
stroke_color='black',
|
| 91 |
+
stroke_width=1
|
| 92 |
+
).set_position(('center', 'bottom')).set_duration(8)
|
| 93 |
|
| 94 |
+
subtitles = [create_subtitle(scene['voiceover']) for scene in scenes]
|
|
|
|
| 95 |
subtitles = concatenate_videoclips(subtitles)
|
| 96 |
|
| 97 |
# Add watermark
|
| 98 |
+
watermark = TextClip(
|
| 99 |
+
"MentorMindz",
|
| 100 |
+
fontsize=30,
|
| 101 |
+
color='white'
|
| 102 |
+
).set_position(('right', 'top')).set_duration(final_video.duration)
|
| 103 |
|
| 104 |
+
# Combine all elements
|
| 105 |
final_video = CompositeVideoClip([final_video, subtitles, watermark])
|
| 106 |
|
| 107 |
# Export
|
|
|
|
| 117 |
return output_path
|
| 118 |
|
| 119 |
except Exception as e:
|
| 120 |
+
raise Exception(f"Video creation failed: {str(e)}")
|