Giter VIP home page Giter VIP logo

overpass's Introduction

Overpass

Overpass makes it easy to host your own live streaming server with features such as authentication via Discord, stream playback in your web browser, and an easy way to archive your streams for your users to rewatch!

Overpass also lets you run a private instance for a users on a single Discord server. Simply add the server ID of your Discord server to the configuration file and Overpass will take care of the rest.

Powered by nginx-rtmp.

Notice

This project is no longer maintained and I encourage you to find an alternative. I had many ideas for Overpass but honestly could never be arsed to work on it again as it was just about good enough when it was in use.

Dependencies

Getting Started

Creating the Discord app for Overpass

Navigate to Discord's Developer Portal.

  • Select "New Application" in the top left corner
  • Choose a name for your application
  • Select the "OAuth2" tab
  • Find the "Client Information" section of the page, and copy your "Client ID" and your "Client Secret" and save these for use in the configuration file
  • Click "Add redirect" and type in a URI like so:

https://overpass.dev/auth/callback - replacing overpass.dev with your domain name.

Note: If you wish to develop on Overpass, you will have to add http://localhost:5000/auth/callback to your list of redirect URIs.

Install

Docker Usage

There is a Docker image for Overpass, which you can either build yourself with the Dockerfile, or download from the Docker Hub.

This image is pre-configured to run Overpass in production mode with Gunicorn, so if you wish to develop on Overpass, you may need to change docker/startup.sh to execute flask run, and modifying the route to Overpass' API in the nginx configuration.

Continue reading if you wish to run Overpass on bare-metal, otherwise, you can use the example Docker Compose file.

Creating a config file

Note: If you are using Docker, set these values as environment variables. See the example Docker Compose file. You will not have to create the .env file.

Generate a secret key

Run python -c "import os; print(os.urandom(16))" and copy the output after the byte symbol into OVERPASS_SECRET_KEY

Create an empty .env file, in the projects' root directory which contains the following:

DISCORD_CLIENT_ID =
DISCORD_CLIENT_SECRET = ""
DISCORD_REDIRECT_URI = ""
DISCORD_GUILD_ID = (if you want to restrict access to the tool to users from a certain guild ID - set one here)


OVERPASS_SECRET_KEY = "your generated key here"

HLS_PATH = ""
REC_PATH = ""
RTMP_SERVER = (IP address and port of your RTMP server - as a string)

Example config

DISCORD_CLIENT_ID = 31040105101013151
DISCORD_CLIENT_SECRET = "1251XXXXXXXXXXXXXXXXXXXXX"
DISCORD_REDIRECT_URI = "https://overpass.dev/auth/callback"
DISCORD_GUILD_ID = 05105010105619519

OVERPASS_SECRET_KEY = "#\x1an\x1an\x1an\x1an\x1an"

HLS_PATH = "/storage/overpass/hls"
REC_PATH = "/storage/overpass/archive"

RTMP_SERVER = "overpass.dev:1935/live"

Streaming server setup

  • Create the directories you defined in HLS_PATH and REC_PATH and make sure to give www-data write permissions to said folder.

Make sure the user the Overpass is running as also has read and write access to the same folders.

Remember to change the on_publish and on_done URIs, record_path and hls_path variables to match your environment

Edit your nginx.conf file to contain the following information.

rtmp {
    server {
        listen 1935;
        on_publish http://127.0.0.1:5000/api/rtmp/connect;
        on_done http://127.0.0.1:5000/api/rtmp/done;

        application live {
            deny play all;
            live on;
            record all;
            record_path /storage/overpass/archive;
            record_append on;

            hls on;
            hls_path /storage/overpass/hls;
            hls_fragment 2;
            hls_playlist_length 10;
            exec_record_done bash -c "/usr/bin/ffmpeg -i $path -acodec copy -vcodec copy -movflags +faststart /your/recording/path/$basename.mp4 && rm $path";
         }
    }
}

Running the application

  • Run flask init-db to initialize the database.

Development mode

  • Run flask run

Deploying to production

In the same folder as Overpass, while in a virtual environment, run the following command:

gunicorn -w 10 app:app --timeout 600 --log-level=debug --access-logformat "%({X-Real-IP}i)s %(l)s %(t)s %(b)s '%(f)s' '%(a)s'" --access-logfile '-'

NGINX setup

location / {
    proxy_pass http://127.0.0.1:8000;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
}

Screenshots

Homepage Web Player Archive Profile Page

