xai-org/x-algorithm · warning · TypeError
Container is not an InputContainer: {type(container).__name_
Error message
Container is not an InputContainer: {type(container).__name__} What it means
_extract_frames opens the video with PyAV and asserts the returned container is an av.InputContainer. av.open(io.BytesIO(...)) should always yield an InputContainer for readable byte streams, so this TypeError firing indicates an unexpected PyAV return type — classically an output container, or an av version/typing change. It is effectively a defensive invariant check.
Source
Thrown at grox/libs/video_tools/video_frames.py:65
tile_size,
enable_clahe,
include_combined_video_bytes,
)
@classmethod
def _extract_frames(
cls,
video_bytes: bytes,
max_frames: int,
tile_size: int | None,
enable_clahe: bool = False,
include_combined_video_bytes: bool = True,
) -> VideoData:
logger.info(f"Extracting maximum {max_frames} frames from video")
with av.open(io.BytesIO(video_bytes)) as container:
if not isinstance(container, InputContainer):
raise TypeError(
f"Container is not an InputContainer: {type(container).__name__}"
)
c_duration = container.duration
if not c_duration:
logger.warning("No duration found for video")
c_duration = 0
total_duration = float(c_duration / av.time_base)
sample_times = cls._sample_frames(total_duration, max_frames)
frames = cls._extract_frames_at_times(container, sample_times)
for frame in frames:
frame.frame = cls._process_frame(frame.frame, tile_size, enable_clahe)
logger.info(f"Extracted {len(frames)} frames")
combined_bytes = (
cls.get_video_bytes([frame.frame for frame in frames])
if include_combined_video_bytes
else None
)
return VideoData(View on GitHub (pinned to 24c60942c5)
Solutions
- Pin/align the av package to the version this code was built against (check the project's lock/requirements).
- If it persists, replace the isinstance identity check or compare container.__class__.__name__ / use av.logging diagnostics; report upstream.
- In tests, avoid mocking av.open with objects that are not real InputContainer instances.
Example fix
# before
with av.open(io.BytesIO(video_bytes)) as container:
if not isinstance(container, InputContainer): # TypeError on av version drift
raise TypeError(...)
# after (pin the dependency instead of changing logic)
# requirements.txt: av==14.0.1 (match the version the library was tested with) Defensive patterns
Strategy: type-guard
Validate before calling
# guard at the dependency level before extracting frames
import av
assert tuple(int(x) for x in av.__version__.split('.')[:2]) >= (14, 0), 'unsupported PyAV' Type guard
import av
def is_input_container(c: object) -> bool:
return isinstance(c, av.input.InputContainer) or type(c).__name__ == 'InputContainer' Try / catch
try:
frames = extract_frames(video_bytes)
except TypeError as e:
if 'InputContainer' in str(e):
logger.error('PyAV version mismatch; pin av to the supported version')
raise Prevention
- Pin the av version in requirements/lockfiles
- Don't mock av.open with foreign objects in tests
- Run dependency compatibility checks in CI
When it happens
Trigger: A PyAV version where av.open on this input returns a container class not (re)exported as the av.InputContainer the module imported — i.e. identity isinstance check failing due to duplicated module imports or a renamed class; or code paths feeding something av treats as writable, returning OutputContainer.
Common situations: Upgrading/downgrading PyAV (av) so the InputContainer symbol used for isinstance no longer matches the actual runtime class; mixing av built against different FFmpeg; monkeypatching/mocking av in tests causing type mismatch.
Related errors
- class to be imported has to be either a TBase or ThriftStruc
- Sort expects a collection of %s objects, but gets %s
- Parameter [%s] type [%s] is not compatible with the default
- ASTNode return type [%s] is not compatible with the claimed
- Failed to get num_servers or num_processors from gRPC servic
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/55bc64626c1ab69d.
Report an issue: GitHub.