Skip to content

About

Self-hosted video hosting and streaming: tus uploads, HLS transcoding, embeddable player and analytics.

Topics

Resources

Stars

18 stars

Watchers

0 watching

Forks

Repository files navigation

OpenStream - open-source video hosting and streaming

OpenStream is a self-hosted video platform: upload videos, transcode them to adaptive HLS and play them in an embeddable player on your own sites.
MIT-licensed and multi-tenant - keep your videos in your own S3-compatible buckets, decide which sites may play them, and see who watches.

License: MIT Stars Bun TypeScript PostgreSQL ffmpeg

Quick start · Features · Security · FAQ


See it in action

OpenStream product tour: dashboard, library, player, analytics, embed code and API keys


Who is it for


Teams publishing video

Courses, product demos, marketing - published on your own sites, with a player you control, without third-party branding, tracking or recommendations.


Developers

A typed OpenAPI, scoped API keys, resumable uploads and signed webhooks let your backend create, upload, sign and track videos without touching the dashboard.


Organizations

Need your media in your own infrastructure? Connect your own S3-compatible bucket per library, with credentials encrypted at rest, and choose exactly which sites may play each library.


Quick start

Note

Prerequisites: Bun 1.3, Docker with Docker Compose, Caddy and ffmpeg. Everything runs locally, with the services in Docker.

git clone https://github.com/its-gabo/open-stream.git
cd open-stream
caddy trust             # once, so the local HTTPS domains work
cp .env.example .env    # set AUTH_SECRET and STORAGE_ENCRYPTION_KEY
docker compose up -d    # PostgreSQL, Redis, Mailpit and RustFS
bun install
bun run db:migrate
bun run db:seed         # optional: demo accounts, libraries and videos
bun run dev             # web app, API, worker and reverse proxy

Tip

Generate the secrets with openssl rand -hex 32 (AUTH_SECRET) and openssl rand -base64 32 (STORAGE_ENCRYPTION_KEY).

Then open https://app.openstream.localhost, sign up, and confirm your email in the local mailbox:

URL Service
https://app.openstream.localhost Web app (/api/* goes to the API)
https://landing.openstream.localhost Landing page (bun run dev:landing)
https://mailbox.openstream.localhost Mailpit (sent emails)
https://storage.openstream.localhost RustFS console (rustfsadmin / rustfsadmin)

The API describes itself at https://app.openstream.localhost/api/v1/openapi.json.


At a glance

  Upload Resumable tus uploads in 16 MiB chunks, MP4 and MOV, up to 20 GiB
  Transcode HLS in 360p, 480p, 720p and 1080p with ffmpeg, plus a poster and a storyboard
  Store Built-in object storage, or your own S3-compatible buckets per library
  Play Embeddable player, allowed sites, optional signed and expiring URLs
  Measure Views, watch time, completion, retention, devices and embedding sites
  Integrate Library API with scoped keys, Standard Webhooks, generated TypeScript client
  Audit Organization and account activity logs with before and after values

Features

Upload and processing

  • Resumable uploads. Files go up with the tus protocol and straight into an object storage multipart upload, so an interrupted upload continues where it stopped.
  • Import from a URL. Paste a link to an MP4 or MOV file, or send it to the API, and the worker downloads it straight into storage. Redirects are followed, and every hop is checked so imports cannot reach private addresses.
  • Adaptive streaming. One ffmpeg pass turns each video into HLS in the qualities its library chooses, measured on the short side so portrait videos get the same ladder. Nothing is upscaled.
  • Seek previews. Every video gets a poster and a storyboard sprite with a WebVTT index, shown when you scrub.
  • CPU or GPU. Encode with x264, or switch VIDEO_ENCODER to videotoolbox or nvenc.
A library with processed videos
The player and its embed code

