-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5158943
commit 1f49bea
Showing
2 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
FlowPlugins/CommunityFlowPlugins/ffmpegCommand/ffmpegCommandSetVdeoFramerate/1.0.0/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.plugin = exports.details = void 0; | ||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */ | ||
var details = function () { return ({ | ||
name: 'Set Video Framerate', | ||
description: 'Set Video Framerate. If the original framerate is lower than the' | ||
+ ' specified framerate, the original framerate will be used.', | ||
style: { | ||
borderColor: '#6efefc', | ||
}, | ||
tags: 'video', | ||
isStartPlugin: false, | ||
pType: '', | ||
requiresVersion: '2.11.01', | ||
sidebarPosition: -1, | ||
icon: '', | ||
inputs: [ | ||
{ | ||
name: 'framerate', | ||
type: 'number', | ||
defaultValue: '30', | ||
inputUI: { | ||
type: 'text', | ||
}, | ||
tooltip: 'Specify framerate value', | ||
}, | ||
], | ||
outputs: [ | ||
{ | ||
number: 1, | ||
tooltip: 'Continue to next plugin', | ||
}, | ||
], | ||
}); }; | ||
exports.details = details; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
var plugin = function (args) { | ||
var lib = require('../../../../../methods/lib')(); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign | ||
args.inputs = lib.loadDefaultValues(args.inputs, details); | ||
var desiredFrameRate = Number(args.inputs.framerate); | ||
args.jobLog("Desired framerate: ".concat(desiredFrameRate)); | ||
args.variables.ffmpegCommand.streams.forEach(function (stream) { | ||
if (stream.codec_type === 'video') { | ||
var fileFramerateUsed = false; | ||
if (stream.avg_frame_rate) { | ||
var parts = stream.avg_frame_rate.split('/'); | ||
if (parts.length === 2) { | ||
var numerator = parseInt(parts[0], 10); | ||
var denominator = parseInt(parts[1], 10); | ||
if (numerator > 0 && denominator > 0) { | ||
var fileFramerate = numerator / denominator; | ||
args.jobLog("File framerate: ".concat(fileFramerate)); | ||
if (fileFramerate < desiredFrameRate) { | ||
args.jobLog('File framerate is lower than desired framerate. Using file framerate.'); | ||
stream.outputArgs.push('-r', "".concat(String(fileFramerate))); | ||
fileFramerateUsed = true; | ||
} | ||
else { | ||
args.jobLog('File framerate is greater than desired framerate. Using desired framerate.'); | ||
} | ||
} | ||
} | ||
} | ||
if (!fileFramerateUsed) { | ||
args.jobLog('Using desired framerate.'); | ||
stream.outputArgs.push('-r', "".concat(String(desiredFrameRate))); | ||
} | ||
} | ||
}); | ||
return { | ||
outputFileObj: args.inputFileObj, | ||
outputNumber: 1, | ||
variables: args.variables, | ||
}; | ||
}; | ||
exports.plugin = plugin; |
93 changes: 93 additions & 0 deletions
93
...PluginsTs/CommunityFlowPlugins/ffmpegCommand/ffmpegCommandSetVdeoFramerate/1.0.0/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { | ||
IpluginDetails, | ||
IpluginInputArgs, | ||
IpluginOutputArgs, | ||
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces'; | ||
|
||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */ | ||
const details = () :IpluginDetails => ({ | ||
name: 'Set Video Framerate', | ||
description: 'Set Video Framerate. If the original framerate is lower than the' | ||
+ ' specified framerate, the original framerate will be used.', | ||
style: { | ||
borderColor: '#6efefc', | ||
}, | ||
tags: 'video', | ||
isStartPlugin: false, | ||
pType: '', | ||
requiresVersion: '2.11.01', | ||
sidebarPosition: -1, | ||
icon: '', | ||
inputs: [ | ||
{ | ||
name: 'framerate', | ||
type: 'number', | ||
defaultValue: '30', | ||
inputUI: { | ||
type: 'text', | ||
}, | ||
tooltip: 'Specify framerate value', | ||
}, | ||
], | ||
outputs: [ | ||
{ | ||
number: 1, | ||
tooltip: 'Continue to next plugin', | ||
}, | ||
], | ||
}); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const plugin = (args:IpluginInputArgs):IpluginOutputArgs => { | ||
const lib = require('../../../../../methods/lib')(); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign | ||
args.inputs = lib.loadDefaultValues(args.inputs, details); | ||
|
||
const desiredFrameRate = Number(args.inputs.framerate); | ||
|
||
args.jobLog(`Desired framerate: ${desiredFrameRate}`); | ||
|
||
args.variables.ffmpegCommand.streams.forEach((stream) => { | ||
if (stream.codec_type === 'video') { | ||
let fileFramerateUsed = false; | ||
|
||
if (stream.avg_frame_rate) { | ||
const parts = stream.avg_frame_rate.split('/'); | ||
|
||
if (parts.length === 2) { | ||
const numerator = parseInt(parts[0], 10); | ||
const denominator = parseInt(parts[1], 10); | ||
|
||
if (numerator > 0 && denominator > 0) { | ||
const fileFramerate = numerator / denominator; | ||
|
||
args.jobLog(`File framerate: ${fileFramerate}`); | ||
|
||
if (fileFramerate < desiredFrameRate) { | ||
args.jobLog('File framerate is lower than desired framerate. Using file framerate.'); | ||
stream.outputArgs.push('-r', `${String(fileFramerate)}`); | ||
fileFramerateUsed = true; | ||
} else { | ||
args.jobLog('File framerate is greater than desired framerate. Using desired framerate.'); | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (!fileFramerateUsed) { | ||
args.jobLog('Using desired framerate.'); | ||
stream.outputArgs.push('-r', `${String(desiredFrameRate)}`); | ||
} | ||
} | ||
}); | ||
|
||
return { | ||
outputFileObj: args.inputFileObj, | ||
outputNumber: 1, | ||
variables: args.variables, | ||
}; | ||
}; | ||
export { | ||
details, | ||
plugin, | ||
}; |