overpass's People

Contributors

goats2k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

overpass's Issues

Archive: Save filenames only

We should only save filenames to be able to allow for more portability in case the user wants to move the archive elsewhere.

HLS: Re-write playlist generator

The current playlist re-writing function is quite inefficient as it runs on every GET /hls/<unique_id>/index.m3u8, instead of updating whenever the last chunk is out of date. This doesn't scale well with many concurrent viewers.

Docker image for linux/amd64?

Hi, I was curious if it'd be possible to get a docker image built for linux/amd64?

I've been interested in running this project for a few days and finally got around to attempting to get it running only to find out Docker images intended for armv7 cannot be ran on amd64 platforms.

I'm not experienced with Docker by any means so maybe im missing something super obvious so im kind of stuck unless I attempt to build manually.

Thanks and I hope to see this project grow.

Add unit tests to code base

I wanted to more leave this as a discussion, but I think some unit tests would make your code base much easier to ensure that a change doesn't break everything.

Admin panel

An admin panel should have the following features:

  • Manage users (list / update / ban)
  • Manage streams from all users (add or remove from the archive)
  • Get user role from discord server if environment variable is set

Internal Server Error after Manual Setup.

Getting this after Discord Auth:

Screenshot_2021-12-18_13-33-48

This is in the terminal:

^Cilfs@ilfsZ:~/overpass$ flask run
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [18/Dec/2021 13:34:25] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [18/Dec/2021 13:34:27] "GET /auth/login/ HTTP/1.1" 302 -
127.0.0.1 - - [18/Dec/2021 13:34:30] "GET /auth/callback?code=fnL7Nt63FT7glFebNGksKvDdk7eMhh&state=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfX3N0YXRlX3NlY3JldF8iOiIycTA1OURKejNhQjFzUkp0Z2pGNm1OeFc1ZFRRb3oifQ.clrqRbaC1UR1UUaX5G6z4V3aNzKKeD0Yzl589Y2OPeg HTTP/1.1" 308 -
Exception on /auth/callback/ [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/ilfs/overpass/overpass/routes/auth.py", line 47, in callback
    discord.callback()
  File "/usr/local/lib/python3.8/dist-packages/flask_discord/client.py", line 157, in callback
    token = self._fetch_token(state)
  File "/usr/local/lib/python3.8/dist-packages/flask_discord/_http.py", line 93, in _fetch_token
    return discord.fetch_token(
  File "/usr/local/lib/python3.8/dist-packages/requests_oauthlib/oauth2_session.py", line 239, in fetch_token
    self._client.parse_request_uri_response(
  File "/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/clients/web_application.py", line 203, in parse_request_uri_response
    response = parse_authorization_code_response(uri, state=state)
  File "/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/parameters.py", line 268, in parse_authorization_code_response
    raise MismatchingStateError()
oauthlib.oauth2.rfc6749.errors.MismatchingStateError: (mismatching_state) CSRF Warning! State not equal in request and response.
127.0.0.1 - - [18/Dec/2021 13:34:30] "GET /auth/callback/?code=fnL7Nt63FT7glFebNGksKvDdk7eMhh&state=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfX3N0YXRlX3NlY3JldF8iOiIycTA1OURKejNhQjFzUkp0Z2pGNm1OeFc1ZFRRb3oifQ.clrqRbaC1UR1UUaX5G6z4V3aNzKKeD0Yzl589Y2OPeg HTTP/1.1" 500 -

Here is the .env file

Screenshot_2021-12-18_13-37-59

Any idea how to resolve this.

Handle usernames with special characters

Discord usernames can contain pretty much any unicode character, which is a problem for Overpass when it comes to displaying streams.

Problem

Currently, stream URLs look something like this /watch/<username>
This can potentially become a problem if the username looks something like "Example / User", the problems it introduces are:

  • Unless the slashes are escaped by the browser, the stream will simply not work.
  • The URL becomes harder for the user to type, if they just want to watch a user when they're live.

Potential solutions

  • Force every user to create a "display name" and make sure the name only contains letters, numbers and simple symbols.
  • Generate a display name based on their username on the server side.

Refactor database design

  • Use an ORM
  • Refactor database table (user_id instead of user_snowflake in `streams`` for example)
  • Set up some sort of migrations system

Archive: Pagination

Once the archive gets a bit fuller, we'll need some sort of pagination mechanism.

Write tests

This should've probably been done a long time ago...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.