Git Product home page Git Product logo

browser-broadcast-box's Introduction

Browser Broadcast Box

A low latency video streaming server and client using WebRTC. It can be deployed on serverless container service like AWS Fargate or Alibaba Cloud Elastic Container Instance. Just pay for the machine time and traffic you use.

The link in the description does not contain any backend. However, you can deploy the backend yourself and use the link to connect to it.

Features

  • WHIP/WHEP protocol (compatible with OBS WHIP output)
  • Using public IP without STUN server
  • Chat using WebRTC DataChannel
  • Count of live viewers
  • Access HTTP endpoint from HTTPS page

Usage

Local development

Build static files:

npm install
npm run build

Install deno: https://deno.land/manual/getting_started/installation

Run server:

deno task dev

Open http://localhost:11733/backend/ in browser. This page will connect to deno process and handle stream forwarding. During deployment, this page will be opened with headless chromium on the server.

Open http://localhost:11733/ to browse the client.

Environment variables

You can set environment variables in .env or .env.local file.

  • BEARER_TOKEN: Required. Secret token.
  • PUBLIC_IP: Public IP of the server. If not set, it will be detected automatically on AWS Fargate and Alibaba Cloud ECI.

Stream with OBS

Make sure BEARER_TOKEN is set. On the client page, click the LIVE button, select the service as My Channel, fill in the BEARER_TOKEN, and click the CREATE button. Then you will get a link. Copy the link and paste it to OBS.

Deployments

Server

Build server docker image:

docker compose build

Deploy the image to any serverless container service. Expose port 11733 and all UDP ports.

browser-broadcast-box's People

Contributors

longern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

browser-broadcast-box's Issues

Error fetching public IP

Where can I specify the PUBLIC_IP in a .env file? I am getting a public IP not found error

async function init() {
  for (const envPath of ["./.env.local", "./.env"]) {
    try {
      loadSync({ envPath: envPath, export: true });
    } catch (_e) {
      // Ignore
    }
  }

  if (!Deno.env.get("PUBLIC_IP")) {
    const publicIp = await detectPublicIp();
    if (publicIp) Deno.env.set("PUBLIC_IP", publicIp);
  }

  if (Deno.env.get("BEARER_TOKEN")) console.log("Bearer token is set");

  const dbPath = Deno.env.get("DB") || "./db.sqlite3";
  const DB = new D1Database(dbPath);
  const migrations = new TextDecoder().decode(
    Deno.readFileSync("./server/migrations.sql")
  );
  DB.exec(migrations);
  bindings = { ...Deno.env.toObject(), DB };
}

anand@chi1:~/browser-broadcast-box$ docker compose up
[+] Running 6/6
 ⠿ chrome Pulled                                                          24.4s
   ⠿ f56be85fc22e Pull complete                                            0.9s
   ⠿ c691cfdca2fd Pull complete                                           21.3s
   ⠿ bf2668cbf258 Pull complete                                           21.4s
   ⠿ 34dc035d5a52 Pull complete                                           21.5s
   ⠿ 4f4fb700ef54 Pull complete                                           21.7s
[+] Running 3/3
 ⠿ Network browser-broadcast-box_default      Created                      0.1s
 ⠿ Container browser-broadcast-box-backend-1  Created                      0.1s
 ⠿ Container browser-broadcast-box-chrome-1   Created                      0.0s
Attaching to browser-broadcast-box-backend-1, browser-broadcast-box-chrome-1
browser-broadcast-box-backend-1  | Task prod deno run -A server/main.ts
browser-broadcast-box-backend-1  | Fetching public IP...
browser-broadcast-box-backend-1  | Listening on http://localhost:11733/
browser-broadcast-box-chrome-1   | [0412/170034.073710:ERROR:headless_shell.cc(255)] Multiple targets are not supported.
browser-broadcast-box-chrome-1 exited with code 1
browser-broadcast-box-backend-1  | No public IP found
^CGracefully stopping... (press Ctrl+C again to force)
Aborting on container exit...
[+] Running 1/2
 ⠿ Container browser-broadcast-box-chrome-1   Stopped                      0.0s
[+] Running 2/2owser-broadcast-box-backend-1  Stopping                     0.2s
[+] Running 0/1owser-broadcast-box-chrome-1   Stopped                      0.0s
 ⠿ Container browser-broadcast-box-backend-1  Error while Killing          0.2s
canceled
anand@chi1:~/browser-broadcast-box$

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.