799967501@qq.com

完整版

node_modules
.idea
\ No newline at end of file
.idea
log
\ No newline at end of file
... ...
{
"GETCLASSURL":"http://139.196.126.156:8081/getLogs/recordClassList",
"GETCLASSURLPARAMETER":{
"siteId":["BuzzKID","kuaikuenglish"],
"siteId":["beidatest"],
"key":"xdymp4record20191225",
"page":1,
"maxMedia":1
},
"PROJECTWINCATALOG":"E:/project/web_capture_release/win-x64",
"PROJECTCATALOG":"E:/project/web_capture_release",
"PROJECTWINCATALOG":"F:/project/web_capture_release/win-x64",
"PROJECTCATALOG":"F:/project/web_capture_release",
"BACKMEDIACONFIG":{
"url" : "https://pclive.xuedianyun.com/pcBase/pclive2/dev/index.html",
"recordMp4":true,
"classId":"",
"userId":0,
"userName":"",
... ...
... ... @@ -9,10 +9,16 @@ const methods = {
let date = YesterdayTimeDate.getDate()
let startTime = new Date(year + "-" + month + "-" + date + " 5:30:00").getTime()
let endTime = new Date(year + "-" + month + "-" + date + " 23:59:00").getTime()
if(month < 10){
month = '0' + month
}
if(date < 10){
date = '0' + date
}
return {
startTime,
endTime,
ymd:year + "-" + month + "-" + date
ymd:year+month+date
}
},
dayTimeYMD() {
... ... @@ -20,6 +26,12 @@ const methods = {
let year = dayTimeDate.getFullYear()
let month = dayTimeDate.getMonth() + 1
let date = dayTimeDate.getDate()
if(month < 10){
month = '0' + month
}
if(date < 10){
date = '0' + date
}
return {
ymd:year + "-" + month + "-" + date
}
... ...
... ... @@ -3,7 +3,8 @@
"version": "0.0.0",
"private": true,
"scripts": {
"start": "nodemon ./bin/www"
"start": "nodemon ./bin/www",
"pm2": "pm2 start ./bin/www --name webScreen"
},
"dependencies": {
"axios": "^0.19.0",
... ...
... ... @@ -48,11 +48,18 @@ class MediaCreat {
if (siteIds.length) {
return await new MediaCreat().allData()
}
this.wrieLog("去重前的classId:------>" + JSON.stringify(classid))
this.wrieLog("httpData:------>" + JSON.stringify(result.data))
return true
} else {
return false
}
}
wrieLog(text){
// 写入log
let logFile = `./log/${dayTimeYMD().ymd}.txt`
fs.appendFileSync(logFile,new Date().toLocaleString() + " " +text+'\r\n');
}
async mediaCreat(id, siteId) {
let fileConfig = await new MediaCreat().getConfigFileJson()
if(!fileConfig) return false
... ... @@ -70,13 +77,13 @@ class MediaCreat {
if (!fs.existsSync(ymdDir)) {
fs.mkdirSync(ymdDir);
}
let url = `web_capture_c -o=../media/${siteId}/${ymd}/${id}.mp4 -u="${BACKMEDIACONFIG.url}?classId=${id}&userId=${BACKMEDIACONFIG.userId}&userName=${BACKMEDIACONFIG.userName}&userRole=${BACKMEDIACONFIG.userRole}&portalIP=${BACKMEDIACONFIG.portalIP}&portalPort=${BACKMEDIACONFIG.portalPort}&channels=${BACKMEDIACONFIG.channels}&playRecord=${BACKMEDIACONFIG.playRecord}" -d=${BACKMEDIACONFIG.d} -s=${BACKMEDIACONFIG.s} -fa=${BACKMEDIACONFIG.fa} -k=${BACKMEDIACONFIG.k} -w=${BACKMEDIACONFIG.w} -h=${BACKMEDIACONFIG.h}`
let url = `web_capture_c -o=../media/${siteId}/${ymd}/${id}.mp4 -u="${BACKMEDIACONFIG.url}?classId=${id}&recordMp4=${BACKMEDIACONFIG.recordMp4}&userId=${BACKMEDIACONFIG.userId}&userName=${BACKMEDIACONFIG.userName}&userRole=${BACKMEDIACONFIG.userRole}&portalIP=${BACKMEDIACONFIG.portalIP}&portalPort=${BACKMEDIACONFIG.portalPort}&channels=${BACKMEDIACONFIG.channels}&playRecord=${BACKMEDIACONFIG.playRecord}" -d=${BACKMEDIACONFIG.d} -s=${BACKMEDIACONFIG.s} -fa=${BACKMEDIACONFIG.fa} -k=${BACKMEDIACONFIG.k} -w=${BACKMEDIACONFIG.w} -h=${BACKMEDIACONFIG.h}`
var workerProcess = spawn(url, { cwd: PROJECTWINCATALOG, shell: true })
// workerProcess.stdout.on('data', async function (data) {
// });
workerProcess.on('close', async function (code) {
workerProcess.on('close', async (code) => {
let files = fs.readdirSync(ymdDir);
if (files.indexOf(id + ".mp4") == -1) {
//当前课堂没有写入到文件夹,进入重录
... ... @@ -88,6 +95,7 @@ class MediaCreat {
}
if (parentData[siteId].length == 0) {
// //全部录制完毕
this.wrieLog("录制结束:------>")
fs.writeFile(ymdDir + "/download.json", `{ "code": "0", "success": "ok"}`, function (err) {
if (err) {
console.log(err);
... ... @@ -121,13 +129,14 @@ class MediaCreat {
if (!fs.existsSync(dateDir)) {
fs.mkdirSync(dateDir);
}
let url = `web_capture_c -o=../media/recording/${siteId}/${dayTimeYMD().ymd}/${id}.mp4 -u="${BACKMEDIACONFIG.url}?classId=${id}&userId=${BACKMEDIACONFIG.userId}&userName=${BACKMEDIACONFIG.userName}&userRole=${BACKMEDIACONFIG.userRole}&portalIP=${BACKMEDIACONFIG.portalIP}&portalPort=${BACKMEDIACONFIG.portalPort}&channels=${BACKMEDIACONFIG.channels}&playRecord=${BACKMEDIACONFIG.playRecord}" -d=${BACKMEDIACONFIG.d} -s=${BACKMEDIACONFIG.s} -fa=${BACKMEDIACONFIG.fa} -k=${BACKMEDIACONFIG.k} -w=${BACKMEDIACONFIG.w} -h=${BACKMEDIACONFIG.h}`
let url = `web_capture_c -o=../media/recording/${siteId}/${dayTimeYMD().ymd}/${id}.mp4 -u="${BACKMEDIACONFIG.url}?classId=${id}&recordMp4=${BACKMEDIACONFIG.recordMp4}&userId=${BACKMEDIACONFIG.userId}&userName=${BACKMEDIACONFIG.userName}&userRole=${BACKMEDIACONFIG.userRole}&portalIP=${BACKMEDIACONFIG.portalIP}&portalPort=${BACKMEDIACONFIG.portalPort}&channels=${BACKMEDIACONFIG.channels}&playRecord=${BACKMEDIACONFIG.playRecord}" -d=${BACKMEDIACONFIG.d} -s=${BACKMEDIACONFIG.s} -fa=${BACKMEDIACONFIG.fa} -k=${BACKMEDIACONFIG.k} -w=${BACKMEDIACONFIG.w} -h=${BACKMEDIACONFIG.h}`
var workerProcess = spawn(url, { cwd: PROJECTWINCATALOG, shell: true })
// workerProcess.stdout.on('data', async function (data) {
// });
workerProcess.on('close', async function (code) {
workerProcess.on('close', async (code) =>{
let files = fs.readdirSync(dateDir);
if (files.indexOf(id + ".mp4") == -1) {
//当前课堂没有写入到文件夹,进入重录
... ... @@ -139,6 +148,7 @@ class MediaCreat {
}
if (parentData[siteId].length == 0) {
// //全部录制完毕
this.wrieLog("录制结束:------>")
fs.writeFile(dateDir + "/download.json", `{ "code": "0", "success": "ok"}`, function (err) {
if (err) {
console.log(err);
... ... @@ -161,6 +171,7 @@ class MediaCreat {
router.get('/', async function (req, res, next) {
new MediaCreat().wrieLog("录制开始:------>")
let fileConfig = await new MediaCreat().getConfigFileJson()
if(!fileConfig) return false
... ... @@ -170,10 +181,13 @@ router.get('/', async function (req, res, next) {
let result = await new MediaCreat().allData()
if (result) {
// 去重
classobj = {}
classid = classid.reduce(function (item, next) {
classobj[next.classId] ? '' : classobj[next.classId] = true && item.push(next);
return item;
}, []);
// 写入log
new MediaCreat().wrieLog("去重后的classid:------>" + JSON.stringify(classid))
if (classid.length) {
for (let i = 0; i < GETCLASSURLPARAMETER.maxMedia; i++) {
let shiftData = classid.shift()
... ... @@ -183,8 +197,10 @@ router.get('/', async function (req, res, next) {
return false
}
}
res.send({ code: "0" });
}else{
res.send({ code: "1" ,message:"无录制数据"});
}
res.send({ code: "0" });
}
});
... ... @@ -194,6 +210,7 @@ router.get('/', async function (req, res, next) {
* }
*/
router.post('/recording', async function (req, res, next) {
new MediaCreat().wrieLog("录制开始:------>")
let fileConfig = await new MediaCreat().getConfigFileJson()
if(!fileConfig) return false
const { classId } = req.body
... ... @@ -214,8 +231,11 @@ router.post('/recording', async function (req, res, next) {
return false
}
}
res.send({ code: "0" });
}else{
res.send({ code: "1" ,message:"无录制数据"});
}
res.send({ code: "0" });
})
... ...