2024-02-29 21:31:42 +02:00
<!-- PROJECT LOGO -->
< p align = "center" >
< a href = "https://github.com/algora-io/tv" >
< img src = "https://user-images.githubusercontent.com/17045339/231901505-2936b331-3716-4418-9386-4a5d9cb694ba.svg" alt = "Logo" >
< / a >
< h3 align = "center" > Algora TV< / h3 >
< p align = "center" >
The interactive livestreaming & video sharing service for developers.
< br / >
< a href = "https://tv.algora.io" > Website< / a >
·
< a href = "https://algora.io/discord" > Discord< / a >
·
< a href = "https://twitter.com/algoraio" > Twitter< / a >
·
< a href = "https://www.youtube.com/@algora-io" > YouTube< / a >
·
< a href = "https://github.com/algora-io/tv/issues" > Issues< / a >
< / p >
2024-08-18 18:53:48 +02:00
< p align = "center" >
< a href = "https://console.algora.io/org/algora/bounties?status=open" >
< img src = "https://img.shields.io/endpoint?url=https%3A%2F%2Fconsole.algora.io%2Fapi%2Fshields%2Falgora%2Fbounties%3Fstatus%3Dopen" alt = "Open Bounties" >
< / a >
< a href = "https://console.algora.io/org/algora/bounties?status=completed" >
< img src = "https://img.shields.io/endpoint?url=https%3A%2F%2Fconsole.algora.io%2Fapi%2Fshields%2Falgora%2Fbounties%3Fstatus%3Dcompleted" alt = "Rewarded Bounties" >
< / a >
< / p >
2024-02-29 21:31:42 +02:00
< / p >
2024-08-30 15:22:42 +02:00
## ✨ New feature: Earn with Livestream Billboards! ✨
Algora Live Billboards allow for in-video ads, helping devs earn money while livestreaming and giving devtools companies a novel channel to reach new audiences. [Learn more ](https://tv.algora.io/partner )
https://github.com/user-attachments/assets/6f706a4b-210f-4ec8-a817-2a72cea0954a
2024-02-29 21:31:42 +02:00
<!-- GETTING STARTED -->
## Getting Started
2024-08-27 23:53:35 +02:00
To get a local copy up and running, follow these steps.
2024-02-29 21:31:42 +02:00
### Prerequisites
2024-08-27 23:50:19 +02:00
- Elixir and Erlang/OTP
2024-08-28 16:39:06 +02:00
- We recommend using [asdf ](https://github.com/asdf-vm/asdf ) to install [Elixir ](https://github.com/asdf-vm/asdf-elixir ) and [Erlang/OTP ](https://github.com/asdf-vm/asdf-erlang ).
- Keep in mind that each Elixir version supports [specific Erlang/OTP versions ](https://hexdocs.pm/elixir/compatibility-and-deprecations.html#between-elixir-and-erlang-otp ).
- Make sure you have at least **Elixir 1.12** installed to run Algora TV.
2024-02-29 21:31:42 +02:00
- PostgreSQL
2024-04-01 20:03:06 +02:00
- FFmpeg
2024-09-20 16:28:32 +02:00
- ImageMagick
2024-08-27 23:50:19 +02:00
- OBS Studio (recommended for testing livestreaming features)
### Setting up the project
2024-02-29 21:31:42 +02:00
2024-08-27 23:50:19 +02:00
1. Clone the repo and go to the project folder
2024-02-29 21:31:42 +02:00
2024-08-27 23:50:19 +02:00
```sh
git clone https://github.com/algora-io/tv.git; cd tv
```
2024-02-29 21:31:42 +02:00
2024-08-27 23:50:19 +02:00
2. Fetch dependencies
2024-02-29 21:31:42 +02:00
```sh
2024-08-27 23:50:19 +02:00
mix deps.get
2024-02-29 21:31:42 +02:00
```
2024-09-20 16:28:32 +02:00
**Note:** If you're using an Apple machine with an ARM-based chip, you need to install the Rust compiler and run `mix compile.rambo`
2024-08-27 23:50:19 +02:00
3. Initialize your `.env` file
2024-02-29 21:31:42 +02:00
```sh
2024-08-27 23:50:19 +02:00
cp .env.example .env
2024-02-29 21:31:42 +02:00
```
2024-08-27 23:50:19 +02:00
4. Create your database
2024-02-29 21:31:42 +02:00
```sh
2024-08-27 23:50:19 +02:00
sudo -u postgres psql
2024-02-29 21:31:42 +02:00
```
2024-08-27 23:50:19 +02:00
```sql
CREATE USER algora WITH PASSWORD 'password';
CREATE DATABASE tv;
GRANT ALL PRIVILEGES ON DATABASE tv TO algora;
```
5. Paste your connection string into your `.env` file
2024-02-29 21:31:42 +02:00
2024-08-27 23:50:19 +02:00
```env
DATABASE_URL="postgresql://algora:password@localhost:5432/tv"
```
2024-02-29 21:31:42 +02:00
2024-09-04 14:38:23 +02:00
6. Run migrations and seed your database
2024-02-29 21:31:42 +02:00
```sh
2024-08-27 23:50:19 +02:00
env $(cat .env | xargs -L 1) mix ecto.setup
2024-02-29 21:31:42 +02:00
```
2024-08-27 23:50:19 +02:00
7. Start your development server
2024-02-29 21:31:42 +02:00
```sh
env $(cat .env | xargs -L 1) iex -S mix phx.server
```
2024-08-27 23:50:19 +02:00
### Setting up external services
Some features of Algora TV rely on external services. If you're not planning on using these features, feel free to skip setting them up.
#### GitHub
GitHub is used for authenticating users.
[Create a GitHub OAuth app ](https://github.com/settings/applications/new ) and set
- Homepage URL: http://localhost:4000
- Authorization callback URL: http://localhost:4000/oauth/callbacks/github
Once you have obtained your client ID and secret, add them to your `.env` file.
```env
GITHUB_CLIENT_ID=""
GITHUB_CLIENT_SECRET="..."
```
#### Tigris
Tigris is used for storing and delivering livestreams and other media.
[Create a public Tigris bucket ](https://console.tigris.dev/ ) to obtain your secrets and add them to your `.env` file.
```env
AWS_ENDPOINT_URL_S3="https://fly.storage.tigris.dev"
AWS_REGION="auto"
AWS_ACCESS_KEY_ID="tid_..."
AWS_SECRET_ACCESS_KEY="tsec_..."
BUCKET_MEDIA="..."
```
2024-08-27 23:52:32 +02:00
<!-- ARCHITECTURE -->
## Architecture
### Overview
```mermaid
graph
Streamers{Streamers} --> Fly
Fly[Fly< br > Elixir App] --> RTMP
Fly --> Web[Phoenix< br > Web Server]
Fly --> Db[Fly< br > Postgres]
RTMP[Membrane< br > RTMP Server] -->|First mile delivery| Tigris[Tigris< br > Object Storage]
Viewers{Viewers} -->|Last mile delivery| Tigris
Viewers --> Fly
```
### Livestream pipeline
```mermaid
graph
Encoder{Encoder< br > e.g. OBS} -->|RTMP| Source[FLV Demuxer]
Source -->|video| H264Parser[H264 Parser]
Source -->|audio| AACParser[AAC Parser]
H264Parser --> H264Payloader[H264 Payloader]
AACParser --> AACPayloader[AAC Payloader]
H264Payloader --> CMAFMuxerVideo[CMAF Muxer]
AACPayloader --> CMAFMuxerAudio[CMAF Muxer]
CMAFMuxerVideo --> fMP4
CMAFMuxerAudio --> fMP4
fMP4[Fragmented MP4] -->|HLS| Tigris{Tigris Object Storage}
```
2024-02-29 21:31:42 +02:00
<!-- LICENSE -->
## License
Distributed under the [AGPLv3 License ](https://github.com/algora-io/tv/blob/main/LICENSE ). See `LICENSE` for more information.
<!-- ACKNOWLEDGEMENTS -->
## Acknowledgements
Special thanks to these amazing projects which help power Algora TV:
- [Tigris ](https://www.tigrisdata.com/ )
- [Fly.io ](https://fly.io/ )
- [Phoenix Framework ](https://www.phoenixframework.org/ )
- [Ecto ](https://github.com/elixir-ecto/ecto )
- [Membrane ](https://membrane.stream/ )
- [FFmpeg ](https://ffmpeg.org/ )
- [Tailwind CSS ](https://tailwindcss.com/ )