forked from Jalle19/node-ffmpeg-mpegts-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode-ffmpeg-mpegts-proxy.js
More file actions
79 lines (69 loc) · 1.85 KB
/
node-ffmpeg-mpegts-proxy.js
File metadata and controls
79 lines (69 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Require libraries
*/
var yargs = require('yargs');
var winston = require('winston');
var http = require("http");
var child_process = require('child_process');
var sleep = require('sleep');
var executable = require('executable');
var avconv = require('./libs/avconv/avconv');
var options = require('./libs/options');
var commandExists = require('command-exists');
/*
* Read command line options
*/
var argv = yargs
.usage('Usage: $0 -p <port> -s <sources> [-a <avconv>] [-q | -v | -l]')
.alias('p', 'port')
.alias('l', 'listen')
.alias('a', 'avconv')
.alias('s', 'sources')
.alias('q', 'quiet')
.alias('v', 'verbose')
.demand(['p', 's'])
.default('a', 'avconv')
.default('l', '::')
.describe('p', 'The port the HTTP server should be listening on')
.describe('l', 'The address to listen on')
.describe('a', 'The path to avconv, defaults to just "avconv"')
.describe('s', 'The path to sources.json, defaults to "data/sources.json"')
.describe('q', 'Disable all logging to stdout')
.describe('v', 'Enable verbose logging (shows the output from avconv)')
.argv;
/*
* Configure logger
*/
winston.remove(winston.transports.Console);
if (!argv.quiet)
{
winston.add(winston.transports.Console, {
timestamp: true,
colorize: true,
level: argv.verbose ? 'silly' : 'debug'
});
}
/**
* Check that the avconv is useable
*/
if (!argv.avconv) {
argv.avconv = 'avconv';
}
commandExists(argv.avconv, function(err, exists) {
if (!exists) {
//Check if ffmpeg exists
commandExists('ffmpeg', function(err, exists) {
if ( ! exists ) {
winston.error('neither avconv, nor ffmpeg found or is not executable');
process.exit();
}
else {
argv.avconv = 'ffmpeg';
}
});
}
});
// Start the server
var ClusterServer = require('./libs/cluster')(argv);
ClusterServer.name = 'node-ffmpeg-mpegts-proxy';
ClusterServer.start(require('./libs/server')(argv), argv.port, argv.l);