44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
const ffmpeg = require("fluent-ffmpeg");
|
|
|
|
module.exports = {
|
|
/**
|
|
* reads information from a video
|
|
* @param {*} inputPath path to video file
|
|
* @returns promise <video size, videoduration>
|
|
*/
|
|
'getVideoInfo': (inputPath) => {
|
|
return new Promise((resolve, reject) => {
|
|
|
|
if (typeof(inputPath) != "string") {
|
|
return reject("path must be of type string");
|
|
}
|
|
|
|
return ffmpeg.ffprobe(inputPath, (error, videoInfo) => {
|
|
|
|
if (error) {
|
|
return reject(error);
|
|
}
|
|
|
|
const { duration, size } = videoInfo.format;
|
|
|
|
return resolve({
|
|
size,
|
|
durationInSeconds: Math.floor(duration),
|
|
});
|
|
});
|
|
});
|
|
},
|
|
/**
|
|
* encodes video with given parameters
|
|
* @param {object} options JSON Object passed as settings
|
|
* @returns promise
|
|
*/
|
|
'encodeVideo': (options) => {
|
|
// TODO: figure my shit out
|
|
// Literally dont fucking know how to do this -.-
|
|
// Future me be smarter best of luck.. past me.
|
|
},
|
|
'generateThumbnail': () => {
|
|
|
|
}
|
|
} |