Speed up video play for FileBin video files

cron-as-worker-process
Moe 2022-06-27 15:04:14 -07:00
parent 9711472dda
commit 1f238d2175
1 changed files with 8 additions and 3 deletions

View File

@ -237,11 +237,16 @@ module.exports = function(s,config,lang,app,io){
if(r && r[0]){
r = r[0]
r.details = JSON.parse(r.details)
const filePath = s.dir.fileBin + req.params.ke + '/' + req.params.id + (r.details.year && r.details.month && r.details.day ? '/' + r.details.year + '/' + r.details.month + '/' + r.details.day : '') + '/' + req.params.file;
const filename = req.params.file
const filePath = s.dir.fileBin + req.params.ke + '/' + req.params.id + (r.details.year && r.details.month && r.details.day ? '/' + r.details.year + '/' + r.details.month + '/' + r.details.day : '') + '/' + filename;
fs.stat(filePath,function(err,stats){
if(!err){
res.on('finish',function(){res.end()})
fs.createReadStream(filePath).pipe(res)
if(filename.endsWith('.mp4')){
s.streamMp4FileOverHttp(filePath,req,res,!!req.query.pureStream)
}else{
res.on('finish',function(){res.end()})
fs.createReadStream(filePath).pipe(res)
}
}else{
failed()
}