From 29045e0121707ae64d3aff86af10a94d25ab0ae7 Mon Sep 17 00:00:00 2001 From: Froz Date: Sun, 27 Nov 2022 12:55:14 -0800 Subject: [PATCH] Added OvenMediaEngine w Radium Next for sub-second latency streams --- OvenMediaEngine-RadiumNext/README.md | 484 +++++++++++++++++++++++++++ 1 file changed, 484 insertions(+) create mode 100644 OvenMediaEngine-RadiumNext/README.md diff --git a/OvenMediaEngine-RadiumNext/README.md b/OvenMediaEngine-RadiumNext/README.md new file mode 100644 index 0000000..2835198 --- /dev/null +++ b/OvenMediaEngine-RadiumNext/README.md @@ -0,0 +1,484 @@ +I use OvenMediaEngine + Radium Next to do sub-second latency streams from my OBS to my friends because discord stream quality sucks. + +https://www.ovenmediaengine.com/about + +https://github.com/zibbp/radium/tree/next + +A tip for this guide replace anything in the examples that says "stream.example.com" with your own desired subdomain.domainname.tld + +### Minimum File Structure +``` +/home/ +└── ~/ + └── docker/ + └── ovenmediaengine/ + └── config + ├── stream.example.com.crt + ├── stream.example.com.key + ├── Server.xml + ├── docker-compose.yml + └── radium-next/ + + ├── docker-compose.yml +``` + +Just create the directories for now. As you read further we will populate the other files. This is different from usual since we have two different services running. We need one directory for ovenmediaengine and one directory for raidum under the docker directory. You also want to create a subdirectory for ovenmediaengine called config. + +### Add to Caddyfile (from ~/docker/caddy) +Remember to `docker exec -w /etc/caddy caddy caddy reload` after editing your Caddyfile. + +``` +stream.example.com { + reverse_proxy radium:3000 +} +``` + +### docker-compose.yml inside ovenmediaengine folder +*docker-compose.yml* +``` +version: '3.3' +services: + ovenmediaengine: + image: 'airensoft/ovenmediaengine:0.14.14' + container_name: ovenmediaengine + ports: + - '1935:1935' + - '4000:4000/udp' + - '3333:3333' + - '3334:3334' + - '3478:3478' + - '9000:9000' + - '9999:9999/udp' + volumes: + - ./config:/opt/ovenmediaengine/bin/origin_conf + command: /opt/ovenmediaengine/bin/OvenMediaEngine -c origin_conf +``` + +### docker-compose.yml inside radium-next folder +``` +version: "3.3" +services: + radium: + container_name: radium-next +# ports: +# - "3000:3000" + environment: + - "BASE_URL=https://stream.example.com" + - INITIAL_SOURCE_TYPE=webrtc + - INITIAL_SOURCE_URL=wss://stream.example.com:3334/app/stream + image: ghcr.io/zibbp/radium:next + +networks: + default: + name: caddy_net +``` + +### Copy your stream.example.com Caddy crts and keys to ovenmediaengine/config +Remember stream.example.com is just the example. You need to change it. To what you plan on using. + +``` +sudo cp ~/docker/caddy/data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/stream.example.com/stream.example.com.crt ~/docker/ovenmediaengine/config/ + +sudo cp ~/docker/caddy/data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/stream.example.com/stream.example.com.key ~/docker/ovenmediaengine/config/ +``` + +### Create Server.xml inside ovenmediaengine/config folder +There are a couple of things you need to change in the default example Server.xml I included. And that's your stream.example.com and your TLS CertPath + KeyPath. + + +``` + + + + stream.example.com + + + ./stream.example.com.crt + ./stream.example.com.key + + +``` + +*Server.xml* +``` + + + + OvenMediaEngine + + origin + + * + false + + stun.l.google.com:19302 + + + + + true + + + + true + + + + + + false + 2 + + + + + + + + + + + 1 + + + 1 + + + + ${env:OME_RTMP_PROV_PORT:1935} + 1 + + + ${env:OME_SRT_PROV_PORT:9999} + 1 + + + + ${env:OME_MPEGTS_PROV_PORT:4000/udp} + + + + ${env:OME_WEBRTC_SIGNALLING_PORT:3333} + ${env:OME_WEBRTC_SIGNALLING_TLS_PORT:3334} + 1 + + + ${env:OME_WEBRTC_TCP_RELAY_ADDRESS:*:3478} + true + 1 + *:10006/udp + + + + + + + + ${env:OME_ORIGIN_PORT:9000} + 1 + + + + ${env:OME_LLHLS_STREAM_PORT:3333} + ${env:OME_LLHLS_STREAM_TLS_PORT:3334} + 1 + + + + ${env:OME_WEBRTC_SIGNALLING_PORT:3333} + ${env:OME_WEBRTC_SIGNALLING_TLS_PORT:3334} + 1 + + + *:10000-10005/udp + ${env:OME_WEBRTC_TCP_RELAY_ADDRESS:*:3478} + true + 1 + + + + + + + + + + default + + ovenmediaengine.com + + + + + stream.example.com + + + ./stream.example.com.crt + ./stream.example.com.key + + + + + + + + + + + app + + live + + + bypass_stream + ${OriginStreamName} + + + + + + + + + + + + + + + + + + + + + + stream_${Port} + 4000 + + + + + + 1 + 8 + + + 30000 + false + false + false + + + 0.5 + + 1.5 + 6 + 10 + + * + + + + + + + + +``` +# Starting it up +Now that everything has been created and configured... it's time to start your instances. + +Inside the ~/docker/ovenmediaengine folder do the following command +``` +docker compose up -d +``` +It should start up! You can view the logs by doing +``` +docker compose logs -f +``` +and stop viewing the logs with ctrl+C + +Now that ovenmediaengine is running... it's time to start radium-next + +Inside the ~/docker/radium-next folder do the following command +``` +docker compose up -d +``` +again to view logs it works the same way as before. + +Now you're ready to stream from OBS! + +# OBS Instructions +Under the stream tab of OBS set the following... + +``` +Server: rtmp://stream.example.com:1935/app +Stream Key: stream + +``` + +Under the output tab of OBS change Output Mode to "Advanced" then select the "Streaming" tab. + +Set the following if you have NVIDIA NVENC as an Encoder +``` +Encoder: NVDIA NVENC H.264 + +Rate Control: CBR +Bitrate: Your choice + +The only other important encoder settings are as follows +Tuning: Ultra Low Latency +Keyframe Interval: 1 +Max B-frames (IMPORTANT): 0 + +If you don't set Max B-frames to 0 some browsers will have issues playing the stream. +``` + +Set the following if you don't have NVIDA NVENC +``` +Encoder: x265 + +Rate Control: CBR +Bitrate: Your choice + +Keyframe Interval: 1 +CPU Usage Preset: ultrafast +Profile: main +Tune: zerolatency + +x264 Options (separated by space): bframes=0 threads=8 +``` + +Congrats, now you should be able to stream from OBS to stream.example.com + +If you can figure out how to change the stream key let me know I want to know! \ No newline at end of file