Player and embedding

  • Embeddable player. Copy an <iframe> from the video's Embed tab, with autoplay, mute, loop, start time and title options.
  • Allowed sites. Each library lists the sites that may play it. The player sends them as frame-ancestors, so no other page can frame it.
  • Signed playback. Optionally accept only expiring URLs signed by your server. Revoking the signing key revokes its URLs.
  • Chapters. Type chapters, add them at the player's position, paste a list like 0:00 Intro, or have a language model suggest them from a caption track, through OpenAI (gpt-6-luna by default) or a model server of your own that speaks OpenAI's API, then review them before saving. The player splits its seek bar at each one and lists them with storyboard thumbnails; other players can read them as a WebVTT chapters track.
  • Playlists. Group a library's videos into a playlist and embed it as one player. Viewers open an episodes menu with each video's description and how much of it they watched, skip to the next video, or let it start by itself after a countdown. Their progress stays in their own browser, and one signed URL covers every video in the playlist.
  • Calls to action. Show a button that opens a link, or a form that collects email addresses, over the video at chosen times or on its end screen. Email forms need a ticked consent checkbox, and each lead keeps the exact text the viewer agreed to. Leads can be searched, exported as CSV and deleted, and they stay when their call to action or video is deleted.
  • Captions. Upload WebVTT or SRT files, which are cleaned and stored as WebVTT, or transcribe videos with OpenAI or a speech-to-text server of your own that speaks OpenAI's API, such as a self-hosted Whisper. Libraries can transcribe every new video automatically. Each transcription provider can have a monthly limit in minutes of audio, and each chapter provider a monthly limit in tokens. The player offers the tracks in a captions menu and remembers the viewer's language.

Analytics

  • Real viewing data. Players report watched seconds and position every 15 seconds, and the server caps each report by the real time that passed.
  • Three levels. Views, watch time, average view, completion, daily views, devices and embedding sites for the organization, each library and each video, over 7, 30 or 90 days.
  • Retention. See the share of viewers still watching at each point of a video. Videos with chapters also show how many views reached and finished each chapter, and videos with calls to action show how many views saw, answered or closed each one.
Library analytics with daily views, top videos, devices and sites
Library API keys and playback security

API and webhooks

  • Library API. Up to 25 named keys per library, each limited to videos:read, videos:upload, videos:manage, playback:sign, analytics:read or leads:read.
  • Webhooks. video.* events for creation, uploads, every processing step, caption tracks and failed transcriptions, and each email address left in a call to action, signed per Standard Webhooks and retried with backoff. Deliveries can be inspected, tested and resent.
  • Typed client. The web app uses a client generated from the OpenAPI schema, and so can yours.

Organizations

  • Multi-tenant. Organizations with members, invitations, ownership transfer and scheduled deletion.
  • Bring your own storage. Connect S3-compatible buckets, test them, choose a folder layout, and assign them to libraries.
  • Activity logs. Every change is recorded with who made it, from where, and the values before and after.
The organization activity log

Security

  Tenant isolation Dashboard routes require membership of the organization, and library API keys work only on their own library.
  Secrets at rest API keys are stored as SHA-256 hashes. Storage credentials are envelope-encrypted and webhook secrets encrypted with STORAGE_ENCRYPTION_KEY; neither is returned by the API after it is created.
  CSRF and sessions Cookie-authenticated requests must come from the web app's origin. The library API uses bearer keys and sends no cookies.
  Safe webhooks In production, webhook URLs must be public HTTPS and are resolved before each delivery to refuse private addresses. Redirects are not followed.

FAQ

Do I need a GPU?

No. x264 on the CPU is the default and works everywhere. On a Mac, VIDEO_ENCODER=videotoolbox uses the hardware encoder, and nvenc does the same on NVIDIA GPUs.

Where are my videos stored?

In the default S3-compatible storage from OBJECT_STORAGE_* (RustFS locally), or in your own bucket. Each library can use a different storage, with its own folder layout.

Can I stop other sites from using my videos?

Yes. Add allowed sites to a library and only those sites can frame the player or stream its HLS. For stricter control, require signed URLs that your server creates and that expire.

How are views counted?

A view starts when the player starts playing. The player then reports how much was watched every 15 seconds, and the server caps each report by the time that actually passed. Viewers are not identified.

Can I upload from my own backend?

Yes. Create a library API key with videos:upload, create a video, and upload its file with any tus client to /api/v1/libraries/<library-id>/videos/<video-id>/uploads.


Built with

TypeScript Bun Hono React TanStack Start Tailwind CSS shadcn/ui Vite Turborepo PostgreSQL Redis ffmpeg


License

OpenStream is released under the MIT License.


OpenStream
Back to top ↑

About

Self-hosted video hosting and streaming: tus uploads, HLS transcoding, embeddable player and analytics.

Topics

Resources

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages