{"record":{"id":"0d2c990305c607e2","repo":"unslothai/unsloth","slug":"webm-export-failed-libvpx-vp9-unavailable-exc","errorCode":null,"errorMessage":"WebM export failed (libvpx-vp9 unavailable?): {exc}","messagePattern":"WebM export failed \\(libvpx-vp9 unavailable\\?\\): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":501,"severity":"error","filePath":"studio/backend/core/inference/video_gallery.py","lineNumber":202,"sourceCode":"                        for out_packet in out_v.encode(frame.reformat(format = \"yuv420p\")):\n                            dst.mux(out_packet)\n                    continue\n                for frame in packet.decode():\n                    for resampled in resampler.resample(frame):\n                        # Let the FIFO time the output: the resampler's frames do not line up with Opus' fixed frame size.\n                        resampled.pts = None\n                        fifo.write(resampled)\n                    _drain_audio()\n            for packet in out_v.encode():\n                dst.mux(packet)\n            if out_a is not None:\n                _drain_audio(flush = True)\n                for packet in out_a.encode():\n                    dst.mux(packet)\n    except RuntimeError:\n        raise\n    except Exception as exc:  # noqa: BLE001 -- surface as \"encoder unavailable\"\n        raise RuntimeError(f\"WebM export failed (libvpx-vp9 unavailable?): {exc}\") from exc\n\n\n# Ceilings for a GIF export, which must hold every kept frame in memory before encoding. 720 px and 300 frames (25s at the\n# 12 fps target) bound that at roughly 150 MB for the widest clip a generate request allows.\n_GIF_MAX_EDGE = 720\n_GIF_MAX_FRAMES = 300\n\n\ndef _transcode_gif(path: Path) -> bytes:\n    import io\n\n    try:\n        import av\n        from PIL import Image\n    except Exception as exc:  # noqa: BLE001 -- missing deps -> no transcode\n        raise RuntimeError(\"GIF export needs the 'av' and 'Pillow' packages.\") from exc\n    frames: list[Any] = []\n    try:","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/video_gallery.py#L184-L220","documentation":"The catch-all at the bottom of _transcode_webm: any non-RuntimeError exception during open/decode/encode is re-wrapped as 'WebM export failed (libvpx-vp9 unavailable?)' with the original exception chained. The leading hypothesis in the message is the common one — the PyAV build lacks the libvpx-vp9 encoder — but the wrapped exc is the real diagnosis. Deliberate RuntimeErrors (no video stream) are re-raised untouched.","triggerScenarios":"PyAV installed from source or a distro package compiled without libvpx; a decode error mid-clip (corrupt frame); muxing failures such as unmatched stream parameters; audio path failures (Opus encoder missing) also land here.","commonSituations":"Distro Python-av packages (Debian/Ubuntu apt builds sometimes exclude libvpx); old PyAV versions predating bundled ffmpeg with VP9; partially corrupt generated clips.","solutions":["Read the chained original exception ({exc}) — it names the actual failing operation/codec.","If it is indeed libvpx-vp9: pip install --force-reinstall av to get the PyPI wheel whose ffmpeg includes libvpx.","Check the source clip plays with ffprobe/ffplay; a decode-side error is a corrupt input, not a codec issue.","Fall back to MP4 export (H.264, different encoder) while the environment is fixed."],"exampleFix":"# before: distro av package without libvpx -> RuntimeError('libvpx-vp9 unavailable?')\nsudo apt remove python3-av\n\n# after: PyPI wheel bundles ffmpeg with libvpx-vp9\npip install --force-reinstall av","handlingStrategy":"fallback","validationCode":"import av\n\ndef vp9_encoder_available() -> bool:\n    try:\n        with av.open(\"out.webm\", \"w\", format=\"webm\") as c:\n            c.add_stream(\"libvpx-vp9\", rate=24)\n        return True\n    except Exception:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    _transcode_webm(src, dest)\nexcept RuntimeError as e:\n    if \"libvpx-vp9 unavailable\" in str(e):\n        data = export_clip(clip, fmt=\"mp4\")  # different encoder, same clip\n    else:\n        raise","preventionTips":["Use PyPI 'av' wheels (bundled ffmpeg with libvpx), not distro packages lacking VP9.","Read the chained __cause__ exception — the wrapper's guess is only the common case.","Add a startup probe that adds a libvpx-vp9 stream to a throwaway WebM container."],"tags":["video","webm","codec","libvpx","dependency"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}