This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is streamlit-webrtc, a Streamlit component that enables real-time video and audio processing using WebRTC. The library allows developers to build web apps that can capture, process, and stream video/audio data in real-time directly in the browser.
# Install dependencies
uv sync
# Install pre-commit hooks
pre-commit install# Set _RELEASE = False in streamlit_webrtc/component.py (development only, don't commit)
# Start frontend dev server
cd streamlit_webrtc/frontend
pnpm dev
# In another terminal, run the main app
streamlit run home.py# Run Python tests
uv run pytest
# Run frontend tests
cd streamlit_webrtc/frontend
pnpm test# Format backend code
make format/backend
# Or individually:
uv run ruff format .
uv run ruff check . --fix
# Format frontend code
make format/frontend
# Or individually:
cd streamlit_webrtc/frontend
pnpm format
# Format all code
make format
# Type checking
uv run mypy .# Build the complete package (frontend + backend)
make build
# Frontend build only
cd streamlit_webrtc/frontend
pnpm run buildstreamlit_webrtc/component.py: Main Streamlit component interface (webrtc_streamer)streamlit_webrtc/webrtc.py: WebRTC connection management and worker processesstreamlit_webrtc/models.py: Data models and base classes for processorsstreamlit_webrtc/process.py: Audio/video processing tracks and transformationsstreamlit_webrtc/factory.py: Factory functions for creating processing tracks
- React/TypeScript frontend in
streamlit_webrtc/frontend/ - Vite for bundling and development
- Material-UI components for UI
- WebRTC adapter for cross-browser compatibility
- Processors:
VideoProcessorBaseandAudioProcessorBasefor frame-by-frame processing - Tracks: MediaStreamTrack implementations for audio/video streams
- WebRtcWorker: Manages WebRTC connections and media processing
- Component Context:
WebRtcStreamerContextfor accessing stream state
- Browser captures media via WebRTC
- Frames are sent to Python backend
- Custom processors transform frames (video/audio)
- Processed frames are sent back to browser
- Browser displays/plays the processed media
- Edit
CHANGELOG.mdfirst - Use
make release/patch,make release/minor, ormake release/major - CI/CD automatically builds and publishes on tag push
- Set
_RELEASE = Falseincomponent.pyfor local development - Frontend dev server runs on different port than production build
- Component loads development build when
_RELEASE = False
- Python tests in
tests/directory using pytest - Frontend tests using Vitest and React Testing Library
- Example apps in
pages/for manual testing
- STUN/TURN server configuration via
rtc_configuration - Default uses Google's public STUN server
- Production deployments may need TURN servers (e.g., Twilio)