🐛(summary) complete webm support

When duration is not reported in the files metadata,
we directly infer the duration from the audio packets.
This prevents errors on webm files.

Very simple audio & video test files have been added
that cover relevant usecases to prevent regressions.
This commit is contained in:
Florent Chehab
2026-05-11 15:01:23 +02:00
parent 04f2a9ebdc
commit 90ebe231ef
12 changed files with 123 additions and 19 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,30 @@
"""Unit tests for the file service."""
from pathlib import Path
import pytest
from summary.core.file_service import get_media_duration
@pytest.mark.parametrize(
"filename, duration",
[
("audio-sample-android-chrome.webm", 2.2795),
("audio-sample-android-firefox.ogg", 2.3025),
("audio-sample-android.m4a", 1.38),
("audio-sample-chromium.webm", 2.65),
("audio-sample-firefox.ogg", 2.0865),
("audio-sample-ios-browser.webm", 2.6229),
("audio-sample-ios.m4a", 1.408),
("audio-sample-mac-os-safari.webm", 2.3049),
("video-sample-visio.mp4", 5.34059),
],
)
def test_validate_duration_supports_all_used_file_formats(
filename: str, duration: float
) -> None:
"""Validate duration for Safari iPhone WebM files without format duration."""
audio_path = Path(__file__).parent.parent / "assets" / filename
assert get_media_duration(audio_path) == pytest.approx(duration, 1e-3)