Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/t-mullen/mediastream-to-webm
Convert MediaStreams to live WebM streams.
https://github.com/t-mullen/mediastream-to-webm
mediastream p2p webm webrtc
Last synced: 3 days ago
JSON representation
Convert MediaStreams to live WebM streams.
- Host: GitHub
- URL: https://github.com/t-mullen/mediastream-to-webm
- Owner: t-mullen
- Created: 2018-01-25T18:51:46.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-25T00:41:26.000Z (about 5 years ago)
- Last Synced: 2025-01-05T08:05:01.320Z (6 days ago)
- Topics: mediastream, p2p, webm, webrtc
- Language: JavaScript
- Size: 83 KB
- Stars: 15
- Watchers: 6
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mediastream-to-webm
Converts MediaStreams to live WebM streams. Currently only for Chrome.
Allows you to send video/audio as a single outgoing data stream to many peers.
## Features
- Packages webm clusters and headers into standalone chunks that don't require the entire stream.
- Fixes MSE problems with timestamp gaps.
- Abstracts away recording and source buffers.## Install
```javascript
var MediaStreamToWebm = require('mediastream-to-webm')
``````html
```
## Usage
```javascript
// Wrap your MediaStream into an encoder
var encodedStream = MediaStreamToWebm.EncodedStream(mediaStream)// The encoded stream is a ReadableStream
encodedStream.pipe(socket1)
encodedStream.pipe(socket2) // pipe as many times as you want, at any time, without worrying about the structure of the stream
encodedStream.pipe(socket2)
// ...
``````javascript
var decodedStream = MediaStreamToWebm.DecodedStream()
socket.pipe(decodedStream) // pipe the encoded stream into the decoded// The buffered video element is available for us to watch!
var video = decodedStream.videoElement
video.autoplay = true
video.oncanplay = function () {
video.play()
}
document.body.appendChild(video)
```## API
### `MediaStreamToWebm.EncodedStream(mediaStream, opts)`
Encode a MediaStream into a webm data stream.`mediaStream` - The input MediaStream you want to broadcast.
`opts` - Options object. Default is:
```javascript
{
interval: 10,
mimeType: 'video/webm; codecs="opus,vp8"'
}
```### `MediaStreamToWebm.DecodedStream(opts)`
Decode an encoded webm data stream. Decoded data will be buffered into a video element.`opts` - Options object. Default is:
```javascript
{
videoElement: null, // specify an existing video element
mimeType: 'video/webm; codecs="opus,vp8"'
}
```## `DecodedStream.videoElement`
The video element that will be buffered with the decoded webm stream.## Notes
- Currently only works on Chrome (Firefox refuses to accept a webm stream from their own MediaRecorder...)
- This module has additional overhead for live streaming. If you want just want a prerecorded stream, use `media-recorder-stream`.
- Headers are sent with every chunk and this packaged needs to be decoded. You won't be able to pass the data stream directly into a webm player.
- Less efficient and versatile than sending MediaStreams over WebRTC. This "dumb" video stream is not meant to be a replacement for the adaptive bitrate, network-aware SRTP protocol used by WebRTC.