init commit
This commit is contained in:
parent
c9eec03559
commit
39d9e2cb47
2
.env
Normal file
2
.env
Normal file
@ -0,0 +1,2 @@
|
||||
FFMPEG_PATH="./bin/win64/ffmpeg.exe"
|
||||
FFPROBE_PATH="./bin/win64/ffprobe.exe"
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
node_modules/
|
||||
proccessed/
|
||||
uploads/
|
14
auflösungen.txt
Normal file
14
auflösungen.txt
Normal file
@ -0,0 +1,14 @@
|
||||
LOW 480 X 270 400kbps
|
||||
Medium 640 X 360 800kbps
|
||||
High 960 X 540 1200kbps
|
||||
HD 1280 x 720 1500kbps
|
||||
FullHD 1920 x 1080 4000kbps
|
||||
4K 3840 X 2160 8000kbps
|
||||
|
||||
.\ffmpeg.exe -i .\uploads\test.mp4 -vf scale=480:270 -fpsmax 30 -pass 1 -f mp4 -vcodec h264 -b:v 400000 .\proccessed\test\test-270.mp4
|
||||
.\ffmpeg.exe -i .\uploads\test.mp4 -vf scale=640:360 -fpsmax 30 -pass 1 -f mp4 -vcodec h264 -b:v 800000 .\proccessed\test\test-360.mp4
|
||||
.\ffmpeg.exe -i .\uploads\test.mp4 -vf scale=960:540 -fpsmax 30 -pass 1 -f mp4 -vcodec h264 -b:v 1200000 .\proccessed\test\test-540.mp4
|
||||
.\ffmpeg.exe -i .\uploads\test.mp4 -vf scale=1280:720 -fpsmax 30 -pass 1 -f mp4 -vcodec h264 -b:v 1500000 .\proccessed\test\test-720.mp4
|
||||
.\ffmpeg.exe -i .\uploads\test.mp4 -vf scale=1920:1080 -fpsmax 30 -pass 1 -f mp4 -vcodec h264 -b:v 4000000 .\proccessed\test\test-1080.mp4
|
||||
.\ffmpeg.exe -i .\uploads\test.mp4 -vf scale=3840:2160 -fpsmax 30 -pass 1 -f mp4 -vcodec h264 -b:v 8000000 .\proccessed\test\test-2160.mp4
|
||||
.\ffmpeg.exe -i .\uploads\test.mp4 -ss 00:00:01.000 -frames:v 1 -q:v 2 .\proccessed\test\test-thumbnail.png
|
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': () => {
|
||||
|
||||
}
|
||||
}
|
13
index.js
Normal file
13
index.js
Normal file
@ -0,0 +1,13 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const video = require("./functions/video");
|
||||
|
||||
// File is used for for testing
|
||||
async function performTest(){
|
||||
video.getVideoInfo("./uploads/test.mp4").then(video => {
|
||||
console.log("Video Size:", video.size, "- duration:", video.durationInSeconds);
|
||||
});
|
||||
}
|
||||
|
||||
performTest();
|
||||
// TODO: do the nightmare of class directions..
|
78
package-lock.json
generated
Normal file
78
package-lock.json
generated
Normal file
@ -0,0 +1,78 @@
|
||||
{
|
||||
"name": "video-encoder",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "video-encoder",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"fluent-ffmpeg": "^2.1.2"
|
||||
}
|
||||
},
|
||||
"node_modules/async": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz",
|
||||
"integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ=="
|
||||
},
|
||||
"node_modules/fluent-ffmpeg": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/fluent-ffmpeg/-/fluent-ffmpeg-2.1.2.tgz",
|
||||
"integrity": "sha512-IZTB4kq5GK0DPp7sGQ0q/BWurGHffRtQQwVkiqDgeO6wYJLLV5ZhgNOQ65loZxxuPMKZKZcICCUnaGtlxBiR0Q==",
|
||||
"dependencies": {
|
||||
"async": ">=0.2.9",
|
||||
"which": "^1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/isexe": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
|
||||
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
|
||||
"dependencies": {
|
||||
"isexe": "^2.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"which": "bin/which"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"async": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz",
|
||||
"integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ=="
|
||||
},
|
||||
"fluent-ffmpeg": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/fluent-ffmpeg/-/fluent-ffmpeg-2.1.2.tgz",
|
||||
"integrity": "sha512-IZTB4kq5GK0DPp7sGQ0q/BWurGHffRtQQwVkiqDgeO6wYJLLV5ZhgNOQ65loZxxuPMKZKZcICCUnaGtlxBiR0Q==",
|
||||
"requires": {
|
||||
"async": ">=0.2.9",
|
||||
"which": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"isexe": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="
|
||||
},
|
||||
"which": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
|
||||
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
|
||||
"requires": {
|
||||
"isexe": "^2.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
15
package.json
Normal file
15
package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "video-encoder",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"fluent-ffmpeg": "^2.1.2"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user