@eliteencoder/byoc-sdk
v1.0.4
Published
Production-quality SDK for Livepeer BYOC video streaming with AI processing
Maintainers
Readme
BYOC Stream SDK
Production-quality SDK for Livepeer BYOC video streaming with AI-powered insights.
Highlights
- 🎥 WebRTC streaming with WHIP/WHEP endpoints and automatic ICE handling
- 🤖 AI-ready pipelines with custom params/state updates
- 📊 SSE data streaming for stats and text insights
- 📱 Media device management with permissions and device lists
- ⚛️ React hooks for publisher, viewer, data, and event flows
- 📦 TypeScript-first exports with ESM/CJS builds
- 🔄 Robust retries plus connection monitoring and stats
Quick Start
git clone https://github.com/eliteprox/byoc-sdk.git
cd byoc-sdk
npm install
npm run build # produces `dist/` for publishing or linking
npm run serve:examples # opens `examples/html-demo.html` on http://localhost:3005The serve:examples script spins up http-server against the repo root and immediately serves examples/html-demo.html. Open http://localhost:3005 to try the new single-page demo and inspect the console log to see SDK events and stats.
Example Preview
examples/html-demo.htmlis the only bundled example. It wires the SDK to the browser camera, logs events, and renders stats + config controls.- Adjust the
promptsinput or theStreamPublisherstart options inside that file to exercise different AI pipelines or resolutions. - Use the
StreamPublisher,StreamViewer, andDataStreamClientsnippets below as the foundation for your own pages.
Integrating the SDK
import { StreamPublisher, StreamConfig } from '@eliteencoder/byoc-sdk'
const config: StreamConfig = {
whipUrl: 'https://your-server/gateway/ai/stream/start',
whepUrl: 'https://your-server/mediamtx',
dataStreamUrl: 'https://your-server/gateway',
kafkaEventsUrl: 'https://your-server/kafka/events',
defaultPipeline: 'comfystream'
}
const publisher = new StreamPublisher(config)
await publisher.start({
streamName: 'my-stream',
pipeline: 'comfystream',
width: 1280,
height: 720,
fpsLimit: 30,
enableVideoIngress: true,
enableAudioIngress: true,
enableDataOutput: true,
customParams: { prompts: 'Analyze this frame' }
})
await publisher.updateStream({
params: { prompts: '{"1":{"inputs":{"images":["3",0]},"class_type":"SaveTensor"}}' },
// Width/height changes require restarting the stream, so omit them here.
})Hook up a StreamViewer to the same StreamConfig to render the WHEP output, or create a DataStreamClient for SSE payloads to mirror real-time insights from the demo.
Commands
npm run build– emitdist/for publishing or linkingnpm run serve:examples– serveexamples/html-demo.htmlon port 3005npm test– run the Vitest suitenpm run demo:dev– start the React demo webapp indemo/
Linking locally
Use npm link if you need to consume the SDK from another project without publishing:
cd byoc-sdk
npm link
cd ../livepeer-app-pipelines/byoc-stream/webapp
npm link @eliteencoder/byoc-sdk
npm install
npm run devSupport
- File issues at https://github.com/eliteprox/byoc-sdk/issues
- Review the bundled
demodirectory for a full React + Vite example that mirrors production usage, including its own README. - Contributions welcome – send PRs to the repository and reference this README for context.
License
MIT
