Update video2.py
Browse files
video2.py
CHANGED
|
@@ -267,24 +267,25 @@ from moviepy.editor import VideoFileClip, AudioFileClip
|
|
| 267 |
from moviepy.video.fx.speedx import speedx
|
| 268 |
|
| 269 |
# video.py
|
| 270 |
-
import os
|
| 271 |
-
import rust_highlight
|
| 272 |
-
|
| 273 |
-
CLIPS_DIR = os.path.join(os.environ.get('BASE_DIR', '/app/data'), 'clips') # Adjust as needed for Hugging Face Spaces
|
| 274 |
-
|
| 275 |
def video_func(id, lines, lang):
|
| 276 |
-
duration, audio_path = audio_func(id, lines, lang)
|
| 277 |
if not duration or not audio_path:
|
| 278 |
print("Failed to generate audio.")
|
| 279 |
return None
|
|
|
|
| 280 |
TEXT = lines[id]
|
| 281 |
print("-----------------------------------------------------------------------------")
|
| 282 |
print(TEXT)
|
| 283 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
final_video_path = rust_highlight.generate_video_clip(id, TEXT, audio_path, duration, CLIPS_DIR)
|
| 285 |
-
if final_video_path is None:
|
| 286 |
-
print("Failed to generate video.")
|
| 287 |
-
return None
|
| 288 |
|
| 289 |
-
|
| 290 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
from moviepy.video.fx.speedx import speedx
|
| 268 |
|
| 269 |
# video.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
def video_func(id, lines, lang):
|
| 271 |
+
duration, audio_path = audio_func(id, lines, lang)
|
| 272 |
if not duration or not audio_path:
|
| 273 |
print("Failed to generate audio.")
|
| 274 |
return None
|
| 275 |
+
|
| 276 |
TEXT = lines[id]
|
| 277 |
print("-----------------------------------------------------------------------------")
|
| 278 |
print(TEXT)
|
| 279 |
|
| 280 |
+
# CREATE CLIPS DIRECTORY IF IT DOESN'T EXIST
|
| 281 |
+
os.makedirs(CLIPS_DIR, exist_ok=True)
|
| 282 |
+
|
| 283 |
+
# Call Rust function
|
| 284 |
final_video_path = rust_highlight.generate_video_clip(id, TEXT, audio_path, duration, CLIPS_DIR)
|
|
|
|
|
|
|
|
|
|
| 285 |
|
| 286 |
+
if final_video_path:
|
| 287 |
+
print(f"Final video saved at: {final_video_path}")
|
| 288 |
+
return final_video_path
|
| 289 |
+
else:
|
| 290 |
+
print("Video generation failed.")
|
| 291 |
+
return None
|