{"id":20254652,"url":"https://github.com/shocknet/seed","last_synced_at":"2025-04-11T00:03:42.159Z","repository":{"id":37072306,"uuid":"268567133","full_name":"shocknet/seed","owner":"shocknet","description":"Simple WebTorrent and Livestreaming seed service","archived":false,"fork":false,"pushed_at":"2023-03-06T21:58:22.000Z","size":758,"stargazers_count":9,"open_issues_count":27,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T00:03:31.373Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shocknet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["shocknet"]}},"created_at":"2020-06-01T15:57:17.000Z","updated_at":"2024-10-08T17:35:29.000Z","dependencies_parsed_at":"2024-11-14T10:44:41.044Z","dependency_job_id":null,"html_url":"https://github.com/shocknet/seed","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shocknet%2Fseed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shocknet%2Fseed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shocknet%2Fseed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shocknet%2Fseed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shocknet","download_url":"https://codeload.github.com/shocknet/seed/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317705,"owners_count":21083528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T10:34:16.697Z","updated_at":"2025-04-11T00:03:42.140Z","avatar_url":"https://github.com/shocknet.png","language":"TypeScript","funding_links":["https://github.com/sponsors/shocknet"],"categories":[],"sub_categories":[],"readme":"# Shock Seed\n\n---\n\nA simple cross platform NodeJS service that lets your users upload files to torrent and also\nshare live streams using RTMP or RTSP and supports different output formats including\nHLS/DASH/MP4/H.264/H.265/AAC/OPUS\n\nTable of Content:\n\n- [Installation](#installation)\n  - [Docker Container](#docker-container)\n- [Configuration](#configuration)\n- - [Configure Web Server](#configure-web-server)\n- - - [Caddy One-Liner](#Caddy-One-Liner)\n- - - [Full Caddy Config](#full-caddy-config)\n- [Tests](#tests)\n  - [Tests Configuration](#tests-configuration)\n  - [Run Tests](#run-tests)\n- [Routes](#routes)\n  - [Enroll token](#enroll-token)\n  - [Upload files](#upload-files)\n  - [Files info](#files-info)\n- [Streaming](#streaming)\n  - [Publish Stream using FFMPEG](#publish-stream-using-ffmpeg)\n  - [Publish Stream using OBS](#publish-stream-using-obs)\n  - [Fetching Live Stream](#fetching-live-stream)\n\n## Installation\n\n---\n\n1. Clone and install:\n\n```bash\n$ git clone git@github.com:shocknet/seed.git\n$ cd seed\n$ mv env.example .env\n$ yarn install\n```\n\n2. Required configuration variables are specified in the example file.\n\n```bash\n$ nano .env\n```\n\n3. Run the server by using the `start` script:\n\n```bash\n$ yarn start\n```\n\n### Docker Container\n\nThere's a `Dockerfile` available at the root of the project which you can use to build an image and run the server inside a isolated container.\n\n```bash\n$ docker build -t shocknet/seed:v0.0.1 .\n```\n\n## Configuration\n\n---\n\n1. **WebTorrent Trackers:**  \n   The `TRACKERS` environment variable can be used to specify custom web torrent trackers for the generated `.torrent` files.  \n    **Format:** An array of arrays of strings. More information available at [bep12](http://www.bittorrent.org/beps/bep_0012.html)  \n    **Default Value:** see `bittorrent-tracker`\n\n2. **WebSeed URLs:**  \n   The `WEBSEED_URL` environment variable can be used to specefiy an array of URIs for `.torrent` files' webseed.  \n   Check the [Full Caddy Config](#full-caddy-config) section to learn more about how to configure a file server to use as WebSeed.   \n   **Format:** An array of strings. More information available at [bep19](http://www.bittorrent.org/beps/bep_0019.html)    \n   **Example:** \"https://example.com\"\n\n3. **Database:**  \n   This projects supports both `sqlite` and `postgres` databases. Database configuration fields are available in `.env.example` file.  \n   **Default:** `sqlite` is the default database and its file is located on projects root by default. Default value for `SQLITE_DB` is `PROJECT_ROOT/database.sqlite`.\n\n4. **File Storage:**  \n   Currently only storing files on the local storage is available. The provided keys for configruing file storage are `STORAGE_TYPE` and `STORAGE_PATH`.  \n   **Default:**  \n   `STORAGE_TYPE` = `local`  \n   `STORAGE_PATH` = `/tmp/seed-uploads`\n\n### Configure Web Server\nShockSeed provides both torrent file and streaming options and you can either configure a simple web server to serve the torrent API and files, or also configure the web server to serve streaming API and outputs.\n\n#### Caddy One-Liner\nThis One-Liner starts Caddy with a Reverse-Proxy to serve the ShockSeed API and also a file server for torrents.\n\n**Important:** Please remember that this method requires domain's public A/AAAA DNS records pointed at your machine. We recommend running Caddy using a Caddyfile for more control over the service.\n\n```\ncaddy reverse-proxy --from example.com --to localhost:3000 file-server --domain example.com\n```\n\n#### Full Caddy Config\nFirst store this configuration in a file like `/etc/caddy/Caddyfile` and then pass the config to Caddy according to your installation method.   \nThis configuration setups both streaming and torrent APIs but the one-liner is only for torrents.\n\n```\nexample.com {\n  root * /usr/share/caddy\n\n  header {\n    Access-Control-Allow-Origin \"*\"\n    Access-Control-Allow-Methods \"POST, GET, OPTIONS, PUT, DELETE\"\n    Access-Control-Allow-Headers \"Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, Range, User-Agent\"\n  }\n\n  handle /rtmpapi/* {\n    uri strip_prefix /rtmpapi\n    reverse_proxy localhost:8000\n  }\n\n  handle /websocket/* {\n    uri strip_prefix /websocket\n    reverse_proxy localhost:3005\n  }\n\n  handle /api/* {\n    reverse_proxy localhost:3000\n  }\n\n  handle {\n    file_server browse\n  }\n\n  log {\n    output file /var/log/caddy/access.log\n  }\n}\n```\n\nNote: The last `handle` block in this Caddyfile is responsible for serving `.torrent` files aka WebSeed URIs.\nAlso if you want streaming enabled, make sure you've set the `/websocket/*` and `/rtmpapi/*` blocks and their prefix trimmer.\n\n## Tests\n\n---\n\n### Tests Configuration\n\nTests are located under the `src/tests` directory and they use the `.env.test` file for fetching the configuration. Test configuration keys are same as the main `.env.example` file but keep in mind, if you don't provide a `.env.test` file, `.env` would be used instead.\n\n### Run Tests\n\nThis projects uses [Avajs](https://avajs.dev) for running the test and you can use the `test` script to run the tests via `ava`:\n\n```bash\n$ yarn test\n```\n\n## Routes\n\n---\n\n### Enroll token\n\nMethod: `POST`\nEndpoint: `/api/enroll_token`\nRequired Headers:\n\n```\nContent-Type: application/json\n```\n\nBody:\n\n```json\n{\n  \"seed_token\": \"Should match ENROLL_TOKEN env\",\n  \"wallet_token\": \"Token purchased by user\"\n}\n```\n\n---\n\n### Upload files\n\nMethod: `POST`\nEndpoint: `/api/put_file`\nRequired Headers:\n\n```\nContent-Type: application/json\nAuthorization: `Bearer {Enrolled token}`\n```\n\nBody:\nFile upload uses multipart format and files should use the `files` key in request.\nAdditional data:\n\n```json\n{\n  \"comment\": \".torrent file comment\",\n  \"info\": {\n    \"additional\": \"Use object-like format for additional info for .torrent file\"\n  }\n}\n```\n\n---\n\n### Files info\n\nEndpoint: `/api/{HASH}/info`\nRequired Headers:\n\n```\nNull\n```\n\nRequest Params:\n\n`{HASH}`: Provided in the response of file upload request.\n\n## Streaming\n\nStreams are published to the server through the RTMP protocol, so you can use\neither OBS, ffmpeg or other tools to push your stream to the server.\n\n### Publish Stream using FFMPEG\n\nFor a H.264 video and AAC audio use:\n\n```\nffmpeg -re -i FILE_NAME -c copy -f flv rtmp://localhost/live/STREAM_NAME\n```\n\nFor other audio or video formats use:\n\n```\nffmpeg -re -i FILE_NAME -c:v libx264 -preset veryfast -tune zerolatency -c:a aac -ar 44100 -f flv rtmp://localhost/live/STREAM_NAME\n```\n\n### Publish Stream using OBS\n\nUsing the **Settings** menu open the **Stream** tab and fill the values according\nto your config. Like:\n\nStream Type: Custom Streaming Server\n\nURL: rtmp://localhost/live\n\nStream key: STREAM_NAME\n\n### Fetching Live Stream\n\nThere are different formats that you can use to fetch the stream output. Here\nis a list of available URLs:\n\nHLS\n`http://localhost:8000/live/STREAM/index.m3u8`\n\nDASH\n`http://localhost:8000/live/STREAM/index.mpd`\n\nRTMP\n`rtmp://localhost/live/STREAM`\n\nhttp-flv\n`http://localhost:8000/live/STREAM.flv`\n\nwebsocket-flv\n`ws://localhost:8000/live/STREAM.flv`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshocknet%2Fseed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshocknet%2Fseed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshocknet%2Fseed/lists"}