initial commit

This commit is contained in:
steev 2023-10-14 22:41:00 +02:00
parent 39d9e2cb47
commit b11c2f6d31
5 changed files with 41 additions and 36 deletions

View File

@ -1,9 +1,9 @@
LOW 480 X 270 400kbps LOW 480 X 270 400kbps
Medium 640 X 360 800kbps Medium 640 X 360 800kbps
High 960 X 540 1200kbps High 960 X 540 1200kbps
HD 1280 x 720 1500kbps HD 1280 x 720 1500kbps
FullHD 1920 x 1080 4000kbps FullHD 1920 x 1080 4000kbps
4K 3840 X 2160 8000kbps 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=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=640:360 -fpsmax 30 -pass 1 -f mp4 -vcodec h264 -b:v 800000 .\proccessed\test\test-360.mp4

View File

@ -28,6 +28,18 @@ module.exports = {
}); });
}); });
}, },
'scaleVideo': (options) => {
ffmpeg(options.inputPath)
.size(`${options.width}x${options.height}`)
.videoBitrate(options.bitrate)
.save(options.outputPath)
.on('end', () => {
console.log('Video resolution and file size have been changed successfully!');
})
.on('error', (err) => {
console.log('Error: ' + err.message);
});
},
/** /**
* encodes video with given parameters * encodes video with given parameters
* @param {object} options JSON Object passed as settings * @param {object} options JSON Object passed as settings

View File

@ -7,6 +7,14 @@ async function performTest(){
video.getVideoInfo("./uploads/test.mp4").then(video => { video.getVideoInfo("./uploads/test.mp4").then(video => {
console.log("Video Size:", video.size, "- duration:", video.durationInSeconds); console.log("Video Size:", video.size, "- duration:", video.durationInSeconds);
}); });
video.scaleVideo({
inputPath: "./uploads/test.mp4",
outputPath: "./proccessed/test-480.mp4",
bitrate: "800k",
width: 640,
height: 480
})
} }
performTest(); performTest();

45
package-lock.json generated
View File

@ -1,7 +1,7 @@
{ {
"name": "video-encoder", "name": "video-encoder",
"version": "1.0.0", "version": "1.0.0",
"lockfileVersion": 2, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
@ -9,6 +9,7 @@
"version": "1.0.0", "version": "1.0.0",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"ffmpeg": "^0.0.4",
"fluent-ffmpeg": "^2.1.2" "fluent-ffmpeg": "^2.1.2"
} }
}, },
@ -17,6 +18,14 @@
"resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz",
"integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ=="
}, },
"node_modules/ffmpeg": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/ffmpeg/-/ffmpeg-0.0.4.tgz",
"integrity": "sha512-3TgWUJJlZGQn+crJFyhsO/oNeRRnGTy6GhgS98oUCIfZrOW5haPPV7DUfOm3xJcHr5q3TJpjk2GudPutrNisRA==",
"dependencies": {
"when": ">= 0.0.1"
}
},
"node_modules/fluent-ffmpeg": { "node_modules/fluent-ffmpeg": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/fluent-ffmpeg/-/fluent-ffmpeg-2.1.2.tgz", "resolved": "https://registry.npmjs.org/fluent-ffmpeg/-/fluent-ffmpeg-2.1.2.tgz",
@ -34,6 +43,11 @@
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="
}, },
"node_modules/when": {
"version": "3.7.8",
"resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz",
"integrity": "sha512-5cZ7mecD3eYcMiCH4wtRPA5iFJZ50BJYDfckI5RRpQiktMiYTcn0ccLTZOvcbBume+1304fQztxeNzNS9Gvrnw=="
},
"node_modules/which": { "node_modules/which": {
"version": "1.3.1", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
@ -45,34 +59,5 @@
"which": "bin/which" "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"
}
}
} }
} }

View File

@ -10,6 +10,6 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"fluent-ffmpeg": "^2.1.2" "ffmpeg": "^0.0.4"
} }
} }