{"record":{"id":"f0f74ca6e0fa2746","repo":"unslothai/unsloth","slug":"minimax-h3-reference-videos-run-h3-ref-video-min","errorCode":null,"errorMessage":"MiniMax-H3 reference videos run {H3_REF_VIDEO_MIN_SECONDS:g} to {H3_REF_VIDEO_MAX_SECONDS:g} seconds; this one is longer than {H3_REF_VIDEO_MAX_SECONDS:g}s. Trim it first.","messagePattern":"MiniMax-H3 reference videos run (.+?) to (.+?) seconds; this one is longer than (.+?)s\\. Trim it first\\.","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"studio/backend/core/inference/video_minimax_h3.py","lineNumber":401,"sourceCode":"    with av.open(io.BytesIO(blob)) as container:\n        if not container.streams.video:\n            raise ValueError(\"That reference file carries no video track.\")\n        stream = container.streams.video[0]\n        source_fps = float(stream.average_rate or stream.guessed_rate or H3_FPS)\n        if source_fps <= 0:\n            source_fps = float(H3_FPS)\n        # Select, resample, and resize incrementally to bound memory for 4K inputs.\n        from PIL import Image\n\n        frames = []\n        decoded_count = 0\n        next_target = 0\n        fitted_size = None\n        max_source_frames = math.floor(H3_REF_VIDEO_MAX_SECONDS * source_fps + 1e-6)\n        for source_index, frame in enumerate(container.decode(video = 0)):\n            decoded_count = source_index + 1\n            if decoded_count > max_source_frames:\n                raise ValueError(\n                    f\"MiniMax-H3 reference videos run {H3_REF_VIDEO_MIN_SECONDS:g} to \"\n                    f\"{H3_REF_VIDEO_MAX_SECONDS:g} seconds; this one is longer than \"\n                    f\"{H3_REF_VIDEO_MAX_SECONDS:g}s. Trim it first.\"\n                )\n            target_source = int(next_target * source_fps / H3_FPS)\n            if target_source > source_index:\n                continue\n            image = frame.to_image().convert(\"RGB\")\n            if fitted_size is None:\n                fitted_size = h3_reference_frame_size(*image.size)\n            if image.size != fitted_size:\n                image = image.resize(fitted_size, Image.LANCZOS)\n            while int(next_target * source_fps / H3_FPS) <= source_index:\n                frames.append(image)\n                next_target += 1\n\n    if decoded_count == 0:\n        raise ValueError(\"That reference video decoded to no frames.\")","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/video_minimax_h3.py#L383-L419","documentation":"While decoding a reference video frame-by-frame, the decoder counts source frames and raises once decoded_count exceeds max_source_frames = floor(H3_REF_VIDEO_MAX_SECONDS * source_fps + 1e-6), i.e. the clip runs longer than the model's reference window (15s). Checking during the loop (rather than after) bounds decode work and memory for long 4K inputs instead of decoding 10 minutes to then refuse.","triggerScenarios":"Uploading a 60s or 10-minute clip as an H3 reference video; high-fps sources where even short wall-clock durations exceed the frame budget only after seconds > 15.","commonSituations":"Users pasting full shot takes instead of the relevant motion snippet; automated pipelines feeding untrimmed stock footage; forgetting the model's reference window is bounded.","solutions":["Trim the clip to at most 15s (H3_REF_VIDEO_MAX_SECONDS) before uploading.","Trim to the 2-15s window in one pass: ffmpeg -i in.mp4 -t 15 out.mp4.","Show the 2-15s constraint in the upload UI and validate duration client-side."],"exampleFix":"# before: uploading the full 45s take\nupload_reference(blob=open(\"take.mp4\", \"rb\").read())\n\n# after: trim to the model's window first\nffmpeg -ss 10 -t 5 -i take.mp4 -c copy ref.mp4  # 5s snippet, 2-15s window","handlingStrategy":"validation","validationCode":"import av, io\n\nH3_REF_VIDEO_MAX_SECONDS = 15.0\n\nwith av.open(io.BytesIO(blob)) as c:\n    s = c.streams.video[0]\n    fps = float(s.average_rate or s.guessed_rate or 25)\n    n = s.frames or 0\n    if n and n / fps > H3_REF_VIDEO_MAX_SECONDS:\n        raise ValueError(\"trim reference video to <= 15s\")","typeGuard":null,"tryCatchPattern":"try:\n    frames, wf, sr = decode_h3_reference_video(blob)\nexcept ValueError as e:\n    if \"longer than\" in str(e) and \"seconds\" in str(e):\n        return HTTPException(400, \"trim the reference video to 2-15s\") from e\n    raise","preventionTips":["Trim to <= 15s (H3_REF_VIDEO_MAX_SECONDS) before upload.","Show the 2-15s window in upload UI copy.","Validate duration client-side from stream metadata when available."],"tags":["video","minimax-h3","upload","duration","validation"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}