diff --git a/.gitignore b/.gitignore index b0eb56e..2c9e147 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.mp4 logs/ +.DS_Store diff --git a/README.md b/README.md index 38d5d6e..779289c 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ wget http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBun Use ffmpeg to create a LL-DASH playlist. This creates a segment every 2s and MP4 fragment every 10ms. ``` -ffmpeg -i media/source.mp4 -f dash -use_timeline 0 -r:v 24 -g:v 48 -keyint_min:v 48 -sc_threshold:v 0 -tune zerolatency -streaming 1 -ldash 1 -seg_duration 2 -frag_duration 0.01 -frag_type duration media/playlist.mpd +./media/generate ``` You can increase the `frag_duration` (microseconds) to slightly reduce the file size in exchange for higher latency. @@ -62,10 +62,10 @@ If you have a valid certificate you can use it instead of self-signing. The go b Otherwise, use [mkcert](https://github.com/FiloSottile/mkcert) to install a self-signed CA: ``` -mkcert -install +./generate/cert ``` -With no arguments, the server will generate self-signed cert using this root CA. +With no arguments, the server will generate self-signed cert using this root CA. This certificate is only valid for *2 weeks* due to how WebTransport performs certificate fingerprinting. ## Server The Warp server supports WebTransport, pushing media over streams once a connection has been established. A more refined implementation would load content based on the WebTransport URL or some other messaging scheme. @@ -89,13 +89,3 @@ yarn serve These can be accessed on `https://localhost:4444` by default. If you use a custom domain for the Warp server, make sure to override the server URL with the `url` query string parameter, e.g. `https://localhost:4444/?url=https://warp.demo`. - -## Chrome -Now we need to make Chrome accept these certificates, which normally would involve trusting a root CA but this was not working with WebTransport when I last tried. - -Instead, we need to run a *fresh instance* of Chrome, instructing it to allow our self-signed certificate. This command will not work if Chrome is already running, so it's easier to use Chrome Canary instead. - -Launch a new instance of Chrome Canary: -``` -/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --allow-insecure-localhost --origin-to-force-quic-on=localhost:4443 https://localhost:4444 -``` diff --git a/cert/fingerprint b/cert/fingerprint deleted file mode 100755 index ba533e6..0000000 --- a/cert/fingerprint +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -set -euo pipefail - -HOST="localhost" - -cd "$(dirname "${BASH_SOURCE[0]}")" - -# Outputs the certificate fingerprint in the format Chrome expects -openssl x509 -pubkey -noout -in "${HOST}.crt" | - openssl rsa -pubin -outform der 2>/dev/null | - openssl dgst -sha256 -binary | - base64 diff --git a/cert/generate b/cert/generate index 7ee63d5..5103f25 100755 --- a/cert/generate +++ b/cert/generate @@ -3,4 +3,20 @@ set -euxo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" -mkcert -cert-file localhost.crt -key-file localhost.key localhost 127.0.0.1 ::1 +# Generate a new RSA key/cert for local development +HOST="localhost" +CRT="$HOST.crt" +KEY="$HOST.key" + +# Install the system certificate if it's not already +mkcert -install + +# Generate a new certificate for localhost +mkcert -ecdsa -cert-file "$CRT" -key-file "$KEY" localhost 127.0.0.1 ::1 + +# Reduce the expiration time of the certificate to 14 days; the WebTransport maximum. +# TODO https://github.com/FiloSottile/mkcert/pull/513 +openssl x509 -days 14 -in "$CRT" -signkey "$KEY" -out "$CRT" + +# Compute the sha256 fingerprint of the certificate for WebTransport +# openssl x509 -in "$CRT" -outform der | openssl dgst -sha256 diff --git a/player/package.json b/player/package.json index cbbdf4f..56ac7ae 100644 --- a/player/package.json +++ b/player/package.json @@ -1,7 +1,7 @@ { "source": "src/index.html", "scripts": { - "serve": "parcel serve --https --host localhost --port 4444 --cert ../cert/localhost.crt --key ../cert/localhost.key", + "serve": "parcel serve --https --cert ../cert/localhost.crt --key ../cert/localhost.key --host localhost --port 4444 --open", "build": "parcel build", "check": "tsc --noEmit" }, diff --git a/player/src/player.css b/player/src/index.css similarity index 100% rename from player/src/player.css rename to player/src/index.css diff --git a/player/src/index.html b/player/src/index.html index efb254c..92e0bdd 100644 --- a/player/src/index.html +++ b/player/src/index.html @@ -5,7 +5,7 @@