From 5ee7cde123d9f71dd2e645eb3ef04349cdea3521 Mon Sep 17 00:00:00 2001 From: Administrator Administrator Date: Sun, 1 Sep 2024 19:35:03 -0700 Subject: [PATCH] Turn on Audio Sync for audio extraction process --- custom_libs/subliminal_patch/providers/whisperai.py | 2 +- libs/ffsubsync/speech_transformers.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/custom_libs/subliminal_patch/providers/whisperai.py b/custom_libs/subliminal_patch/providers/whisperai.py index d427f8ad2..866585cdb 100644 --- a/custom_libs/subliminal_patch/providers/whisperai.py +++ b/custom_libs/subliminal_patch/providers/whisperai.py @@ -143,7 +143,7 @@ def encode_audio_stream(path, ffmpeg_path, audio_stream_language=None): logger.debug(f"Whisper will only use the {audio_stream_language} audio stream for {path}") inp = inp[f'a:m:language:{audio_stream_language}'] - out, _ = inp.output("-", format="s16le", acodec="pcm_s16le", ac=1, ar=16000) \ + out, _ = inp.output("-", format="s16le", acodec="pcm_s16le", ac=1, ar=16000, af="aresample=async=1") \ .run(cmd=[ffmpeg_path, "-nostdin"], capture_stdout=True, capture_stderr=True) except ffmpeg.Error as e: diff --git a/libs/ffsubsync/speech_transformers.py b/libs/ffsubsync/speech_transformers.py index 72ca23e30..38883d14b 100644 --- a/libs/ffsubsync/speech_transformers.py +++ b/libs/ffsubsync/speech_transformers.py @@ -367,6 +367,8 @@ def fit(self, fname: str, *_) -> "VideoSpeechTransformer": "1", "-acodec", "pcm_s16le", + "-af", + "aresample=async=1", "-ar", str(self.frame_rate), "-",