-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (31 loc) · 996 Bytes
/
index.js
File metadata and controls
38 lines (31 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const express = require('express')
const app = express()
exports.run = function(){
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.get('/getFrameRate', function (req, res) {
getMediaInfo(req.query.path).then(function(file){
if (file.media)
res.send("{\"framerate\":"+Math.round(file.media.track[0].framerate)+"}");
else
res.send("{\"framerate\":"+Math.round(file.file.track[0].frameRate)+"}");
}).catch(function(e){
res.send('{"error":"error"}');
});
})
app.listen(3500, function () {
console.log('FrameRateService listening on port 3500!')
});
var mediainfo = require('mediainfo-parser');
function getMediaInfo(filePath) {
return new Promise(function(resolve, reject) {
mediainfo.exec(filePath, function(err, info) {
if(err) return reject(err);
return resolve(info);
});
});
}
}