initial commit
This commit is contained in:
parent
39d9e2cb47
commit
b11c2f6d31
@ -1,9 +1,9 @@
|
||||
LOW 480 X 270 400kbps
|
||||
Medium 640 X 360 800kbps
|
||||
High 960 X 540 1200kbps
|
||||
HD 1280 x 720 1500kbps
|
||||
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
|
||||
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
|
||||
|
@ -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
|
||||
* @param {object} options JSON Object passed as settings
|
||||
|
8
index.js
8
index.js
@ -7,6 +7,14 @@ async function performTest(){
|
||||
video.getVideoInfo("./uploads/test.mp4").then(video => {
|
||||
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();
|
||||
|
45
package-lock.json
generated
45
package-lock.json
generated
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "video-encoder",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
@ -9,6 +9,7 @@
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"ffmpeg": "^0.0.4",
|
||||
"fluent-ffmpeg": "^2.1.2"
|
||||
}
|
||||
},
|
||||
@ -17,6 +18,14 @@
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz",
|
||||
"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": {
|
||||
"version": "2.1.2",
|
||||
"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",
|
||||
"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": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
|
||||
@ -45,34 +59,5 @@
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,6 @@
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"fluent-ffmpeg": "^2.1.2"
|
||||
"ffmpeg": "^0.0.4"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user