init commit
This commit is contained in:
44
functions/video.js
Normal file
44
functions/video.js
Normal file
@ -0,0 +1,44 @@
|
||||
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': () => {
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user