Princeaka commited on
Commit
15d564e
·
verified ·
1 Parent(s): f7db304

Update videogenerator.py

Browse files
Files changed (1) hide show
  1. videogenerator.py +19 -17
videogenerator.py CHANGED
@@ -155,23 +155,25 @@ class VideoGenerator:
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
- (
163
- ffmpeg
164
- .input(video_path)
165
- .input(audio_path)
166
- .output(out_path, vcodec='copy', acodec='aac', shortest=None)
167
- .overwrite_output()
168
- .run(quiet=True, capture_stdout=True, capture_stderr=True)
169
- )
170
- except Exception as e:
171
- logger.error(f"Failed to merge audio and video: {e}")
172
- raise
173
-
174
- return out_path
 
 
175
 
176
  # ---------------- Enhancement Modules ----------------
177
  def enhance_video(self, input_path, scale=2, smooth=True):
 
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
  # ---------------- Enhancement Modules ----------------
179
  def enhance_video(self, input_path, scale=2, smooth=True):