View on GitHub

Webcast.js

Streaming from your browser to the world!

Webcast.js

Webcast Flowchart
The Webcast Flowchart

Description

The webcast library is designed to write browser-based clients to stream local files and live media (webcam video, microphone audio).

The API contains several classes:

Here's the highlight of how to use the library:

var source = (...);

var encoder = new Webcast.Encoder.Mp3({
  channels: 2,
  samplerate: 44100,
  bitrate: 128
});

if (inputSampleRate !== 44100) {
  encoder = new Webcast.Encoder.Resample({
    encoder:    encoder,
    samplerate: inputSampleRate 
  });
}

if (useWorker) {
  encoder = new Webcast.Encoder.Asynchronous({
    encoder: encoder,
    scripts: [(...)], // full path to required scripts for the worker.
                      // usually includes requires encoders and webcast.js 
  });
}

var webcast = context.createWebcastSource(4096, 2);

source.connect(webcast);
webcast.connect(audioContext.destination);

webcast.sendMetadata({
  title:  "My Awesome Stream",
  artist: "The Dude"
});

The library involves several cutting-edge technologies and, thus, require a fairly modern browser. Here's a quick summary of the required technologies:

How to test?

Client

A browser-based streaming client, sending mp3 encoded data, using libshine.js or raw PCM data is available at webcast/webcaster

Server

The webcast/webcast.js repository contains a demo server, written in NodeJS.

Alternatively, a fully functional implementation of the protocol is available in liquidsoap. To test it, you can simply run liquidsoap with the following command line:

liquidsoap 'output.ao(fallible=true,audio_to_stereo(input.harbor("mount",port=8080)))'