diff --git a/FlowPluginsTs/FlowHelpers/1.0.0/cliParsers.ts b/FlowPluginsTs/FlowHelpers/1.0.0/cliParsers.ts index 4c9bded..1429e74 100644 --- a/FlowPluginsTs/FlowHelpers/1.0.0/cliParsers.ts +++ b/FlowPluginsTs/FlowHelpers/1.0.0/cliParsers.ts @@ -39,6 +39,28 @@ const handbrakeParser = ({ return percentage; }; +const getHandBrakeFps = ({ + str, +}: { + str: string, +}): number => { + try { + if (typeof str !== 'string' || !(str.includes('(') && str.includes('fps'))) { + return 0; + } + + const out = parseInt(str.split('(')[1].split('fps')[0].trim(), 10); + + // eslint-disable-next-line no-restricted-globals + if (!isNaN(out)) { + return out; + } + } catch (err) { + // err + } + return 0; +}; + // frame= 889 fps=106 q=26.0 Lsize= 25526kB time=00:00:35.69 bitrate=5858.3kbits/s speed=4.25x const getFFmpegVar = ({ str, @@ -227,5 +249,6 @@ export { ffmpegParser, getFFmpegPercentage, getFFmpegVar, + getHandBrakeFps, editreadyParser, }; diff --git a/FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts b/FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts index 6da999c..4bb36cb 100644 --- a/FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts +++ b/FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts @@ -1,4 +1,6 @@ -import { editreadyParser, ffmpegParser, handbrakeParser } from './cliParsers'; +import { + editreadyParser, ffmpegParser, getHandBrakeFps, handbrakeParser, +} from './cliParsers'; import { Ilog, IupdateWorker } from './interfaces/interfaces'; import { IFileObject, Istreams } from './interfaces/synced/IFileObject'; @@ -182,6 +184,16 @@ class CLI { percentage, }); } + + const fps = getHandBrakeFps({ + str, + }); + + if (fps > 0) { + this.config.updateWorker({ + fps, + }); + } } else if (this.config.cli.toLowerCase().includes('ffmpeg')) { const n = str.indexOf('fps'); const shouldUpdate = str.length >= 6 && n >= 6;