changes in audio delay processing

This commit is contained in:
2025-07-17 09:52:04 +02:00
parent d953574733
commit b53e79e005
2 changed files with 17 additions and 6 deletions

View File

@@ -376,10 +376,15 @@ def main(no_downmix=False):
# Find mediainfo track by StreamOrder
audio_track_info = mediainfo_audio_tracks.get(stream_index)
track_delay = 0
delay_in_seconds = audio_track_info.get("Video_Delay") if audio_track_info else None
if delay_in_seconds is not None:
delay_raw = audio_track_info.get("Video_Delay") if audio_track_info else None
if delay_raw is not None:
try:
track_delay = round(float(delay_in_seconds) * 1000)
delay_val = float(delay_raw)
# If the value is a float < 1, it's seconds, so convert to ms.
if delay_val < 1:
track_delay = int(round(delay_val * 1000))
else:
track_delay = int(round(delay_val))
except Exception:
track_delay = 0

View File

@@ -221,10 +221,16 @@ def main(no_downmix=False):
track_delay = 0
media_tracks_data = media_info.get("media", {}).get("track", [])
audio_track_info = next((t for t in media_tracks_data if t.get("@type") == "Audio" and int(t.get("StreamOrder", -1)) == stream_index), None)
delay_in_seconds = audio_track_info.get("Video_Delay") if audio_track_info else None
if delay_in_seconds is not None:
delay_raw = audio_track_info.get("Video_Delay") if audio_track_info else None
track_delay = 0
if delay_raw is not None:
try:
track_delay = round(float(delay_in_seconds) * 1000)
# If the value is a float < 1, it's seconds, so convert to ms.
delay_val = float(delay_raw)
if delay_val < 1:
track_delay = int(round(delay_val * 1000))
else:
track_delay = int(round(delay_val))
except Exception:
track_delay = 0