fix: 04_Encode_HEVC - use RcLookahead from Flow model, add size safety net, update JSDoc
This commit is contained in:
parent
02c1db0cbc
commit
b04221cce4
1 changed files with 29 additions and 6 deletions
|
|
@ -1,11 +1,10 @@
|
|||
/**
|
||||
* @author Sascha (Port von Tdarr_Plugin_Custom_MKV_H265_DE_v400)
|
||||
* @description HEVC NVENC VBR CQ fuer 1080p Material mit deutschen Audiospuren.
|
||||
* Slot 0 = AAC 2.0 192k DE (DEFAULT), Slot 1+ = beste DE copy, dann
|
||||
* weitere DE, dann alle EN. Alle Untertitel bleiben erhalten.
|
||||
* Slot 0 = EAC3-Kompat bei DTS, sonst copy. Alle Untertitel bleiben erhalten.
|
||||
* CUDA HW-Decode. HDR/DV-aware. Idempotent (kein Re-Re-Encode).
|
||||
* @revision 2
|
||||
* @uid 4f1c2a90-1111-4b00-8a01-0000000000a4
|
||||
* GROESSEN-SICHERHEITSNETZ: Output <= Original + 5% Toleranz.
|
||||
* @revision 3
|
||||
* @output Encode erfolgreich
|
||||
* @output Skip / Fehler
|
||||
* @param {int} TargetBitrateMbit Ziel-Bitrate in Mbit/s (b:v)
|
||||
|
|
@ -13,14 +12,16 @@
|
|||
* @param {int} SkipThresholdMbit Wenn Quelle <= dieser Wert (Mbit/s): HEVC copy, sonst encode
|
||||
* @param {string} Preset NVENC Preset p1..p7
|
||||
* @param {int} CQ Constant Quality
|
||||
* @param {int} RcLookahead NVENC rc-lookahead Frames (Default 32)
|
||||
*/
|
||||
function Script(TargetBitrateMbit, MaxrateMbit, SkipThresholdMbit, Preset, CQ)
|
||||
function Script(TargetBitrateMbit, MaxrateMbit, SkipThresholdMbit, Preset, CQ, RcLookahead)
|
||||
{
|
||||
TargetBitrateMbit = TargetBitrateMbit || 5;
|
||||
MaxrateMbit = MaxrateMbit || 8;
|
||||
SkipThresholdMbit = SkipThresholdMbit || 5;
|
||||
Preset = Preset || 'p7';
|
||||
CQ = CQ || 24;
|
||||
RcLookahead = RcLookahead || 32;
|
||||
|
||||
let TARGET = TargetBitrateMbit * 1000000;
|
||||
let MAXRATE = MaxrateMbit * 1000000;
|
||||
|
|
@ -138,7 +139,7 @@ function Script(TargetBitrateMbit, MaxrateMbit, SkipThresholdMbit, Preset, CQ)
|
|||
'-preset', Preset,
|
||||
'-spatial_aq', '1',
|
||||
'-temporal_aq', '1',
|
||||
'-rc-lookahead', '32',
|
||||
'-rc-lookahead', '' + RcLookahead,
|
||||
'-tag:v', 'hvc1');
|
||||
|
||||
if (!forceSDR && (isHDR || is10bit)) {
|
||||
|
|
@ -219,6 +220,28 @@ function Script(TargetBitrateMbit, MaxrateMbit, SkipThresholdMbit, Preset, CQ)
|
|||
return 2;
|
||||
}
|
||||
|
||||
// ── GROESSEN-SICHERHEITSNETZ ──────────────────────────────────
|
||||
// Output darf nicht wesentlich groesser sein als die Quelle.
|
||||
// Toleranz: 5% (fuer Audio-Stream-Unterschiede / Metadaten).
|
||||
// Bei Ueberschreitung: Encode verwerfen, Original behalten, Warnung.
|
||||
// Ausnahme: copyVideo (nur Audio-Remux) kann durch EAC3 etwas wachsen.
|
||||
if (!copyVideo) {
|
||||
let origSizeStat = Flow.Execute({ command: '/usr/bin/stat', argumentList: ['-c', '%s', inputFile] });
|
||||
let origSize = parseInt((origSizeStat && origSizeStat.standardOutput) ? origSizeStat.standardOutput.trim() : '0', 10) || 0;
|
||||
let newSizeStat = Flow.Execute({ command: '/usr/bin/stat', argumentList: ['-c', '%s', outFile] });
|
||||
let newSize = parseInt((newSizeStat && newSizeStat.standardOutput) ? newSizeStat.standardOutput.trim() : '0', 10) || 0;
|
||||
|
||||
if (origSize > 0 && newSize > 0) {
|
||||
let growthPct = ((newSize - origSize) / origSize) * 100;
|
||||
Logger.ILog('Groesse: orig=' + origSize + ' bytes, output=' + newSize + ' bytes, growth=' + growthPct.toFixed(1) + '%');
|
||||
if (growthPct > 5) {
|
||||
Logger.WLog('GROESSEN-WARNUNG: Output ' + growthPct.toFixed(1) + '% groesser als Quelle -> Encode verworfen, Original bleibt.');
|
||||
Flow.Execute({ command: '/bin/rm', argumentList: ['-f', outFile] });
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Flow.SetWorkingFile(outFile);
|
||||
Logger.ILog('HEVC Encode erfolgreich -> ' + outFile);
|
||||
return 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue