none commited on
Commit
3936b33
·
1 Parent(s): 93fde94

try to fix bugs in online inference

Browse files
src/moviedubber/infer_with_mmlm_result.py CHANGED
@@ -14,38 +14,28 @@ from src.moviedubber.model import ControlNetDiT, DiT
14
 
15
 
16
  def concat_movie_with_audio(wav, video_path, out_dir):
17
- if not os.path.exists(wav):
18
- raise FileNotFoundError(f"Audio file {wav} does not exist")
19
-
20
- if not os.path.exists(video_path):
21
- raise FileNotFoundError(f"Video file {video_path} does not exist")
22
-
23
- try:
24
- with (
25
- AudioFileClip(str(wav)) as audio_clip,
26
- VideoFileClip(str(video_path)) as video_clip,
27
- ):
28
- duration = min(video_clip.duration, audio_clip.duration)
29
-
30
- video_subclip = video_clip.subclipped(0, duration)
31
- audio_subclip = audio_clip.subclipped(0, duration)
32
-
33
- final_video = video_subclip.with_audio(audio_subclip)
34
-
35
- output_path = wav.replace(".wav", ".mp4")
36
-
37
- final_video.write_videofile(
38
- str(output_path),
39
- codec="libx264",
40
- audio_codec="mp3",
41
- fps=25,
42
- logger=None,
43
- threads=1,
44
- temp_audiofile_path=out_dir,
45
- )
46
-
47
- except Exception as e:
48
- print(f"Error processing {wav} {video_path}: {str(e)}")
49
 
50
  return output_path
51
 
 
14
 
15
 
16
  def concat_movie_with_audio(wav, video_path, out_dir):
17
+ with (
18
+ AudioFileClip(str(wav)) as audio_clip,
19
+ VideoFileClip(str(video_path)) as video_clip,
20
+ ):
21
+ duration = min(video_clip.duration, audio_clip.duration)
22
+
23
+ video_subclip = video_clip.subclipped(0, duration)
24
+ audio_subclip = audio_clip.subclipped(0, duration)
25
+
26
+ final_video = video_subclip.with_audio(audio_subclip)
27
+
28
+ output_path = wav.replace(".wav", ".mp4")
29
+
30
+ final_video.write_videofile(
31
+ str(output_path),
32
+ codec="libx264",
33
+ audio_codec="mp3",
34
+ fps=25,
35
+ logger=None,
36
+ threads=1,
37
+ temp_audiofile_path=out_dir,
38
+ )
 
 
 
 
 
 
 
 
 
 
39
 
40
  return output_path
41