{"id":26058928,"url":"https://github.com/agustinsrg/rtmp-server-rs","last_synced_at":"2026-06-10T07:31:10.772Z","repository":{"id":278917508,"uuid":"921913882","full_name":"AgustinSRG/rtmp-server-rs","owner":"AgustinSRG","description":"RTMP server implemented in Rust","archived":false,"fork":false,"pushed_at":"2026-04-26T13:15:42.000Z","size":384,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-26T15:09:32.034Z","etag":null,"topics":["media","rtmp","rtmp-server","rust","streaming"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AgustinSRG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-24T21:25:00.000Z","updated_at":"2026-04-26T13:12:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"12fb2fa7-25e6-43a2-a1b5-15be85ea8cac","html_url":"https://github.com/AgustinSRG/rtmp-server-rs","commit_stats":null,"previous_names":["agustinsrg/rtmp-server-rs"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/AgustinSRG/rtmp-server-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Frtmp-server-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Frtmp-server-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Frtmp-server-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Frtmp-server-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AgustinSRG","download_url":"https://codeload.github.com/AgustinSRG/rtmp-server-rs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Frtmp-server-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34142637,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["media","rtmp","rtmp-server","rust","streaming"],"created_at":"2025-03-08T12:41:01.363Z","updated_at":"2026-06-10T07:31:10.767Z","avatar_url":"https://github.com/AgustinSRG.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RTMP Server (Rust Implementation)\n\n[![Rust](https://github.com/AgustinSRG/rtmp-server-rs/actions/workflows/rust.yml/badge.svg)](https://github.com/AgustinSRG/rtmp-server-rs/actions/workflows/rust.yml)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](./LICENSE)\n\nThis is a RTMP (Real Time Messaging Protocol) server for live streaming broadcasting, implemented in [Rust](https://www.rust-lang.org/).\n\nThis is a rewrite of [RTMP Server (Go Implementation)](https://github.com/AgustinSRG/rtmp-server).\n\nThis version's main goal is performance and efficiency:\n\n- Lower memory usage\n- Lower CPU usage\n- Greater bit rate\n\n## Compilation\n\nIn order to compile the project, run the following command:\n\n```sh\ncargo build --release\n```\n\nAn executable binary will be generated in the `target/release` folder, called called `rtmp-server`, or `rtmp-server.exe` if you are using Windows.\n\n## Docker image\n\nYou can find the docker image for this project available in Docker Hub: [https://hub.docker.com/r/asanrom/rtmp-server-rs](https://hub.docker.com/r/asanrom/rtmp-server-rs)\n\nTo pull it type:\n\n```\ndocker pull asanrom/rtmp-server-rs\n```\n\nExample compose file:\n\n```yml\nversion: \"3.7\"\n\nservices:\n  rtmp_server:\n    image: asanrom/rtmp-server-rs\n    ports:\n      - \"1935:1935\"\n      #- '443:443'\n    environment:\n      # Configure it using env vars:\n      - PLAY_ALLOWED_FROM=*\n      - CONCURRENT_LIMIT_WHITELIST=*\n      - REDIS_USE=NO\n      - LOG_REQUESTS=YES\n      - LOG_DEBUG=NO\n      - GOP_CACHE_SIZE_MB=0\n```\n\n## Usage\n\nIn order to run the server you have to run the binary or the docker container. That will run the server in the port `1935`.\n\nThe server will accept RTMP connections with the following schema:\n\n```\nrtmp://{HOST}/{CHANNEL}/{KEY}\n```\n\nNote: Both `CHANNEL` and `KEY` are restricted to letters `a-z`, numbers `0-9`, dashes `-` and underscores `_`.\n\nBy default, it will accept any connections. If you need to restrict the access or customize the server in any way, you can use environment variables.\n\n### RTMP play restrict\n\nYou probably only want external users to be able to publish to the RTMP server, since spectators probably receive the stream using other protocol, like HLS or MPEG-Dash.\n\nIn order to do that, set the `RTMP_PLAY_WHITELIST` to a list of allowed internet addresses split by commas. Example: `127.0.0.1,10.0.0.0/8`. You can set IPs, or subnets. It supports both IP version 4 and version 6.\n\n### Event callback\n\nIn order to restrict the access and have control over who publishes, the RTMP server can send requests to a remote server with the information of certain events.\n\nSet the `CALLBACK_URL` environment variable to the remote server that is going to handle those events:\n\n- When an user wants to publish, to validate the streaming channel and key. (`start`)\n- When a session is closed, meaning the live streaming has ended. (`stop`)\n\nThe events are sent as HTTP(S) **POST** requests to the given URL, with empty body, and with a header with name `rtmp-event`, containing the event data encoded as a **Base 64 JWT (JSON Web Token)**, signed using a secret you must provide using the `JWT_SECRET` environment variable.\n\nThe JWT is signed using the algorithm `HMAC_256`.\n\nThe JWT contains the following fields:\n\n- Subject (`sub`) is `rtmp_event`.\n- Event name (`event`) can be `start` or `stop`.\n- Channel (`channel`) is the requested channel to publish.\n- Key (`key`) is the given key to publish.\n- Stream ID (`stream_id`) is the unique ID for the stream session, It is undefined for the `start` event, since is not known yet.\n- Client IP (`client_ip`) is the client IP for logging purposes.\n\nFor the `start` event, the event handler server must return with status code **200**, and with a header with name `stream-id`, containing the unique identifier for the RTMP publishing session. If the server does not return with 200, the server will consider the key is invalid and it will close the connection with the client. You can use this to validate streaming keys.\n\n### Redis\n\nThis server supports listening for commands using Redis Pub/Sub.\n\nTo configure it, set the following variables:\n\n| Variable Name  | Description                                                         |\n| -------------- | ------------------------------------------------------------------- |\n| REDIS_USE      | Set it to `YES` in order to enable Redis.                           |\n| REDIS_PORT     | Port to connect to Redis Pub/Sub. Default is `6379`                 |\n| REDIS_HOST     | Host to connect to Redis Pub/Sub. Default is `127.0.0.1`            |\n| REDIS_PASSWORD | Redis authentication password, if required.                         |\n| REDIS_CHANNEL  | Redis channel to listen for commands. By default is `rtmp_commands` |\n| REDIS_TLS      | Set it to `YES` in order to use TLS for the connection.             |\n\nThe commands have the following structure:\n\n```\nCOMMAND\u003eARG_1|ARG2|...\n```\n\nEach command goes in a separate message.\n\nList of commands:\n\n- `kill-session\u003eCHANNEL` - Closes any sessions for that specific channel.\n- `close-stream\u003eCHANNEL|STREAM_ID` - Closes specific connection.\n\nThese commands are meant to stop a streaming session once started, to enforce application-specific limits.\n\n### Control server\n\nIn order to integrate this RTMP server with [tcp-video-streaming](https://github.com/AgustinSRG/tcp-video-streaming)'s control server, set `CONTROL_USE` to `YES`.\n\nAlso, configure the following variables:\n\n| Variable Name    | Description                                                                                  |\n| ---------------- | -------------------------------------------------------------------------------------------- |\n| CONTROL_BASE_URL | Websocket URL to connect to the coordinator server. Example: `wss://10.0.0.0:8080/`          |\n| CONTROL_SECRET   | Secret shared between the coordinator server and the RTMP server, in order to authenticate.  |\n| EXTERNAL_IP      | IP address of the RTMP server in order to indicate it to the coordinator server              |\n| EXTERNAL_PORT    | Listening port of the RTMP server in order to indicate it to the coordinator server          |\n| EXTERNAL_SSL     | Set it to `YES` if the rest of components will need to use SSL to connect to the RTMP server |\n\nNote: Enabling the control server will disable the callback request feature, replacing it with requests to the control server instead.\n\n### TLS\n\nIf you want to use TLS, you have to set the following variables in order for it to work:\n\n| Variable Name            | Description                                                                         |\n| ------------------------ | ----------------------------------------------------------------------------------- |\n| SSL_PORT                 | RTMPS (RTMP over TLS) listening port. Default is `443`                              |\n| SSL_CERT                 | Path to SSL certificate (REQUIRED).                                                 |\n| SSL_KEY                  | Path to SSL private key (REQUIRED).                                                 |\n| SSL_CHECK_RELOAD_SECONDS | Number of seconds to check for changes in the certificate or key (for auto renewal) |\n\n### Log options\n\nHere is a list of options to customize log messages:\n\n| Variable Name | Description                                                                                                    |\n| ------------- | -------------------------------------------------------------------------------------------------------------- |\n| LOG_ERROR     | Log error messages? Set to `YES` or `NO`. By default is `YES`                                                  |\n| LOG_WARNING   | Log warning messages? Set to `YES` or `NO`. By default is `YES`                                                |\n| LOG_INFO      | Log info messages? Set to `YES` or `NO`. By default is `YES`                                                   |\n| LOG_REQUESTS  | Log incoming requests? Set to `YES` or `NO`. By default is `YES`. Note: requests are logged with info messages |\n| LOG_DEBUG     | Log debug messages? Set to `YES` or `NO`. By default is `NO`                                                   |\n| LOG_TRACE     | Log trace messages? Set to `YES` or `NO`. By default, it uses the value of `LOG_DEBUG`                         |\n\n### DOS mitigation options\n\nList of options made to mitigate DOS (Denial of Service) attacks.\n\n| Variable Name                 | Description                                                                                                                        |\n| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |\n| MAX_IP_CONCURRENT_CONNECTIONS | Max number of concurrent connections to accept from a single IP. By default is 4.                                                  |\n| CONCURRENT_LIMIT_WHITELIST    | List of IP ranges not affected by the max number of concurrent connections limit. Split by commas. Example: `127.0.0.1,10.0.0.0/8` |\n\n### Performance options\n\nList of options related to performance.\n\n| Variable Name     | Description                                                                                     |\n| ----------------- | ----------------------------------------------------------------------------------------------- |\n| RTMP_CHUNK_SIZE   | RTMP Chunk size in bytes. Default is `4096`                                                     |\n| GOP_CACHE_SIZE_MB | Size limit in megabytes of packet cache. By default is `256`. Set it to `0` to disable cache    |\n| MSG_BUFFER_SIZE   | Size of the message buffer. Default: `8`. Lower it to reduce memory usage at a cost of bit rate |\n\n### More options\n\nHere is a list with more options you can configure:\n\n| Variable Name               | Description                                                                                                                                           |\n| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |\n| RTMP_HOST                   | RTMP host to add in the JWT as `rtmp_host` in order for the callback handler to know the origin host.                                                 |\n| RTMP_PORT                   | RTMP listening port. It will be added in the JWT as `rtmp_port`. Default is `1935`.                                                                   |\n| BIND_ADDRESS                | Bind address for RTMP and RTMPS. By default it binds to all network interfaces.                                                                       |\n| ID_MAX_LENGTH               | Max length for `CHANNEL` and `KEY`. By default is 128 characters                                                                                      |\n| ID_ALLOW_EMPTY              | Allow `CHANNEL` or `KEY` to be empty strings?. Set to `YES` or `NO`. Default: `NO`                                                                    |\n| ID_ALLOW_SPECIAL_CHARACTERS | Allow special characters for `CHANNEL` or `KEY`?. Set to `YES` or `NO`. Default: `NO`. Note: Some characters will be still forbidden: `\u003e`, `\\n`, `\\|` |\n| CUSTOM_JWT_SUBJECT          | Custom subject to use for tokens sent to the callback URL                                                                                             |\n\n## Testing\n\nIn order to run the unit tests, type:\n\n```sh\ncargo test\n```\n\nIf you wish to test the server against a well-known client, you can use [FFmpeg](https://www.ffmpeg.org/) as the client.\n\nIn order to publish, run a command like this (replace the video file and the RTMP URL):\n\n```sh\nffmpeg -re -stream_loop -1 -i video.mp4 -c:v copy -c:a copy -f flv rtmp://127.0.0.1/channel/key\n```\n\nIn order to play, run a command like this:\n\n```sh\nffplay rtmp://127.0.0.1/channel/key\n```\n\n## Benchmark\n\nThis repository also contains a [benchmark script](./benchmark) you can use to compare performances between versions.\n\n## License\n\nThis project is under the [MIT license](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagustinsrg%2Frtmp-server-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagustinsrg%2Frtmp-server-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagustinsrg%2Frtmp-server-rs/lists"}