-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamingServer.js
More file actions
34 lines (31 loc) · 945 Bytes
/
Copy pathstreamingServer.js
File metadata and controls
34 lines (31 loc) · 945 Bytes
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
const ffmpeg = require('fluent-ffmpeg')
const HLSServer = require('hls-server')
const http = require('http')
// host, port and path to the RTMP stream
const host = 'localhost'
const port = '1935'
const path = '/live/test'
const server = http.createServer((req, res) => {
// res.setHeader('Access-Control-Allow-Origin', '*')
console.log(req)})
const hls = new HLSServer(server, {
path: '/streams', // Base URI to output HLS streams
dir: 'public/videos' // Directory that input files are stored
})
server.listen(8001)
ffmpeg('rtmp://'+host+':'+port+path, { timeout: 432000 }).addOptions([
'-c:v libx264',
'-c:a aac',
'-ac 1',
'-strict -2',
'-crf 18',
'-profile:v baseline',
'-maxrate 400k',
'-bufsize 1835k',
'-pix_fmt yuv420p',
'-hls_time 10',
'-hls_list_size 6',
'-start_number 1'
]).output('public/videos/output.m3u8').on('end', () => {
console.log('end')
}).run()