├── .github
├── live-obs.png
├── sequence-diagram.png
├── stream-obs.png
└── unconnected-browser.png
├── LICENSE
├── README.md
├── go.mod
├── go.sum
└── main.go
/.github/live-obs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sean-Der/OBS2Browser/c153bc3a717c5118d5a6e6edf9799aac94e3e216/.github/live-obs.png
--------------------------------------------------------------------------------
/.github/sequence-diagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sean-Der/OBS2Browser/c153bc3a717c5118d5a6e6edf9799aac94e3e216/.github/sequence-diagram.png
--------------------------------------------------------------------------------
/.github/stream-obs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sean-Der/OBS2Browser/c153bc3a717c5118d5a6e6edf9799aac94e3e216/.github/stream-obs.png
--------------------------------------------------------------------------------
/.github/unconnected-browser.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sean-Der/OBS2Browser/c153bc3a717c5118d5a6e6edf9799aac94e3e216/.github/unconnected-browser.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # OBS2Browser
2 |
3 | OBS2Browser allows you to connect OBS directly to your web browser. Your audio/video goes
4 | directly into your browser via P2P. This will reduce your stream delay and save on bandwidth costs!
5 | On a properly configured local machine you can expect to see sub-100ms times.
6 |
7 | To do this we use the newly added WHIP output in OBS. With WebRTC you can now have a low latency P2P broadcast in OBS.
8 |
9 | If you want to do a 'one to many' broadcast [Broadcast Box](https://github.com/glimesh/broadcast-box) might be a better option.
10 | OBS2Browser can only support one viewer at a time, while Broadcast Box has no upper limit.
11 |
12 | ## How it works
13 |
14 | `OBS2Browser` facilitates the handshake between your browser and OBS. It exists just to transport two text messages.
15 | After this handshaking is done `OBS2Browser` is never used. All of the media is exchanged directly between OBS and your browser.
16 |
17 |
18 |
19 | To confirm this you can shut down `OBS2Browser` after the session has started. Your browser will continue to play frames from OBS.
20 |
21 | ## How to use
22 |
23 | ### Run `OBS2Browser`
24 |
25 | Execute `go run github.com/sean-der/OBS2Browser@latest` by default it listens on port 80. You can change that by setting the environment variable `HTTP_ADDR`.
26 |
27 | You should see a log line for the HTTP Server starting
28 |
29 | ```
30 | 2023/08/15 14:51:24 Starting HTTP Server on :80
31 | ```
32 |
33 | ### Open in your browser
34 |
35 | Open [http://localhost](http://localhost) and press the `Connect` button.
36 |
37 |
38 |
39 | You will see a log in `OBS2Browser` that says the WebSocket has connected
40 |
41 | ```
42 | 2023/08/15 14:52:00 WebSocket connected
43 | ```
44 |
45 | ### Broadcast from OBS
46 |
47 | Next configure OBS to the following
48 |
49 | * **Service** - WHIP
50 | * **Server** - http://localhost/whip
51 | * **Bearer Token** - (None)
52 |
53 |
54 |
55 |
56 | ### Enjoy!
57 |
58 | Press `Start Streaming`
59 |
60 |
61 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/sean-der/OBS2Browser
2 |
3 | go 1.20
4 |
5 | require golang.org/x/net v0.14.0 // indirect
6 |
--------------------------------------------------------------------------------
/go.sum:
--------------------------------------------------------------------------------
1 | golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
2 | golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
3 |
--------------------------------------------------------------------------------
/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "io"
6 | "log"
7 | "net/http"
8 | "os"
9 | "sync/atomic"
10 |
11 | "golang.org/x/net/websocket"
12 | )
13 |
14 | func htmlHandler(w http.ResponseWriter, req *http.Request) {
15 | fmt.Fprintf(w, `
16 |
17 |