1
{
  "_id": "SZjePu95q",
  "name": "handbrake-V5",
  "description": "handbrake-V5",
  "tags": "",
  "flowPlugins": [
    {
      "name": "Check Skiplist",
      "sourceRepo": "Community",
      "pluginName": "processedCheck",
      "version": "1.0.0",
      "fpEnabled": true,
      "id": "yEWLaQc4w",
      "position": {
        "x": 1224,
        "y": -624
      }
    },
    {
      "name": "Input File",
      "sourceRepo": "Community",
      "pluginName": "inputFile",
      "version": "1.0.0",
      "id": "rIy6G8-ZD",
      "inputsDB": {
        "fileAccessChecks": "true",
        "pauseNodeIfAccessChecksFail": "true"
      },
      "fpEnabled": true,
      "position": {
        "x": 1152,
        "y": -744
      }
    },
    {
      "name": "Pre-check Stream Count",
      "sourceRepo": "Community",
      "pluginName": "checkStreamsCount",
      "version": "1.0.0",
      "id": "DGpKu7oHx",
      "fpEnabled": true,
      "position": {
        "x": 1152,
        "y": -552
      }
    },
    {
      "name": "Analyze Streams & Build Audio/Sub Args",
      "sourceRepo": "Community",
      "pluginName": "customFunction",
      "version": "1.0.0",
      "id": "fW33Ysqvw",
      "inputsDB": {
        "code": "module.exports = async (args) => {\n  args.variables.user = args.variables.user || {};\n\n  const ff = args.inputFileObj.ffProbeData;\n  const video = ff.streams.find((s) => s.codec_type === 'video' && s.disposition?.attached_pic !== 1);\n  if (!video) {\n    args.jobLog('No video stream found, failing');\n    return { outputFileObj: args.inputFileObj, outputNumber: 2, variables: args.variables };\n  }\n\n  const width = Number(video.width);\n  const height = Number(video.height);\n\n  const parseRate = (r) => {\n    const [n, d] = String(r || '').split('/').map(Number);\n    return d ? n / d : 0;\n  };\n  const fps = parseRate(video.avg_frame_rate) || parseRate(video.r_frame_rate) || 24;\n\n  const streamBps = (s) =>\n    Number(s.bit_rate) || Number(s.tags?.BPS || s.tags?.['BPS-eng'] || 0);\n\n  let videoBps = streamBps(video);\n  if (!videoBps && ff.format.bit_rate) {\n    const audioBps = ff.streams\n      .filter((s) => s.codec_type === 'audio')\n      .reduce((sum, s) => sum + (streamBps(s) || 0), 0);\n    videoBps = Math.max(0, Number(ff.format.bit_rate) - audioBps);\n    args.jobLog('Video bitrate from container minus audio: ' + Math.round(videoBps) + ' bps');\n  }\n\n  let rf;\n  if (!videoBps || !width || !height || !fps) {\n    rf = 30;\n    args.jobLog('Video bitrate unknown, using RF 30');\n  } else {\n    const bpp = videoBps / (width * height * fps);\n    args.jobLog('BPP: ' + bpp.toFixed(4) + ' (fps ' + fps.toFixed(3) + ')');\n    \n    if (bpp >= 0.15) rf = 25;\n    else if (bpp >= 0.12) rf = 28;\n    else if (bpp >= 0.08) rf = 31;\n    else rf = 34;\n  }\n\n  const contentType = String(args.userVariables.library.contentType || '').toLowerCase();\n  const rfRange = contentType === 'animation' ? { offset: 2, min: 27, max: 35 }\n              : { offset: 0, min: 25, max: 33 };\n  rf = Math.min(rfRange.max, Math.max(rfRange.min, rf + rfRange.offset));\n  args.jobLog('Content type: ' + (contentType || 'unset') + ', RF ' + rf);\n\n  const KEEP = ['eng', 'jpn', 'kor', 'und'];\n  const normLang = (s) => {\n    const l = (s.tags?.language || '').toLowerCase();\n    if (!l || l === 'undefined') return 'und';\n    if (l === 'en') return 'eng';\n    if (l === 'ja') return 'jpn';\n    if (l === 'ko') return 'kor';\n    return l;\n  };\n\n  const kept = ff.streams\n    .filter((s) => s.codec_type === 'audio')\n    .map((s, pos) => ({ s, n: pos + 1 }))\n    .filter(({ s, n }) => {\n      const normL = normLang(s);\n      if (!KEEP.includes(normL)) return false;\n\n      const isCommentaryDisp = s.disposition?.comment === 1;\n      const title = (s.tags?.title || '').toLowerCase();\n      const isCommentaryTitle = title.includes('commentary');\n\n      if (isCommentaryDisp || isCommentaryTitle) {\n        args.jobLog('Excluding commentary track at stream ' + s.index + ' (track ' + n + ')');\n        return false;\n      }\n      return true;\n    });\n\n  const encoders = kept.map(({ s }) => {\n    const kbps = streamBps(s) / 1000;\n    if (!kbps) {\n      args.jobLog('Audio track ' + s.index + ' bitrate unknown, using Opus 128');\n      return 'opus';\n    }\n    return kbps < 155 ? 'copy' : 'opus';\n  });\n\n  const clean = (t) => t.replace(/[^A-Za-z0-9 ()&.,\\-\\/\\[\\]]/g, '').trim();\n\n  let audioArgs = '--audio none';\n  let renameList = [];\n\n  if (kept.length > 0) {\n    audioArgs =\n      '-a ' + kept.map((k) => k.n).join(',') +\n      ' --audio-copy-mask aac,ac3,eac3,dts,dtshd,truehd,flac,mp3,opus,vorbis' +\n      ' --aencoder ' + encoders.join(',') +\n      ' --ab ' + encoders.map(() => '128').join(',') +\n      ' --mixdown ' + encoders.map(() => 'stereo').join(',') +\n      ' --audio-fallback opus';\n\n    renameList = kept.map(({ s }, i) => {\n      const title = clean(s.tags?.title || '');\n      if (encoders[i] === 'opus') {\n        const name = title\n          ? title.replace(/Surround/i, 'Stereo').replace(/\\(?Opus\\s*\\d+\\s*Kbps\\)?/i, '(Opus 128Kbps)')\n          : normLang(s).toUpperCase() + ' Stereo (Opus 128Kbps)';\n        return { track: 'a' + (i + 1), name: name };\n      }\n      return title ? { track: 'a' + (i + 1), name: title } : null;\n    }).filter(Boolean);\n\n    args.jobLog('Audio (source order): ' +\n      kept.map(({ s }, i) => s.index + ' ' + normLang(s) + '=' + encoders[i]).join(', '));\n  } else {\n    args.jobLog('No kept audio tracks found');\n  }\n\n  const subKept = ff.streams\n    .filter((s) => s.codec_type === 'subtitle')\n    .map((s, pos) => ({ s, n: pos + 1 }))\n    .filter(({ s, n }) => {\n      const normL = normLang(s);\n      if (!['eng', 'und'].includes(normL) && !/english/i.test(s.tags?.title || '')) {\n        return false;\n      }\n\n      const isCommentaryDisp = s.disposition?.comment === 1;\n      const title = (s.tags?.title || '').toLowerCase();\n      const isCommentaryTitle = title.includes('commentary');\n\n      if (isCommentaryDisp || isCommentaryTitle) {\n        args.jobLog('Excluding commentary subtitle track at stream ' + s.index + ' (track ' + n + ')');\n        return false;\n      }\n      return true;\n    });\n\n  const subArgs = subKept.length\n    ? '-s ' + subKept.map((k) => k.n).join(',')\n    : '--subtitle none';\n\n  args.jobLog('Subtitles kept: ' +\n    (subKept.map(({ s, n }) => n + ' ' + normLang(s)).join(', ') || 'none'));\n\n  args.variables.user.rf = rf;\n  args.variables.user.audioArgs = audioArgs;\n  args.variables.user.renameList = renameList;\n  args.variables.user.subArgs = subArgs;\n\n  return {\n    outputFileObj: args.inputFileObj,\n    outputNumber: 1,\n    variables: args.variables,\n  };\n};"
      },
      "fpEnabled": true,
      "position": {
        "x": 936,
        "y": -312
      }
    },
    {
      "name": "HandBrake Transcode (SVT-AV1-10bit) max 1080p",
      "sourceRepo": "Community",
      "pluginName": "handbrakeCustomArguments",
      "version": "2.0.0",
      "inputsDB": {
        "customArguments": "--encoder svt_av1_10bit --encoder-preset {{{args.userVariables.library.preset}}} --quality {{{args.variables.user.rf}}} --maxWidth 1920 --maxHeight 1080 --non-anamorphic --format av_mkv {{{args.variables.user.subArgs}}} --decomb --comb-detect --keep-aname {{{args.variables.user.audioArgs}}} --encoder-tune vq --encoder-profile main --encoder-level auto --keep-metadata --markers --color-range auto --encopts \"{{{args.variables.user.encOpts}}}\"",
        "useJsonPreset": "false"
      },
      "fpEnabled": true,
      "id": "trAa2RjtE",
      "position": {
        "x": 1044,
        "y": -180
      }
    },
    {
      "name": "Validate Transcode Duration",
      "sourceRepo": "Community",
      "pluginName": "compareFileDurationRatio",
      "version": "1.0.0",
      "fpEnabled": true,
      "id": "2IqZI-qbW",
      "position": {
        "x": 1116,
        "y": -60
      }
    },
    {
      "name": "Apply MKV Track Titles & Statistics",
      "sourceRepo": "Community",
      "pluginName": "customFunction",
      "version": "1.0.0",
      "id": "mkvJsTitle",
      "inputsDB": {
        "code": "const { execFileSync } = require('child_process');\n\nmodule.exports = async (args) => {\n  const file = args.inputFileObj._id;\n  const edits = args.variables.user.renameList || [];\n\n  const argv = [file, '--add-track-statistics-tags'];\n  for (const e of edits) {\n    argv.push('--edit', 'track:' + e.track, '--set', 'name=' + e.name);\n  }\n\n  try {\n    execFileSync('mkvpropedit', argv, { encoding: 'utf8' });\n    args.jobLog('mkvpropedit: statistics tags added' +\n      (edits.length ? ', ' + edits.length + ' title(s) set' : ''));\n  } catch (err) {\n    args.jobLog('mkvpropedit failed: ' + err.message);\n    return { outputFileObj: args.inputFileObj, outputNumber: 2, variables: args.variables };\n  }\n\n  return { outputFileObj: args.inputFileObj, outputNumber: 1, variables: args.variables };\n};\n"
      },
      "fpEnabled": true,
      "position": {
        "x": 1008,
        "y": 12
      }
    },
    {
      "name": "Format Output Filename",
      "sourceRepo": "Community",
      "pluginName": "renameFile",
      "version": "1.0.0",
      "id": "CRGqh1uOY",
      "inputsDB": {
        "fileRename": "${fileName}-P{{{args.userVariables.library.preset}}}-RF{{{args.variables.user.rf}}}.${container}"
      },
      "fpEnabled": true,
      "position": {
        "x": 996,
        "y": 120
      }
    },
    {
      "name": "Move To Directory",
      "sourceRepo": "Community",
      "pluginName": "moveToDirectory",
      "version": "2.0.0",
      "inputsDB": {
        "outputDirectory": "{{{args.userVariables.library.outputDir}}}"
      },
      "fpEnabled": true,
      "id": "felUr0Dya",
      "position": {
        "x": 1008,
        "y": 216
      }
    },
    {
      "name": "Fail Flow",
      "sourceRepo": "Community",
      "pluginName": "failFlow",
      "version": "1.0.0",
      "fpEnabled": true,
      "id": "WM9qZx-iZ",
      "position": {
        "x": 1368,
        "y": 144
      }
    },
    {
      "name": "Fail Flow (Pre-check)",
      "sourceRepo": "Community",
      "pluginName": "failFlow",
      "version": "1.0.0",
      "fpEnabled": true,
      "id": "wFR5DUaSp",
      "position": {
        "x": 1476,
        "y": -384
      }
    },
    {
      "name": "Pause/Unpause Node(s)",
      "sourceRepo": "Community",
      "pluginName": "pauseUnpauseAllNodes",
      "version": "1.0.0",
      "fpEnabled": true,
      "id": "FuVvu_aS5",
      "position": {
        "x": 1152,
        "y": -696
      }
    },
    {
      "name": "Motion check Adaptive RF",
      "sourceRepo": "Community",
      "pluginName": "customFunction",
      "version": "1.0.0",
      "id": "mW05MGb9_",
      "inputsDB": {
        "code": "const { spawnSync } = require('child_process');\n\nfunction getVideoMetadata(src) {\n  const r = spawnSync('ffprobe', [\n    '-v', 'error', '-show_entries', 'format=duration:stream=r_frame_rate',\n    '-of', 'json', src,\n  ], { encoding: 'utf8' });\n  \n  try {\n    const data = JSON.parse(r.stdout);\n    const duration = parseFloat(data.format?.duration) || 0;\n    const fpsParts = (data.streams?.[0]?.r_frame_rate || '30/1').split('/');\n    const fps = parseFloat(fpsParts[0]) / (parseFloat(fpsParts[1]) || 1);\n    return { duration, fps: isNaN(fps) ? 30 : fps };\n  } catch (e) {\n    return { duration: 0, fps: 30 };\n  }\n}\n\nfunction ffmpegProbe(src, startSec, duration, args) {\n  const r = spawnSync('ffmpeg', [\n    '-hide_banner', '-y',\n    '-i', src,\n    '-ss', String(startSec),\n    '-t', String(duration),\n    ...args\n  ], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });\n  return r.stderr || '';\n}\n\nmodule.exports = async (args) => {\n  args.variables.user = args.variables.user || {};\n  const src = args.inputFileObj._id;\n  \n  const contentType = String(args.userVariables.library.contentType || 'live').toLowerCase();\n  \n  const rawPreset = args.userVariables?.library?.preset;\n  const preset = parseInt(rawPreset, 10);\n  const validPreset = isNaN(preset) ? 4 : preset;\n  \n  const PROFILES = {\n    animation: {\n      minRf: 27, maxRf: 35,\n      minCuts: 10,\n      maxCuts: 300,\n      minOffset: 2,\n      maxOffset: -4,\n    },\n    live: {\n      minRf: 25, maxRf: 33,\n      minCuts: 10,\n      maxCuts: 100,\n      minOffset: 1,\n      maxOffset: -2,\n    }\n  };\n\n  const profile = PROFILES[contentType] || PROFILES.live;\n  let baseRf = parseFloat(args.variables.user.rf);\n  if (isNaN(baseRf)) baseRf = 30;\n  \n  args.jobLog(`Analyzing multi-point samples (Profile: ${contentType.toUpperCase()}, Preset: ${validPreset}, Base RF: ${baseRf})`);\n\n  try {\n    const { duration, fps } = getVideoMetadata(src);\n    if (!duration) throw new Error('Could not determine file duration');\n\n    args.jobLog(`Detected stream FPS: ${fps.toFixed(2)} (Duration: ${duration.toFixed(2)}s)`);\n\n    const maxKeyint = Math.round(fps * 10);\n    args.variables.user.encOpts = `enable-overlays=1:scd=1:keyint=${maxKeyint}`;\n    args.jobLog(`Calculated max keyint: ${maxKeyint} (${fps.toFixed(2)} fps * 10s)`);\n\n    const samplePoints = [0.25, 0.50, 0.75];\n    const sampleLen = 10;\n    let rawSceneChanges = 0;\n\n    for (const p of samplePoints) {\n      const startSec = Math.max(0, duration * p - sampleLen / 2);\n      \n      const motionLog = ffmpegProbe(src, startSec, sampleLen, [\n        '-vf', \"select='gt(scene,0.30)',metadata=print\",\n        '-f', 'null', '-'\n      ]);\n      \n      const sceneMatches = motionLog.match(/lavfi\\.scene_score/g) || [];\n      rawSceneChanges += sceneMatches.length;\n    }\n\n    let totalSceneChanges = rawSceneChanges;\n    if (fps > 45) {\n      totalSceneChanges = Math.round(rawSceneChanges / 2);\n      args.jobLog(`60fps stream detected: normalized raw motion count (${rawSceneChanges}) to 30fps baseline (${totalSceneChanges} cuts).`);\n    } else {\n      args.jobLog(`Multi-point motion analysis: detected total ${totalSceneChanges} significant scene/motion cuts across 30s sample.`);\n    }\n\n    const clampedCuts = Math.min(profile.maxCuts, Math.max(profile.minCuts, totalSceneChanges));\n    const ratio = (clampedCuts - profile.minCuts) / (profile.maxCuts - profile.minCuts);\n    \n    const motionDelta = Math.round(profile.minOffset + ratio * (profile.maxOffset - profile.minOffset));\n    args.jobLog(`Proportional motion scaling (${totalSceneChanges} cuts): mapped to motion delta of ${motionDelta} RF.`);\n\n    let presetDelta = 0;\n    if (validPreset <= 2) {\n      presetDelta = 1; \n      args.jobLog(`High-efficiency preset (${validPreset}) detected: applying +1 RF efficiency offset.`);\n    } else if (validPreset >= 6) {\n      presetDelta = -1; \n      args.jobLog(`Fast/lower-efficiency preset (${validPreset}) detected: applying -1 RF compensation offset.`);\n    } else {\n      presetDelta = 0; \n      args.jobLog(`Balanced preset (${validPreset}) detected: no preset offset applied.`);\n    }\n\n    let finalRf = Math.round(baseRf + motionDelta + presetDelta);\n    finalRf = Math.min(profile.maxRf, Math.max(profile.minRf, finalRf));\n\n    args.variables.user.rf = String(finalRf);\n    args.jobLog(`Adaptive RF tuning complete. Final RF set to: ${finalRf} [Clamped ${profile.minRf}-${profile.maxRf}]`);\n\n  } catch (err) {\n    args.jobLog(`Adaptive analysis failed (${err.message}); falling back to BPP baseline RF: ${baseRf}`);\n    args.variables.user.encOpts = 'enable-overlays=1:scd=1:keyint=240';\n  }\n\n  return {\n    outputFileObj: args.inputFileObj,\n    outputNumber: 1,\n    variables: args.variables,\n  };\n};"
      },
      "fpEnabled": true,
      "position": {
        "x": 1092,
        "y": -264
      }
    },
    {
      "name": "health check",
      "sourceRepo": "Community",
      "pluginName": "customFunction",
      "version": "1.0.0",
      "id": "NoN4weslN",
      "inputsDB": {
        "code": "const { spawn } = require('child_process');\nconst fs = require('fs');\n\nmodule.exports = async (args) => {\n  const input = args.inputFileObj._id;\n  \n  const workerName = String(args.workerType || '').toLowerCase();\n  const hasRenderNode = fs.existsSync('/dev/dri/renderD128');\n  \n  const isGpuWorker = workerName.includes('gpu') || \n                      workerName.includes('qsv') || \n                      workerName.includes('intel') || \n                      workerName.includes('ajar') || \n                      hasRenderNode;\n\n  const hwaccel = isGpuWorker\n    ? ['-hwaccel', 'qsv', '-hwaccel_device', '/dev/dri/renderD128']\n    : [];\n\n  args.jobLog(isGpuWorker\n    ? 'Worker hardware detected: decoding via QSV GPU (/dev/dri/renderD128)'\n    : 'Worker is CPU type: decoding in software');\n\n  const cliArgs = [\n    '-stats', '-v', 'error',\n    ...hwaccel,\n    '-i', input,\n    '-an', '-sn',\n    '-f', 'null',\n    '-',\n  ];\n\n  const result = await new Promise((resolve) => {\n    const proc = spawn(args.ffmpegPath, cliArgs);\n    let stderr = '';\n    proc.stderr.on('data', (d) => { stderr += d.toString(); });\n    proc.on('close', (code) => resolve({ code, stderr }));\n    proc.on('error', (e) => resolve({ code: -1, stderr: String(e) }));\n  });\n\n  if (result.code !== 0) {\n    args.jobLog(`Health check failed: ${result.stderr.slice(-500)}`);\n    args.logOutcome('hErr');\n    throw new Error('Health check failed');\n  }\n\n  args.logOutcome('hSuc');\n  args.variables.healthCheck = 'Success';\n\n  return {\n    outputFileObj: args.inputFileObj,\n    outputNumber: 1,\n    variables: args.variables,\n  };\n};"
      },
      "fpEnabled": true,
      "position": {
        "x": 1176,
        "y": -120
      }
    },
    {
      "name": "Audio Stream Integrity & Silence Check",
      "sourceRepo": "Community",
      "pluginName": "customFunction",
      "version": "1.0.0",
      "id": "Q3-nvE4O4",
      "inputsDB": {
        "code": "const { spawn } = require('child_process');\n\nmodule.exports = async (args) => {\n  const input = args.inputFileObj._id;\n\n  args.jobLog('Running audio integrity and silence check...');\n\n  const cliArgs = [\n    '-v', 'error',\n    '-i', input,\n    '-vn',\n    '-af', 'volumedetect',\n    '-f', 'null',\n    '-',\n  ];\n\n  const result = await new Promise((resolve) => {\n    const proc = spawn(args.ffmpegPath, cliArgs);\n    let stderr = '';\n    proc.stderr.on('data', (d) => { stderr += d.toString(); });\n    proc.on('close', (code) => resolve({ code, stderr }));\n    proc.on('error', (e) => resolve({ code: -1, stderr: String(e) }));\n  });\n\n  if (result.code !== 0) {\n    args.jobLog(`Audio check failed to decode: ${result.stderr.slice(-500)}`);\n    args.logOutcome('aErr');\n    throw new Error('Audio stream corruption detected');\n  }\n\n  const maxVolMatch = /max_volume:\\s*([-\\d.]+)\\s*dB/i.exec(result.stderr);\n  if (maxVolMatch) {\n    const maxVol = parseFloat(maxVolMatch[1]);\n    args.jobLog(`Audio integrity check passed. Max volume detected: ${maxVol} dB`);\n    \n    if (maxVol <= -90.0) {\n      args.jobLog('Warning: Audio track appears to be completely silent.');\n    }\n  }\n\n  args.logOutcome('aSuc');\n  args.variables.audioCheck = 'Success';\n\n  return {\n    outputFileObj: args.inputFileObj,\n    outputNumber: 1,\n    variables: args.variables,\n  };\n};"
      },
      "fpEnabled": true,
      "position": {
        "x": 960,
        "y": -528
      }
    },
    {
      "name": "Aspect Ratio / Pixel Aspect Ratio (PAR) Check",
      "sourceRepo": "Community",
      "pluginName": "customFunction",
      "version": "1.0.0",
      "id": "TX_Pphtl8",
      "inputsDB": {
        "code": "const { spawnSync } = require('child_process');\n\nmodule.exports = async (args) => {\n  const input = args.inputFileObj._id;\n\n  args.jobLog('Inspecting video stream aspect ratios (PAR/DAR)...');\n\n  const probe = spawnSync('ffprobe', [\n    '-v', 'error',\n    '-select_streams', 'v:0',\n    '-show_entries', 'stream=width,height,sample_aspect_ratio,display_aspect_ratio',\n    '-of', 'json',\n    input,\n  ], { encoding: 'utf8' });\n\n  if (probe.status !== 0) {\n    args.jobLog(`FFprobe failed: ${probe.stderr}`);\n    args.logOutcome('parErr');\n    throw new Error('Aspect ratio probe failed');\n  }\n\n  const data = JSON.parse(probe.stdout);\n  const stream = data.streams && data.streams[0];\n\n  if (!stream) {\n    throw new Error('No video stream found for aspect ratio check');\n  }\n\n  const width = stream.width;\n  const height = stream.height;\n  const sar = stream.sample_aspect_ratio || '1:1';\n  const dar = stream.display_aspect_ratio || 'N/A';\n\n  args.jobLog(`Resolution: ${width}x${height} | SAR: ${sar} | DAR: ${dar}`);\n\n  const isAnamorphic = sar !== '1:1' && sar !== '0:1' && sar !== '';\n  if (isAnamorphic) {\n    args.jobLog(`Anamorphic video detected with SAR ${sar}. Flagging for proper scaling handling.`);\n    args.variables.user = args.variables.user || {};\n    args.variables.user.isAnamorphic = true;\n    args.variables.user.sar = sar;\n  } else {\n    args.variables.user = args.variables.user || {};\n    args.variables.user.isAnamorphic = false;\n  }\n\n  args.logOutcome('parSuc');\n\n  return {\n    outputFileObj: args.inputFileObj,\n    outputNumber: 1,\n    variables: args.variables,\n  };\n};"
      },
      "fpEnabled": true,
      "position": {
        "x": 864,
        "y": -444
      }
    },
    {
      "name": "Remove Commentary Tracks",
      "sourceRepo": "Community",
      "pluginName": "customFunction",
      "version": "1.0.0",
      "id": "e4lyBF7vs",
      "inputsDB": {
        "code": "module.exports = async (args) => {\n  args.variables.user = args.variables.user || {};\n  const ff = args.inputFileObj.ffProbeData;\n\n  if (!ff || !ff.streams) {\n    return { outputFileObj: args.inputFileObj, outputNumber: 1, variables: args.variables };\n  }\n\n  let audioIdx = -1;\n  let hasCommentary = false;\n  let commentaryMapArgs = '';\n\n  for (let i = 0; i < ff.streams.length; i++) {\n    const stream = ff.streams[i];\n    if (stream.codec_type?.toLowerCase() === 'audio') {\n      audioIdx++;\n      \n      const isCommentaryDisp = stream.disposition?.comment === 1;\n      const title = (stream.tags?.title || '').toLowerCase();\n      const isCommentaryTitle = title.includes('commentary');\n\n      if (isCommentaryDisp || isCommentaryTitle) {\n        commentaryMapArgs += ` -map -0:a:${audioIdx}`;\n        hasCommentary = true;\n        args.jobLog(`Detected commentary track at audio index ${audioIdx} (Stream #${stream.index})`);\n      }\n    }\n  }\n\n  args.variables.user.hasCommentary = hasCommentary;\n  args.variables.user.commentaryMapArgs = commentaryMapArgs;\n\n  return {\n    outputFileObj: args.inputFileObj,\n    outputNumber: 1,\n    variables: args.variables,\n  };\n};"
      },
      "fpEnabled": true,
      "position": {
        "x": 744,
        "y": -372
      }
    },
    {
      "name": "Add To Skiplist",
      "sourceRepo": "Community",
      "pluginName": "processedAdd",
      "version": "1.0.0",
      "id": "vVh6iX82G",
      "position": {
        "x": 1008,
        "y": 288
      },
      "fpEnabled": true
    }
  ],
  "flowEdges": [
    {
      "source": "DGpKu7oHx",
      "sourceHandle": "1",
      "target": "wFR5DUaSp",
      "targetHandle": null,
      "id": "lLQoZ-Uci"
    },
    {
      "source": "DGpKu7oHx",
      "sourceHandle": "3",
      "target": "wFR5DUaSp",
      "targetHandle": null,
      "id": "2USJA6IGe"
    },
    {
      "source": "fW33Ysqvw",
      "sourceHandle": "2",
      "target": "wFR5DUaSp",
      "targetHandle": null,
      "id": "fail0001"
    },
    {
      "source": "2IqZI-qbW",
      "sourceHandle": "2",
      "target": "WM9qZx-iZ",
      "targetHandle": null,
      "id": "0wGRjsa9F"
    },
    {
      "source": "2IqZI-qbW",
      "sourceHandle": "3",
      "target": "WM9qZx-iZ",
      "targetHandle": null,
      "id": "8t5SqiLwv"
    },
    {
      "source": "mkvJsTitle",
      "sourceHandle": "1",
      "target": "CRGqh1uOY",
      "targetHandle": null,
      "id": "cmdRen001"
    },
    {
      "source": "mkvJsTitle",
      "sourceHandle": "2",
      "target": "WM9qZx-iZ",
      "targetHandle": null,
      "id": "cmdFail01"
    },
    {
      "source": "CRGqh1uOY",
      "sourceHandle": "1",
      "target": "felUr0Dya",
      "targetHandle": null,
      "id": "D6jJ4fSUm"
    },
    {
      "source": "2IqZI-qbW",
      "sourceHandle": "1",
      "target": "mkvJsTitle",
      "targetHandle": null,
      "id": "Bb1XSKJ5v"
    },
    {
      "source": "rIy6G8-ZD",
      "sourceHandle": "1",
      "target": "FuVvu_aS5",
      "targetHandle": null,
      "id": "nBdL71x9i"
    },
    {
      "source": "fW33Ysqvw",
      "sourceHandle": "1",
      "target": "mW05MGb9_",
      "targetHandle": null,
      "id": "GZ5tPCeie"
    },
    {
      "source": "mW05MGb9_",
      "sourceHandle": "1",
      "target": "trAa2RjtE",
      "targetHandle": null,
      "id": "HgdjsdaJ1"
    },
    {
      "source": "trAa2RjtE",
      "sourceHandle": "1",
      "target": "NoN4weslN",
      "targetHandle": null,
      "id": "rBFdd-wb0"
    },
    {
      "source": "NoN4weslN",
      "sourceHandle": "1",
      "target": "2IqZI-qbW",
      "targetHandle": null,
      "id": "hCwxrmPYu"
    },
    {
      "source": "DGpKu7oHx",
      "sourceHandle": "2",
      "target": "Q3-nvE4O4",
      "targetHandle": null,
      "id": "Zj2qRIJeh"
    },
    {
      "source": "Q3-nvE4O4",
      "sourceHandle": "2",
      "target": "wFR5DUaSp",
      "targetHandle": null,
      "id": "rt4P0EcYT"
    },
    {
      "source": "Q3-nvE4O4",
      "sourceHandle": "1",
      "target": "TX_Pphtl8",
      "targetHandle": null,
      "id": "bf2PRX4_9"
    },
    {
      "source": "TX_Pphtl8",
      "sourceHandle": "2",
      "target": "wFR5DUaSp",
      "targetHandle": null,
      "id": "jnfkOg60n"
    },
    {
      "source": "FuVvu_aS5",
      "sourceHandle": "1",
      "target": "yEWLaQc4w",
      "targetHandle": null,
      "id": "cFs2kU5R4"
    },
    {
      "source": "yEWLaQc4w",
      "sourceHandle": "1",
      "target": "DGpKu7oHx",
      "targetHandle": null,
      "id": "ET0bmR_oW"
    },
    {
      "source": "yEWLaQc4w",
      "sourceHandle": "2",
      "target": "wFR5DUaSp",
      "targetHandle": null,
      "id": "skiplistFailQuarantine"
    },
    {
      "source": "e4lyBF7vs",
      "sourceHandle": "1",
      "target": "fW33Ysqvw",
      "targetHandle": null,
      "id": "8AoTJuFJ3"
    },
    {
      "source": "TX_Pphtl8",
      "sourceHandle": "1",
      "target": "e4lyBF7vs",
      "targetHandle": null,
      "id": "58OcfxKdT"
    },
    {
      "source": "felUr0Dya",
      "sourceHandle": "1",
      "target": "vVh6iX82G",
      "targetHandle": null,
      "id": "MdR4xjAY3"
    }
  ]
}

For immediate assistance, please email our customer support: [email protected]

Download RAW File