From 5d0a20bd9c0d99d885421f50b4fccd2c9fc99def Mon Sep 17 00:00:00 2001 From: CarolinePascal Date: Sun, 26 Apr 2026 13:55:36 +0200 Subject: [PATCH] feat(video): alias "av1" to "libsvtav1" for backward compat --- src/lerobot/datasets/video_utils.py | 6 ++++++ tests/datasets/test_video_encoding.py | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/lerobot/datasets/video_utils.py b/src/lerobot/datasets/video_utils.py index 0e930b5f3..209490db7 100644 --- a/src/lerobot/datasets/video_utils.py +++ b/src/lerobot/datasets/video_utils.py @@ -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": diff --git a/tests/datasets/test_video_encoding.py b/tests/datasets/test_video_encoding.py index 6dde3a36b..6c49625d3 100644 --- a/tests/datasets/test_video_encoding.py +++ b/tests/datasets/test_video_encoding.py @@ -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"