diff --git a/extract.py b/extract.py index 0084bac..e5f239e 100644 --- a/extract.py +++ b/extract.py @@ -323,7 +323,7 @@ def extract_audio_loudnorm(input_file: str, duration: int, start_sec: float, map_args = ["-map", f"0:a:{stream_idx}"] if stream_idx is not None else [] base = ["ffmpeg", "-y", *ss_args, "-i", input_file, "-t", str(duration), "-vn", *map_args] measure_af = f"loudnorm=I={TARGET_LUFS}:TP={TARGET_TP}:LRA={TARGET_LRA}:print_format=json" - gate_filter = ",agate=threshold=0.02:ratio=20:attack=5:release=50" if loud_gate else "" + gate_filter = ",lowpass=f=3000,agate=threshold=0.02:ratio=20:attack=5:release=50" if loud_gate else "" # ─── Pass 1: measure ─── print(f"[loudness] {stem}: pass 1/2 measuring…") @@ -332,7 +332,7 @@ def extract_audio_loudnorm(input_file: str, duration: int, start_sec: float, if r.returncode != 0: print(f"[loudness] {stem}: pass 1 failed ({r.stderr.strip()[-80:]}), falling back to simple extract", file=sys.stderr) if loud_gate: - cmd_fallback = base + ["-af", f"agate=threshold=0.02:ratio=20:attack=5:release=50", *AUDIO_CODEC, out_path] + cmd_fallback = base + ["-af", "lowpass=f=3000,agate=threshold=0.02:ratio=20:attack=5:release=50", *AUDIO_CODEC, out_path] else: cmd_fallback = base + [*AUDIO_CODEC, out_path] r2 = subprocess.run(cmd_fallback, capture_output=True, text=True) @@ -344,7 +344,7 @@ def extract_audio_loudnorm(input_file: str, duration: int, start_sec: float, if measured is None: print(f"[loudness] {stem}: could not parse measurement, falling back to simple extract", file=sys.stderr) if loud_gate: - cmd_fallback = base + ["-af", f"agate=threshold=0.02:ratio=20:attack=5:release=50", *AUDIO_CODEC, out_path] + cmd_fallback = base + ["-af", "lowpass=f=3000,agate=threshold=0.02:ratio=20:attack=5:release=50", *AUDIO_CODEC, out_path] else: cmd_fallback = base + [*AUDIO_CODEC, out_path] r2 = subprocess.run(cmd_fallback, capture_output=True, text=True) @@ -495,7 +495,7 @@ for _file_idx, INPUT_FILE in enumerate(INPUT_FILES): cmd_audio = [ "ffmpeg", "-y", *ss_args, "-i", INPUT_FILE, "-t", str(DURATION), "-vn", *map_args, "-af", - "agate=threshold=0.02:ratio=20:attack=5:release=50", + "lowpass=f=3000,agate=threshold=0.02:ratio=20:attack=5:release=50", *AUDIO_CODEC, audio_out ] else: