From 082a8e65d04fff1e4cb7115201bd120331ca8a40 Mon Sep 17 00:00:00 2001 From: lml Date: Tue, 17 Mar 2026 22:15:26 +0800 Subject: [PATCH] ffmpeg - Fill timestamp gaps with silence --- lib/converter/ffmpeg_macos.dart | 6 ++++++ lib/converter/ffmpeg_windows.dart | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lib/converter/ffmpeg_macos.dart b/lib/converter/ffmpeg_macos.dart index ba00256..77bb241 100644 --- a/lib/converter/ffmpeg_macos.dart +++ b/lib/converter/ffmpeg_macos.dart @@ -34,6 +34,8 @@ class FFmpegMacOsConverter implements WhisperAudioConverter { } // FFmpeg arguments optimized for Whisper.cpp: + // -map 0:a:0 : Select first audio stream explicitly + // -af aresample=async=1:first_pts=0 : Fill timestamp gaps with silence // -ar 16000 : 16kHz sampling rate // -ac 1 : Mono channel // -c:a pcm_s16le : 16-bit little-endian PCM (WAV) @@ -41,6 +43,10 @@ class FFmpegMacOsConverter implements WhisperAudioConverter { '-y', '-i', '"${input.path}"', + '-map', + '0:a:0', + '-af', + 'aresample=async=1:first_pts=0', '-ar', '16000', '-ac', diff --git a/lib/converter/ffmpeg_windows.dart b/lib/converter/ffmpeg_windows.dart index c03de5b..870a000 100644 --- a/lib/converter/ffmpeg_windows.dart +++ b/lib/converter/ffmpeg_windows.dart @@ -25,6 +25,8 @@ class FFmpegWindowsConverter implements WhisperAudioConverter { } // FFmpeg arguments optimized for Whisper.cpp: + // -map 0:a:0 : Select first audio stream explicitly + // -af aresample=async=1:first_pts=0 : Fill timestamp gaps with silence // -ar 16000 : 16kHz sampling rate // -ac 1 : Mono channel // -c:a pcm_s16le : 16-bit little-endian PCM (WAV) @@ -32,6 +34,10 @@ class FFmpegWindowsConverter implements WhisperAudioConverter { '-y', '-i', '"${input.path}"', + '-map', + '0:a:0', + '-af', + 'aresample=async=1:first_pts=0', '-ar', '16000', '-ac',