Skip to content

Commit b2e5ca3

Browse files
committed
Fix
1 parent 6b68797 commit b2e5ca3

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

open_dubbing/video_processing.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from typing import Final
1919

2020
from moviepy import AudioFileClip, VideoFileClip, concatenate_videoclips
21+
from moviepy.video.io.ffmpeg_reader import ffmpeg_parse_infos
2122

2223
from open_dubbing import logger
2324

@@ -34,16 +35,28 @@ def split_audio_video(*, video_file: str, output_directory: str) -> tuple[str, s
3435

3536
base_filename = os.path.basename(video_file)
3637
filename, _ = os.path.splitext(base_filename)
38+
39+
infos = ffmpeg_parse_infos(
40+
video_file,
41+
check_duration=True,
42+
fps_source="fps",
43+
decode_file=True,
44+
print_infos=True,
45+
)
46+
logger().info(f"i: {infos}")
47+
3748
with VideoFileClip(video_file) as video_clip, warnings.catch_warnings():
38-
# warnings.filterwarnings("ignore", category=UserWarning)
49+
# warnings.filterwarnings("ignore", category=UserWarning)
3950
audio_clip = video_clip.audio
4051
audio_output_file = os.path.join(output_directory, filename + "_audio.mp3")
4152
audio_clip.write_audiofile(audio_output_file, logger=None)
4253
video_clip_without_audio = video_clip.with_audio(None)
4354
fps = video_clip.fps or _DEFAULT_FPS
4455

4556
rotation_angle = getattr(video_clip, "rotation", 0)
46-
logger().info(f"Rotation angle {rotation_angle} for video, type: {type(rotation_angle)}")
57+
logger().info(
58+
f"Rotation angle {rotation_angle} for video, type: {type(rotation_angle)}"
59+
)
4760

4861
duration = getattr(video_clip, "duration", 0)
4962
logger().info(f"Duration {duration}, type: {type(duration)}")
@@ -54,7 +67,7 @@ def split_audio_video(*, video_file: str, output_directory: str) -> tuple[str, s
5467

5568
video_output_file = os.path.join(output_directory, filename + "_video.mp4")
5669
video_clip_without_audio.write_videofile(
57-
video_output_file, codec="libx264", fps=fps#, logger=None
70+
video_output_file, codec="libx264", fps=fps # , logger=None
5871
)
5972
return video_output_file, audio_output_file
6073

0 commit comments

Comments
 (0)