Update videogenerator.py
Browse files- videogenerator.py +19 -18
videogenerator.py
CHANGED
|
@@ -154,25 +154,26 @@ class VideoGenerator:
|
|
| 154 |
raise
|
| 155 |
return out_path
|
| 156 |
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
|
|
|
|
|
|
| 174 |
|
| 175 |
-
return out_path
|
| 176 |
|
| 177 |
|
| 178 |
# ---------------- Enhancement Modules ----------------
|
|
|
|
| 154 |
raise
|
| 155 |
return out_path
|
| 156 |
|
| 157 |
+
def _merge_audio_video(self, video_path, audio_path, out_path):
|
| 158 |
+
if not FFMPEG_AVAILABLE:
|
| 159 |
+
raise RuntimeError("ffmpeg-python not available")
|
| 160 |
+
|
| 161 |
+
try:
|
| 162 |
+
video_in = ffmpeg.input(video_path)
|
| 163 |
+
audio_in = ffmpeg.input(audio_path)
|
| 164 |
+
(
|
| 165 |
+
ffmpeg
|
| 166 |
+
.output(video_in, audio_in, out_path, vcodec='libx264', acodec='aac', shortest=None)
|
| 167 |
+
.overwrite_output()
|
| 168 |
+
.run(quiet=True, capture_stdout=True, capture_stderr=True)
|
| 169 |
+
)
|
| 170 |
+
logger.info(f"Merged video and audio into {out_path}")
|
| 171 |
+
except Exception as e:
|
| 172 |
+
logger.error(f"Failed to merge audio and video: {e}")
|
| 173 |
+
raise
|
| 174 |
+
|
| 175 |
+
return out_path
|
| 176 |
|
|
|
|
| 177 |
|
| 178 |
|
| 179 |
# ---------------- Enhancement Modules ----------------
|