Skip to main content

Whitebox Plugin - VideoJS

This is a plugin for whitebox that provides VideoJS integration, including WHEP (WebRTC) streaming support.

Installation

Simply install the plugin to whitebox:

poetry add whitebox-plugin-videojs

WHEP Tech - WebRTC Streaming

This plugin includes a custom Video.js Tech for WHEP (WebRTC-HTTP Egress Protocol) streaming. WHEP enables ultra-low-latency video playback from WebRTC-capable media servers.

What is WHEP?

WHEP (WebRTC-HTTP Egress Protocol) is a standardized protocol for receiving WebRTC streams. It simplifies WebRTC consumption by using HTTP for signaling:

  1. Client sends an SDP offer via HTTP POST to the WHEP endpoint
  2. Server responds with an SDP answer
  3. ICE candidates are exchanged (trickle ICE supported)
  4. WebRTC peer connection is established
  5. Media flows over WebRTC (UDP/SRTP)

Unlike traditional WebRTC which requires custom signaling servers, WHEP uses simple HTTP - making it easy to integrate with any media server that supports it.

Architecture Overview

┌─────────────────────────────────────────────────────────────────────────────┐
│                           STREAMING PIPELINE                                │
└─────────────────────────────────────────────────────────────────────────────┘

┌──────────────┐     ┌─────────────────┐     ┌─────────────────┐
│   Insta360   │     │     FFmpeg      │     │   SRS Server    │
│    Camera    │────▶│   (transcode)   │────▶│  (media server) │
│              │WiFi │                 │RTMP │                 │
└──────────────┘     │ • Dual fisheye  │     │ • RTMP ingest   │
                     │   → equirect    │     │ • WebRTC/WHEP   │
                     │ • H.264 encode  │     │   egress        │
                     └─────────────────┘     └────────┬────────┘
                                                      │
                                                      │ WHEP (HTTP + WebRTC)
                                                      ▼
┌──────────────────────────────────────────────────────────────────────────────┐
│                              BROWSER                                         │
│  ┌─────────────────┐     ┌─────────────────┐     ┌──────────────────┐        │
│  │    WHEP Tech    │     │    Video.js     │     │    Pannellum     │        │
│  │  (whep-tech.js) │────▶│     Player      │────▶│   360 Viewer     │        │
│  │                 │     │                 │     │                  │        │
│  │ • SDP exchange  │     │ • <video> with  │     │ • WebGL canvas   │        │
│  │ • ICE handling  │     │   srcObject     │     │ • Equirectangular│        │
│  │ • Reconnection  │     │ • Playback ctrl │     │   projection     │        │
│  └─────────────────┘     └─────────────────┘     └──────────────────┘        │
└──────────────────────────────────────────────────────────────────────────────┘

Key Components

1. WHEP Tech (whep-tech.js)

Custom Video.js Tech that handles WebRTC playback:

// Usage
const player = videojs('my-video', {
  techOrder: ['whep'],  // Use WHEP tech
  sources: [{
    src: 'https://srs-server/rtc/v1/whep/?app=live&stream=livestream',
    type: 'application/whep'  // MIME type triggers WHEP tech
  }]
});

Features:

  • Automatic SDP offer/answer exchange
  • Trickle ICE candidate handling
  • Connection state management with events
  • Auto-reconnection with exponential backoff
  • Graceful cleanup on dispose

Events emitted:

  • whep:connecting - Starting connection
  • whep:streaming - Media flowing
  • whep:reconnecting - Connection lost, retrying
  • whep:error - Connection failed

2. Integration with Pannellum (360 Video)

The whitebox-plugin-pannellum provides 360-degree video rendering. It detects WebRTC streams via srcObject:

// In Pannellum360Video.jsx
const isWebRTC = !!videoEl?.srcObject;

if (isWebRTC) {
  // Direct Pannellum initialization - pass video element as texture
  pannellum.viewer(container, {
    type: "equirectangular",
    panorama: videoEl,  // Video element with srcObject
    dynamic: true,
  });
} else {
  // Regular video URL - use videojs-pannellum plugin
  player.pannellum(config);
}

Why the distinction?

  • WebRTC uses srcObject (MediaStream) not src (URL)
  • The videojs-pannellum plugin doesn't handle srcObject
  • Direct Pannellum init passes the video element as a WebGL texture source

Connection Flow

1. Player initialized with WHEP source
   └─▶ WhepTech.setSrc() called

2. Create RTCPeerConnection
   └─▶ Add transceiver for video (recvonly)
   └─▶ Create SDP offer

3. HTTP POST offer to WHEP endpoint
   └─▶ Server returns SDP answer
   └─▶ setRemoteDescription(answer)

4. ICE candidate gathering
   └─▶ Local candidates sent via PATCH
   └─▶ Remote candidates from Link headers

5. Connection established
   └─▶ ontrack fires with MediaStream
   └─▶ video.srcObject = stream
   └─▶ Emit 'whep:streaming'

6. On disconnect
   └─▶ Exponential backoff retry
   └─▶ Emit 'whep:reconnecting'

Frame Detection for 360 Video

WebRTC streams require special handling for 360 rendering. We must wait for actual video frames before initializing Pannellum:

// waitForVideoFrame() in Pannellum360Video.jsx
if ("requestVideoFrameCallback" in videoEl) {
  // Chrome 83+, Firefox 130+ - fires when frame is ready
  videoEl.requestVideoFrameCallback(checkFrame);
} else {
  // Fallback: poll videoWidth/videoHeight
  setInterval(checkDimensions, 100);
}

This prevents the "black sphere" issue where Pannellum initializes before any video data arrives.

Additional Instructions

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whitebox_plugin_videojs-0.1.6.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whitebox_plugin_videojs-0.1.6-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file whitebox_plugin_videojs-0.1.6.tar.gz.

File metadata

  • Download URL: whitebox_plugin_videojs-0.1.6.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0.dev0 CPython/3.14.4 Linux/6.1.75+

File hashes

Hashes for whitebox_plugin_videojs-0.1.6.tar.gz
Algorithm Hash digest
SHA256 30412f0ca36069051e93e083075b6b60daa6085869849d288c6a83c5e263ee46
MD5 e40bb1bb0986f37516b9e1eb4294c27d
BLAKE2b-256 d9072859d4bd8e14fe62652e6a36e88eff5cda984db80dc96ce17204d0c6d479

See more details on using hashes here.

File details

Details for the file whitebox_plugin_videojs-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for whitebox_plugin_videojs-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9d092e83a50908f6f9b00a4a8a9203f1015236a1d7554a04335b530a93893e80
MD5 c3afeed85b8ef031e9bbcf119a7b8072
BLAKE2b-256 83c535441d5998d9767cb601b7e69d24ad6844474867629cd8272ce013e66e09

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page