-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (29 loc) · 898 Bytes
/
app.js
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
var ffmpeg = require("fluent-ffmpeg");
var path = require("path");
const sourceFilePath = path.join(__dirname, "source/test.mp4");
const ffprobePath = path.join(__dirname, "bin/ffprobe.exe");
ffmpeg.setFfprobePath(ffprobePath);
ffmpeg.ffprobe(sourceFilePath, function (err, metadata) {
if (err) {
console.log(err);
} else {
const streams = metadata.streams;
const streamVideo = streams.find((stream) => stream.codec_type == "video");
const allowed = [
"width",
"height",
"display_aspect_ratio",
"avg_frame_rate",
"nb_frames",
"duration",
];
const filtered = (raw) => Object.keys(raw)
.filter((key) => allowed.includes(key))
.reduce((obj, key) => {
obj[key] = raw[key];
return obj;
}, {});
const metadataVideo = filtered(streamVideo);
console.log("metadata-video", metadataVideo);
}
});