mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-06-07 23:05:15 -04:00
Fix audio discontinuity by using output seeking
This commit is contained in:
@@ -3,7 +3,9 @@ from __future__ import annotations
|
||||
from .hls_utils import fetch_text, parse_media_playlist, probe_segment_timeline
|
||||
|
||||
|
||||
def test_audio_segment_100_boundary_is_continuous(master_context: dict, test_config, byte_cache) -> None:
|
||||
def test_audio_segment_100_boundary_is_continuous(
|
||||
master_context: dict, test_config, byte_cache
|
||||
) -> None:
|
||||
if not master_context["audios"]:
|
||||
return
|
||||
|
||||
@@ -48,4 +50,57 @@ def test_audio_segment_100_boundary_is_continuous(master_context: dict, test_con
|
||||
f" delta={delta:.6f}s"
|
||||
)
|
||||
|
||||
assert not failures, "audio discontinuity around lazy head boundary: " + ", ".join(failures)
|
||||
assert not failures, "audio discontinuity around lazy head boundary: " + ", ".join(
|
||||
failures
|
||||
)
|
||||
|
||||
|
||||
def test_audio_pts_never_resets_across_lazy_windows(
|
||||
master_context: dict, test_config, byte_cache
|
||||
) -> None:
|
||||
if not master_context["audios"]:
|
||||
return
|
||||
|
||||
failures: list[str] = []
|
||||
max_allowed_backward_jump_seconds = 0.25
|
||||
|
||||
for audio in master_context["audios"]:
|
||||
text = fetch_text(
|
||||
audio.url,
|
||||
timeout_seconds=test_config.timeout_seconds,
|
||||
headers=test_config.headers,
|
||||
)
|
||||
playlist = parse_media_playlist(text, audio.url, master_context["client_id"])
|
||||
if not playlist.segment_urls:
|
||||
continue
|
||||
|
||||
total_extinf = 0.0
|
||||
# sample enough segments to cross several lazy windows
|
||||
sample_count = min(len(playlist.segment_urls), 340)
|
||||
for idx in range(sample_count):
|
||||
timeline = probe_segment_timeline(
|
||||
segment_url=playlist.segment_urls[idx],
|
||||
map_url=playlist.map_url,
|
||||
timeout_seconds=test_config.timeout_seconds,
|
||||
byte_cache=byte_cache,
|
||||
headers=test_config.headers,
|
||||
)
|
||||
expected = total_extinf
|
||||
drift = timeline.start - expected
|
||||
|
||||
if drift < -max_allowed_backward_jump_seconds:
|
||||
failures.append(
|
||||
f"{audio.attrs.get('GROUP-ID', audio.url)} seg={idx}"
|
||||
f" expected_start~{expected:.3f}s actual={timeline.start:.3f}s"
|
||||
f" backward_jump={-drift:.3f}s"
|
||||
)
|
||||
break
|
||||
|
||||
if idx < len(playlist.segment_durations):
|
||||
dur = playlist.segment_durations[idx]
|
||||
if dur > 0:
|
||||
total_extinf += dur
|
||||
|
||||
assert not failures, (
|
||||
"audio timeline reset detected across lazy windows: " + ", ".join(failures)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user