feat(video): alias "av1" to "libsvtav1" for backward compat

This commit is contained in:
CarolinePascal
2026-04-26 13:55:36 +02:00
parent 2c796d3352
commit 5d0a20bd9c
2 changed files with 18 additions and 0 deletions

View File

@@ -138,6 +138,12 @@ class VideoEncoderConfig:
also silently rewritten to ``libsvtav1`` so encoding never hard-fails on
a host missing the requested encoder.
"""
# Backward compatibility: older datasets persist ``vcodec="av1"`` in
# ``info.json``. Rewrite to the canonical encoder name *before* the
# validation check below so loading those datasets keeps working.
if self.vcodec == "av1":
self.vcodec = "libsvtav1"
if self.vcodec not in VALID_VIDEO_CODECS:
raise ValueError(f"Invalid vcodec '{self.vcodec}'. Must be one of: {sorted(VALID_VIDEO_CODECS)}")
if self.vcodec == "auto":

View File

@@ -311,6 +311,18 @@ class TestEncoderDetection:
assert "h264_videotoolbox" in VALID_VIDEO_CODECS
assert "h264_nvenc" in VALID_VIDEO_CODECS
def test_av1_alias_resolves_to_libsvtav1(self):
"""Older datasets persist ``vcodec="av1"``; backward-compat alias must keep them loadable."""
cfg = VideoEncoderConfig(vcodec="av1")
assert cfg.vcodec == "libsvtav1"
def test_av1_alias_persisted_after_resolve(self):
"""Repeated calls to ``resolve_vcodec`` should be idempotent (alias only fires once)."""
cfg = VideoEncoderConfig(vcodec="av1")
assert cfg.vcodec == "libsvtav1"
cfg.resolve_vcodec()
assert cfg.vcodec == "libsvtav1"
ARTIFACTS = Path(__file__).parent.parent / "fixtures" / "artifacts" / "videos"