-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hejianglin
committed
Mar 30, 2023
1 parent
b8519ba
commit 47fb82f
Showing
7 changed files
with
138 additions
and
77 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
server { | ||
listen 80; | ||
listen 443 ssl http2; | ||
# listen [::]:80; | ||
server_name cn.oimi.space; | ||
#root /usr/share/nginx/html; | ||
ssl_certificate /home/cn.oimi.space.pem; # 证书 | ||
ssl_certificate_key /home/cn.oimi.space.key; # 证书秘钥 | ||
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; #协议 | ||
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; | ||
ssl_prefer_server_ciphers on; | ||
ssl_session_cache shared:SSL:10m; | ||
# sessions时长 | ||
ssl_session_timeout 10m; | ||
add_header Strict-Transport-Security "max-age=31536000"; # 配置之后只能通过https访问网站 | ||
# Load configuration files for the default server block. | ||
# include /etc/nginx/default.d/*.conf; | ||
location / { | ||
proxy_pass http://127.0.0.1:3008/; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header REMOTE-HOST $remote_addr; | ||
} | ||
error_page 404 /404.html; | ||
location = /404.html { | ||
} | ||
|
||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
let ffmpeg = require('fluent-ffmpeg') | ||
|
||
class LiveRecorder { | ||
/** | ||
* Sets the input file | ||
* @param {String} filename M3U8 file path. You can use remote URL | ||
* @returns {Function} | ||
*/ | ||
setInputFile (url) { | ||
this.RECORDER_URl = url | ||
return this | ||
} | ||
|
||
/** | ||
* Sets the output file | ||
* @param {String} filename Output file path. Has to be local :) | ||
* @returns {Function} | ||
*/ | ||
setOutputFile (filename) { | ||
this.DOWNLOAD_FILENAME = filename | ||
return this | ||
} | ||
|
||
/** | ||
* Sets the thread | ||
* @param {Number} number thread number | ||
* @returns {Function} | ||
*/ | ||
setThreads (number) { | ||
if (number) { | ||
this.THREADS = number | ||
} | ||
return this | ||
} | ||
|
||
start () { | ||
return new Promise((resolve, reject) => { | ||
if (!this.RECORDER_URl || !this.DOWNLOAD_FILENAME) { | ||
reject(new Error('You must specify the input and the output files')) | ||
return | ||
} | ||
const ffmpegCmd = ffmpeg(this.RECORDER_URl) | ||
.on('error', error => { | ||
reject(new Error(error)) | ||
}) | ||
.on('end', () => { | ||
resolve() | ||
}) | ||
if (this.THREADS) { | ||
ffmpegCmd.outputOptions(`-threads ${this.THREADS}`) | ||
ffmpegCmd.outputOptions('-preset ultrafast') | ||
} | ||
ffmpegCmd.outputOptions('-c:v copy') | ||
.outputOptions('-c:a aac') | ||
.outputOptions('-b:a 128k') | ||
.output(this.DOWNLOAD_FILENAME) | ||
ffmpegCmd.run() | ||
}) | ||
} | ||
} | ||
|
||
module.exports = LiveRecorder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters