├── .gitignore ├── rtmp_server.js ├── dns_server.js ├── package.json ├── web_server.js ├── index.js └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | config.js 3 | .scsrrc -------------------------------------------------------------------------------- /rtmp_server.js: -------------------------------------------------------------------------------- 1 | module.exports = function (config) { 2 | const { NodeMediaServer } = require('node-media-server'); 3 | var nmcs = new NodeMediaServer(config) 4 | nmcs.run(); 5 | } 6 | 7 | 8 | -------------------------------------------------------------------------------- /dns_server.js: -------------------------------------------------------------------------------- 1 | module.exports = function (config) { 2 | process.env['dnsproxy_logging'] = 'dnsproxy:info'; 3 | process.env['dnsproxy_host'] = config.external_ip; 4 | process.env['dnsproxy_reload_config'] = false; 5 | process.env['dnsproxy_domains__api.ustream.tv'] = config.external_ip; 6 | require('dns-proxy'); 7 | } 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sony-cameras-stream-receiver", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "MIT", 11 | "dependencies": { 12 | "dns-proxy": "^0.6.2", 13 | "node-media-server": "git://github.com/LucaLanziani/Node-Media-Server.git#feature/fdr-x3000-hack" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /web_server.js: -------------------------------------------------------------------------------- 1 | module.exports = function (config) { 2 | const http = require('http'); 3 | const channel_numbers = [config.channel_number]; 4 | const port = config.port; 5 | const hostname = config.hostname; 6 | 7 | let channels = {} 8 | channel_numbers.forEach((channel) => { 9 | channels[channel] = { 10 | broadcast_urls: [ 11 | `rtmp:\/\/api.ustream.tv\/${channel}` 12 | ] 13 | } 14 | }) 15 | 16 | const server = http.createServer((req, res) => { 17 | res.statusCode = 200; 18 | res.setHeader('Content-type', 'application/json'); 19 | res.end(JSON.stringify({channels: channels})); 20 | }); 21 | 22 | server.listen(port, hostname, () => { 23 | console.log(`Server listening at http://${hostname}:${port}/`); 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const rc = require('rc'); 2 | let config = rc('scsr', { 3 | web: { 4 | hostname: '0.0.0.0', 5 | port: 80, 6 | channel_number: null 7 | }, 8 | dns: { 9 | external_ip: null 10 | }, 11 | node_media_server: { 12 | rtmp: { 13 | port: 1935, 14 | chunk_size: 60000, 15 | gop_cache: true, 16 | ping: 10, 17 | ping_timeout: 30 18 | } 19 | } 20 | }); 21 | 22 | 23 | if (!config.dns.external_ip) { 24 | const os = require( 'os' ); 25 | var networkInterfaces = os.networkInterfaces( ); 26 | console.log(` 27 | If you want the dns module to work select one of the following addressess and use 28 | --dns.external_ip=
`); 29 | 30 | Object.keys(networkInterfaces).forEach(interface => { 31 | networkInterfaces[interface].forEach(addresses => { 32 | console.log(`\t${interface} => ${addresses.address}`); 33 | }) 34 | }); 35 | console.log(); 36 | } 37 | 38 | if (!config.web.channel_number) { 39 | console.log(` 40 | Missing param --web.channel_number= 41 | Check the README.md to set get the right value. 42 | `) 43 | process.exit(1); 44 | } 45 | 46 | 47 | if (config.web.channel_number) {require('./web_server')(config.web)}; 48 | if (config.dns.external_ip) { require('./dns_server')(config.dns) }; 49 | require('./rtmp_server')(config.node_media_server); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Sony Cameras Stream Receiver 3 | 4 | How to receive the sony cameras stream directly locally in your computer. 5 | 6 | The software creates a rtmp server and shows the streams in the address command line 7 | 8 | You can consume the stream with any software that supports rtmp connecting to: 9 | 10 | ``` 11 | rtmp://127.0.0.1//broadcaster/live 12 | ``` 13 | 14 | **channel_number**: you can find the instructions to find the channel_number below 15 | 16 | **live_number**: The application will write this once the camera starts streaming 17 | 18 | eg: 19 | ``` 20 | 2018-11-3 23:06:02 5092 [INFO] [rtmp publish] New stream. id=... streamPath=//broadcaster/live2744 streamId=1 21 | ``` 22 | 23 | # Run the application 24 | 25 | ``` 26 | npm i 27 | sudo node ./index.js --web.channel_number= --dns.external_ip= 28 | ``` 29 | 30 | # Prerequisites 31 | 32 | ## Channel number 33 | 34 | Ustream channel number should be passed when starting the software with `--web.channel_number=` 35 | 36 | To get the channel number visit https://www.ustream.tv/dashboard/manage-show/ and, after login, 37 | you'll see the channel number at the end of the url: 38 | 39 | eg. https://www.ustream.tv/dashboard/manage-show/12345678 40 | 41 | ## DNS spoofing 42 | 43 | You need to redirect all request to `api.ustream.tv` to your computer, the module can do the job for you but it needs help. 44 | 45 | 1. use the `--dns.external_ip=
` command line option (address should be the IP of your computer in the local network) 46 | 2. set your router to use your local computer as dns server 47 | 48 | # Persist configuration 49 | 50 | The configuration can be persisted creating a `.scsrrc` file in the local directory containing: 51 | 52 | ``` 53 | { 54 | "web": { 55 | "channel_number": 56 | }, 57 | "dns": { 58 | "external_ip": "external_ip" 59 | } 60 | } 61 | ``` 62 | 63 | test 64 | --------------------------------------------------------------------------------