From 9c64f3f994965ebc86038a44e56f7dc701fd8a59 Mon Sep 17 00:00:00 2001 From: CarolinePascal Date: Tue, 5 May 2026 11:31:23 +0200 Subject: [PATCH] chore(format): formatting code, fixing error messages and variable names --- src/lerobot/datasets/pyav_utils.py | 6 +----- src/lerobot/datasets/video_utils.py | 11 +++++------ tests/datasets/test_video_encoding.py | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/lerobot/datasets/pyav_utils.py b/src/lerobot/datasets/pyav_utils.py index c13c66b89..20ec44e2e 100644 --- a/src/lerobot/datasets/pyav_utils.py +++ b/src/lerobot/datasets/pyav_utils.py @@ -177,10 +177,6 @@ def check_video_encoder_config_pyav(config: VideoEncoderConfig) -> None: vcodec = config.vcodec options = _get_codec_options_by_name(vcodec) if not options: - logger.warning( - "Codec %r is not available in the bundled FFmpeg build; ", - vcodec, - ) - return + raise ValueError(f"Codec {vcodec!r} is not available in the bundled FFmpeg build") _check_pixel_format(config.vcodec, config.pix_fmt) _check_codec_options(config.vcodec, config.get_codec_options(), config) diff --git a/src/lerobot/datasets/video_utils.py b/src/lerobot/datasets/video_utils.py index 9142c9364..4f39e7679 100644 --- a/src/lerobot/datasets/video_utils.py +++ b/src/lerobot/datasets/video_utils.py @@ -46,7 +46,7 @@ logger = logging.getLogger(__name__) # List of hardware encoders to probe for auto-selection. Availability depends on the platform and FFmpeg build. # Determines the order of preference for auto-selection when vcodec="auto" is used. -HW_ENCODERS = [ +HW_VIDEO_CODECS = [ "h264_videotoolbox", # macOS "hevc_videotoolbox", # macOS "h264_nvenc", # NVIDIA GPU @@ -55,7 +55,7 @@ HW_ENCODERS = [ "h264_qsv", # Intel Quick Sync ] -VALID_VIDEO_CODECS = {"h264", "hevc", "libsvtav1", "auto"} | set(HW_ENCODERS) +VALID_VIDEO_CODECS = {"h264", "hevc", "libsvtav1", "auto"} | set(HW_VIDEO_CODECS) LIBSVTAV1_DEFAULT_PRESET: int = 12 @@ -125,8 +125,8 @@ class VideoEncoderConfig: 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": - available = self.detect_available_encoders(HW_ENCODERS) - for encoder in HW_ENCODERS: + available = self.detect_available_encoders(HW_VIDEO_CODECS) + for encoder in HW_VIDEO_CODECS: if encoder in available: logger.info(f"Auto-selected video codec: {encoder}") self.vcodec = encoder @@ -136,13 +136,12 @@ class VideoEncoderConfig: if self.detect_available_encoders(self.vcodec): logger.info(f"Using video codec: {self.vcodec}") - self.vcodec = self.vcodec return raise ValueError(f"Unsupported video codec: {self.vcodec} with video backend {self.video_backend}") def get_codec_options( self, encoder_threads: int | None = None, as_strings: bool = False - ) -> dict[str, str]: + ) -> dict[str, Any]: """Translate the tuning fields to codec-specific FFmpeg options. ``VideoEncoderConfig.extra_options`` are merged last but never override a structured field. diff --git a/tests/datasets/test_video_encoding.py b/tests/datasets/test_video_encoding.py index 6dde3a36b..0b329d5f7 100644 --- a/tests/datasets/test_video_encoding.py +++ b/tests/datasets/test_video_encoding.py @@ -298,7 +298,7 @@ class TestEncoderDetection: @require_videotoolbox def test_auto_picks_videotoolbox_when_available(self): - """``h264_videotoolbox`` sits at the top of ``HW_ENCODERS`` so it wins when present.""" + """``h264_videotoolbox`` sits at the top of ``HW_VIDEO_CODECS`` so it wins when present.""" cfg = VideoEncoderConfig(vcodec="auto") assert cfg.vcodec == "h264_videotoolbox"