{"id":13583677,"url":"https://github.com/jwerle/rtmp-swarm","last_synced_at":"2025-04-22T21:43:54.303Z","repository":{"id":143907125,"uuid":"127364908","full_name":"jwerle/rtmp-swarm","owner":"jwerle","description":"Publish, consume, and discover RTMP streams in a network swarm","archived":false,"fork":false,"pushed_at":"2019-03-08T21:57:58.000Z","size":14,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-21T11:18:20.759Z","etag":null,"topics":["decentralized","dht","distributed","dns","network","rtmp","rtmp-server"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/jwerle.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}},"created_at":"2018-03-30T01:21:14.000Z","updated_at":"2020-10-21T14:48:50.000Z","dependencies_parsed_at":"2024-01-24T13:06:10.817Z","dependency_job_id":null,"html_url":"https://github.com/jwerle/rtmp-swarm","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Frtmp-swarm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Frtmp-swarm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Frtmp-swarm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwerle%2Frtmp-swarm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwerle","download_url":"https://codeload.github.com/jwerle/rtmp-swarm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250330379,"owners_count":21412974,"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":["decentralized","dht","distributed","dns","network","rtmp","rtmp-server"],"created_at":"2024-08-01T15:03:41.543Z","updated_at":"2025-04-22T21:43:54.282Z","avatar_url":"https://github.com/jwerle.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"rtmp-swarm\n==========\n\nPublish, consume, and discover RTMP streams in a network swarm.\n\n## Install\n\n```sh\n$ npm install rtmp-swarm\n```\n\n## Example\n\nStart a RTMP network daemon belonging to a network swarm specified\nby a key.\n\n```js\nconst discovery = require('./')\n\nconst port = process.argv[2] || 0\nconst key = process.argv[3] || 'rtmp-swarm'\n\nconst node = discovery()\n\nnode.join(key).listen(port)\n\nnode.on('listening', () =\u003e {\n  const { port } = node.address()\n  console.log(\"onlistening: rtmp://localhost:%s/%s\", port, key)\n})\n\nnode.on('peer', (peer) =\u003e {\n  console.log('onpeer:', peer);\n})\n\nnode.on('connection', () =\u003e {\n  console.log('onconnection');\n})\n```\n\nPublish video on demand with `ffmpeg` to the rtmp endpoint logged above:\n\n```sh\n$ ffmpeg -re -i 2k.mp4 \\\n  -c:v libx264 \\\n  -c:a aac \\\n  -preset superfast \\\n  -tune zerolatency \\\n  -ar 44100 \\\n  -f flv 'rtmp://localhost:40523/rtmp-stream'\n```\n\nStart another network swarm with the same key, but with a different\nport and then access the stream with `mpv` or `ffplay`:\n\n```sh\n$ mpv 'rtmp://localhost:42583/rtmp-stream'\n```\n\n## API\n\n### `const swarm = discovery(opts)`\n\nwhere `opts` is\n\n```js\n{\n  id: cuid(), // id for this peer\n  net: require('net') // network interface\n  maxConnections: 0, // max peering connections\n}\n```\n\nwhich are passed directly to\n[discovery-channel](https://github.com/maxogden/discovery-channel).\n\n### `swarm.address()`\n\nReturns the server address of this network swarm.\n\n### `swarm.listen(port, address, cb)`\n\nBind a RTMP server to an optionally specified port and address. Will\ncall `cb(err)` when listening.\n\n### `swarm.join(key, cb)`\n\nJoin a network swarm by key. Will call `cb(err)` after joining.\n\n### `swarm.destroy(cb)`\n### `swarm.close(cb)`\n\nClose and destroy the network swarm.\n\n## Command Line Usage\n\n```sh\nusage: rtmp-stream [-hV] [--help] [--version]\n                   [-k|--key|--key=\u003ckey\u003e]\n\noptions:\n  -k, --key=\u003ckey\u003e  Discovery key for this RTMP stream.\n  -V, --version    Output program version.\n  -h, --help       Show this message.\n\n```\n\nIf you do not specify a `key`, one will be generated for you.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwerle%2Frtmp-swarm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwerle%2Frtmp-swarm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwerle%2Frtmp-swarm/lists"}