aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 7738d32b2fca02dd22bc5a74484b804eb8abef2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# EZLive: Self-hosted Serverless Livestream

EZLive is a minimal self-hosted livestream solution built on top of S3-compatible object storage.

It runs a local SRT server, receive live video, turns it into HLS segments (.m3u8 + .ts) and serves them as static files through any S3-compatible object storage. No dedicated streaming server is required — everything runs serverlessly. Then you can easily setup a HTML5 HLS player to watch the stream.

# Build

Install dependencies:

- [SRT](https://github.com/Haivision/srt)
- FFMpeg (libavformat, libavutil, libavcodec)
- AWS C++ SDK (libaws-cpp-sdk-core, libaws-cpp-sdk-s3)

Build:

    make


# Usage

Setup a S3-compatible object storage bucket, for example, Cloudflare R2, AWS S3, Minio, DigitalOcean, etc.

Then create a config file `config`:

```
listening_addr=127.0.0.1
listening_port=61935
bucket=YOUR_BUCKET_NAME
endpoint=https://your-s3.com
s3_path=ezlive/
access_key=YOUR_S3_ACCESS_KEY
secret_key=YOUR_S3_SECRET_KEY
region=auto
key=your_live_key
```

In the dashboard of your object storage provider, enable public read, and add the domain name of your web HLS player to CORS setting. If you don't know how to setup a web HLS player, just add `https://mistivia.github.io`.

For AWS S3, Edit bucket setting, set "Permissions" -> "Bucket Policy" to:

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "PublicReadOnly",
                "Effect": "Allow",
                "Principal": "*",
                "Action": "s3:GetObject",
                "Resource": "arn:aws:s3:::nebulive/*"
            }
        ]
    }

Then set "Permissions" -> "Cross-origin resource sharing (CORS)" to:

    [
        {
            "AllowedHeaders": [
                "*"
            ],
            "AllowedMethods": [
                "GET"
            ],
            "AllowedOrigins": [
                "https://your.hls.player.com"
            ],
            "ExposeHeaders": []
        }
    ]

Start EZLive:

```
./ezlive
```

Open OBS, streaming to `srt://127.0.0.1:61935`, with streaming key. The streaming format must be H.264 + AAC.

Then use a HLS player to load `https://YOUR_BUCKET_NAME.your-s3.com/ezlive/stream.m3u8` to watch the stream.

If you don't know how to setup a HLS player, then make sure you have added `https://mistivia.github.io` in your object storage's CORS setting, then open `https://mistivia.github.io/ezlive#https://YOUR_BUCKET_NAME.your-s3.com/ezlive/stream.m3u8`.

# WARNING

The Docker and Windows binary builds were done on my laptop. While I promise I have no malicious intent, this does not guarantee that my build environment is secure, so is the build target. If you truly care about your privacy and security, please make sure to build from source yourself.

# Docker Usage

Download the docker image tarball in [release](https://github.com/mistivia/ezlive/releases).

Load the docker image:

    cat ezlive-docker-image.tar.gz | gzip -d | sudo docker load

Create a directory `conf`:

    mkdir conf

Create a config file `conf/config`, the config file is nearly the same as the config above. But for docker, the `listening_addr` should be `0.0.0.0`:

    listening_addr=0.0.0.0
    listening_port=61935
    bucket=YOUR_BUCKET_NAME
    endpoint=https://your-s3.com
    s3_path=ezlive/
    access_key=YOUR_S3_ACCESS_KEY
    secret_key=YOUR_S3_SECRET_KEY
    region=auto
    key=your_live_key

Start docker container:

    sudo docker run -it --rm \
        -v ./conf:/etc/ezlive/ \
        -p 127.0.0.1:61935:61935/udp \
        localhost/ezlive

# Windows

For windows users, there is a windows build using MSYS2. See [release](https://github.com/mistivia/ezlive/releases).

To start using, unzip the windows tarball, create a `config` file in the same directory as `ezlive.exe`, and run `ezlive.exe`.

# Credits

Thank [@uonr](https://github.com/uonr) for making nix flake.