|
|
|
|
@ -74,7 +74,8 @@ if (fs.existsSync('/selectedvideo')) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function startVideo(path) {
|
|
|
|
|
process = require('child_process').spawn('ffplay', ['-fs', '-loop', '2147483647', '-hide_banner', '-loglevel', 'error', path]);
|
|
|
|
|
|
|
|
|
|
const newProcess = require('child_process').spawn('ffplay', ['-fs', '-loop', '2147483647', '-hide_banner', '-loglevel', 'error', path]);
|
|
|
|
|
|
|
|
|
|
// process.stdout.on('data', (data) => {
|
|
|
|
|
// console.log(`stdout: ${data}`);
|
|
|
|
|
@ -84,11 +85,23 @@ function startVideo(path) {
|
|
|
|
|
// console.error(`stderr: ${data}`);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
process.on("exit", () => {
|
|
|
|
|
if (!mayRestart) {
|
|
|
|
|
startVideo(path);
|
|
|
|
|
// newProcess.on("exit", (code) => {
|
|
|
|
|
// if (!mayRestart && code !== 0) {
|
|
|
|
|
// startVideo(path);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
if (process) {
|
|
|
|
|
process.kill();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// newProcess.on("exit", (code) => {
|
|
|
|
|
// if (!mayRestart && code !== 0 && process === newProcess) {
|
|
|
|
|
// startVideo(path);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
process = newProcess;
|
|
|
|
|
}, 5000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fs.mkdirSync('/video', { recursive: true });
|
|
|
|
|
@ -116,6 +129,18 @@ app.post('/play', (req, res) => {
|
|
|
|
|
res.json({ status: 'ok' });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.post("/select", (req, res) => {
|
|
|
|
|
let video = req.query.video;
|
|
|
|
|
fs.writeFileSync('/overlayvideo', video);
|
|
|
|
|
res.json({ status: 'ok' });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.post("/playoverlay", (req, res) => {
|
|
|
|
|
let video = fs.readFileSync('/overlayvideo');
|
|
|
|
|
require('child_process').spawn('ffplay', ['-fs', '-autoexit', '-hide_banner', '-loglevel', 'error', video]);
|
|
|
|
|
res.json({ status: 'ok' });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.post('/upload', function (req, res) {
|
|
|
|
|
|
|
|
|
|
if (!req.files || Object.keys(req.files).length === 0) {
|
|
|
|
|
|