Various changes:

* Reformatted source code automatically.
* Possible fix for x264 refusing to build lossless videos.
* Allow encoders to add extra options to the command line, such as gpu selection.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks
2020-10-25 18:32:07 +01:00
parent 43952dd162
commit 3b0cdeaaac
4 changed files with 72 additions and 43 deletions
+13 -6
View File
@@ -31,6 +31,7 @@
"enabled": true, "enabled": true,
"pool": "nvenc", "pool": "nvenc",
"parallel": 2, "parallel": 2,
"gpu": -1,
"presets": [ "presets": [
"p5", "p5",
"p6", "p6",
@@ -55,32 +56,38 @@
"hevc_nvenc": { "hevc_nvenc": {
"enabled": false, "enabled": false,
"pool": "nvenc", "pool": "nvenc",
"parallel": 3 "parallel": 2,
"gpu": -1
}, },
"h264_amf": { "h264_amf": {
"enabled": false, "enabled": false,
"pool": "amf", "pool": "amf",
"parallel": 3 "parallel": 2,
"gpu": -1
}, },
"hevc_amf": { "hevc_amf": {
"enabled": false, "enabled": false,
"pool": "amf", "pool": "amf",
"parallel": 3 "parallel": 2,
"gpu": -1
}, },
"h264_qsv": { "h264_qsv": {
"enabled": false, "enabled": false,
"pool": "qsv", "pool": "qsv",
"parallel": 3 "parallel": 2,
"gpu": -1
}, },
"hevc_qsv": { "hevc_qsv": {
"enabled": false, "enabled": false,
"pool": "qsv", "pool": "qsv",
"parallel": 3 "parallel": 2,
"gpu": -1
}, },
"vp9_qsv": { "vp9_qsv": {
"enabled": false, "enabled": false,
"pool": "qsv", "pool": "qsv",
"parallel": 3 "parallel": 2,
"gpu": -1
}, },
"libvpx-vp9": { "libvpx-vp9": {
"enabled": false, "enabled": false,
+4
View File
@@ -35,6 +35,10 @@ class encoder {
get(index, width, height, framerate) { get(index, width, height, framerate) {
throw new Error("Not Implemented"); throw new Error("Not Implemented");
} }
extra() {
return [];
}
} }
module.exports = encoder; module.exports = encoder;
+3 -9
View File
@@ -139,15 +139,9 @@ class h264_nvenc extends encoder {
return this.combinations[index]; return this.combinations[index];
} }
/* extra() {
for (let br of _config.bitrates) return ["-gpu", settings.gpu];
"-b:v", `${br.toFixed(0)}k`, }
"-bufsize", `${(br * 2).toFixed(0)}k`,
"-minrate", "0",
"-maxrate", `${br.toFixed(0)}k`,
for (let kfm of _config.keyframe_multiplier)
"-g", (_cache.fps * kfm).toFixed(0),
*/
} }
module.exports = h264_nvenc; module.exports = h264_nvenc;
+28 -4
View File
@@ -29,7 +29,7 @@ function float_lt(a, b, edge) { return ((a + edge) < b); }
function float_le(a, b, edge) { return float_lt(a, b, edge) || float_eq(a, b, edge); } function float_le(a, b, edge) { return float_lt(a, b, edge) || float_eq(a, b, edge); }
function float_gt(a, b, edge) { return ((a - edge) > b); } function float_gt(a, b, edge) { return ((a - edge) > b); }
function float_ge(a, b, edge) { return float_gt(a, b, edge) || float_eq(a, b, edge); } function float_ge(a, b, edge) { return float_gt(a, b, edge) || float_eq(a, b, edge); }
Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(key)) { size++; } } return size; }; Object.size = function (obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(key)) { size++; } } return size; };
// Actual Code // Actual Code
async function load_config() { // Load Configuration async function load_config() { // Load Configuration
@@ -244,7 +244,6 @@ async function create_caches(config, ff, videos, encoders) { // Create Caches
} else { } else {
command.push( command.push(
"-c:v", "libx264", "-c:v", "libx264",
"-profile:v", "high",
"-preset", "veryfast", "-preset", "veryfast",
"-crf", "0", "-crf", "0",
"-b:v", "0", "-b:v", "0",
@@ -342,7 +341,7 @@ async function transcode(config, ff, videos, encoders) {
"-minrate", "0", "-minrate", "0",
"-maxrate", "0", "-maxrate", "0",
"-bufsize", `${2 * bitrate}k`, "-bufsize", `${2 * bitrate}k`,
].concat(command.options).concat([file]); ].concat(command.options).concat(encoder.extra()).concat([file]);
queue_commands.push( queue_commands.push(
encoder.pool(), encoder.pool(),
@@ -359,7 +358,7 @@ async function transcode(config, ff, videos, encoders) {
})); }));
} }
} }
queue_promises.push(async function() { queue_promises.push(async function () {
await Promise.allSettled(command_promises); await Promise.allSettled(command_promises);
}); });
} }
@@ -379,8 +378,33 @@ async function transcode(config, ff, videos, encoders) {
console.timeEnd("Subtotal"); console.timeEnd("Subtotal");
console.groupEnd(); console.groupEnd();
// Process from here on out.
// LOOP
// 1. Pull out front of the command and file queue.
// 2. Encode using the given command(s).
// 3. Compare resulting files with real input (libvmaf).
// 4. Delete encoded files.
// 5. Repeat until queues empty, no more caches for video, and no more videos.
/*
console.group("Queueing...")
console.time("Subtotal");
for (let video_key of videos.keys()) {
console.group(video_key);
console.time(video_key);
let video = videos.get(video_key);
for (let cache_key of video.caches.keys()) {
let cache = video.caches.get(cache_key);
console.time(cache_key);
console.timeEnd(cache_key);
}
console.timeEnd(video_key);
console.groupEnd();
}
console.timeEnd("Subtotal");
console.groupEnd();
*/
/* /*
for (let video_name in videos) { for (let video_name in videos) {
console.time(video_name); console.time(video_name);