|
|
|
|
@ -68,21 +68,21 @@ app.get('/videos', (req, res) => {
|
|
|
|
|
let process = null;
|
|
|
|
|
let mayRestart = false;
|
|
|
|
|
|
|
|
|
|
// if (fs.existsSync('/tmp/video')) {
|
|
|
|
|
// const initialVideo = fs.readFileSync('/tmp/video');
|
|
|
|
|
// startVideo(initialVideo);
|
|
|
|
|
// }
|
|
|
|
|
if (fs.existsSync('/selectedvideo')) {
|
|
|
|
|
const initialVideo = fs.readFileSync('/selectedvideo');
|
|
|
|
|
startVideo(initialVideo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function startVideo(path) {
|
|
|
|
|
process = require('child_process').spawn('ffplay', ['-fs', '-loop', '2147483647', '-hide_banner', '-loglevel', 'error', path]);
|
|
|
|
|
|
|
|
|
|
process.stdout.on('data', (data) => {
|
|
|
|
|
console.log(`stdout: ${data}`);
|
|
|
|
|
});
|
|
|
|
|
// process.stdout.on('data', (data) => {
|
|
|
|
|
// console.log(`stdout: ${data}`);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
process.stderr.on('data', (data) => {
|
|
|
|
|
console.error(`stderr: ${data}`);
|
|
|
|
|
});
|
|
|
|
|
// process.stderr.on('data', (data) => {
|
|
|
|
|
// console.error(`stderr: ${data}`);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
process.on("exit", () => {
|
|
|
|
|
if (!mayRestart) {
|
|
|
|
|
@ -109,7 +109,7 @@ app.post('/play', (req, res) => {
|
|
|
|
|
video = path.join('/video/', path.basename(video))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fs.writeFileSync('/tmp/video', video);
|
|
|
|
|
fs.writeFileSync('/selectedvideo', video);
|
|
|
|
|
|
|
|
|
|
startVideo(video);
|
|
|
|
|
|
|
|
|
|
@ -123,9 +123,12 @@ app.post('/upload', function (req, res) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The name of the input field (i.e. "sampleFile") is used to retrieve the uploaded file
|
|
|
|
|
const uploadPath = path.join(__dirname, '/public/videos/');
|
|
|
|
|
// const uploadPath = path.join(__dirname, '/public/videos/');
|
|
|
|
|
const uploadPath = "/video";
|
|
|
|
|
|
|
|
|
|
req.files.file.mv(uploadPath + "video.mp4", function (err) {
|
|
|
|
|
console.log(req.files.file);
|
|
|
|
|
|
|
|
|
|
req.files.file.mv(path.join(uploadPath, req.files.file.name), function (err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return res.status(500);
|
|
|
|
|
}
|
|
|
|
|
@ -138,4 +141,4 @@ app.post('/upload', function (req, res) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res.redirect('/');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|