@kevingodell/node-red-ffmpeg
Advanced tools
Comparing version 0.1.1-beta.1 to 0.1.1-beta.2
@@ -7,3 +7,3 @@ 'use strict'; | ||
const { | ||
settings, | ||
settings: { ffmpeg: ffmpegSettings }, | ||
_, | ||
@@ -13,2 +13,20 @@ nodes: { createNode, registerType }, | ||
const FFMPEG = (() => { | ||
const defaults = { cmdPath: 'ffmpeg', cmdOutputsMax: 5, secretType: 'text' }; | ||
if (ffmpegSettings instanceof Object) { | ||
const { cmdPath, cmdOutputsMax, secretType } = ffmpegSettings; | ||
ffmpegSettings.cmdPath = /ffmpeg/i.test(cmdPath) ? cmdPath.trim() : defaults.cmdPath; | ||
ffmpegSettings.cmdOutputsMax = Number.isInteger(cmdOutputsMax) && cmdOutputsMax > 5 ? cmdOutputsMax : defaults.cmdOutputsMax; | ||
ffmpegSettings.secretType = ['password', 'text'].includes(secretType) ? secretType : defaults.secretType; | ||
return ffmpegSettings; | ||
} | ||
return defaults; | ||
})(); | ||
class FfmpegNode { | ||
@@ -291,20 +309,2 @@ constructor(config) { | ||
static validateCmdPath(cmdPath) { | ||
if (!/ffmpeg/i.test(cmdPath)) { | ||
throw new Error(_('ffmpeg.error.cmd_path_invalid', { cmdPath })); | ||
} | ||
} | ||
static validateCmdArgs(cmdArgs) { | ||
if (!Array.isArray(cmdArgs)) { | ||
throw new Error(_('ffmpeg.error.cmd_args_invalid', { cmdArgs })); | ||
} | ||
} | ||
static validateCmdOutputs(cmdOutputs) { | ||
if (!Number.isInteger(cmdOutputs) || cmdOutputs < 0 || cmdOutputs > cmdOutputsMax) { | ||
throw new Error(_('ffmpeg.error.cmd_outputs_invalid', { cmdOutputs })); | ||
} | ||
} | ||
createTopics() { | ||
@@ -367,2 +367,20 @@ const base = `ffmpeg/${this.id}/`; | ||
static validateCmdPath(cmdPath) { | ||
if (!/ffmpeg/i.test(cmdPath)) { | ||
throw new Error(_('ffmpeg.error.cmd_path_invalid', { cmdPath })); | ||
} | ||
} | ||
static validateCmdArgs(cmdArgs) { | ||
if (!Array.isArray(cmdArgs)) { | ||
throw new Error(_('ffmpeg.error.cmd_args_invalid', { cmdArgs })); | ||
} | ||
} | ||
static validateCmdOutputs(cmdOutputs) { | ||
if (!Number.isInteger(cmdOutputs) || cmdOutputs < 0 || cmdOutputs > FfmpegNode.cmdOutputsMax) { | ||
throw new Error(_('ffmpeg.error.cmd_outputs_invalid', { cmdOutputs })); | ||
} | ||
} | ||
static jsonParse(str) { | ||
@@ -377,28 +395,8 @@ try { | ||
const { cmdPath, cmdOutputsMax, secretType } = (() => { | ||
const ffmpegSettings = settings.get('ffmpeg'); | ||
FfmpegNode.cmdPath = FFMPEG.cmdPath; | ||
const defaults = { cmdPath: 'ffmpeg', cmdOutputsMax: 5, secretType: 'text' }; | ||
FfmpegNode.cmdOutputsMax = FFMPEG.cmdOutputsMax; | ||
if (ffmpegSettings instanceof Object) { | ||
let { cmdPath, cmdOutputsMax, secretType } = ffmpegSettings; | ||
FfmpegNode.secretType = FFMPEG.secretType; | ||
ffmpegSettings.cmdPath = /ffmpeg/i.test(cmdPath) ? cmdPath.trim() : defaults.cmdPath; | ||
ffmpegSettings.cmdOutputsMax = Number.isInteger(cmdOutputsMax) && cmdOutputsMax > 5 ? cmdOutputsMax : defaults.cmdOutputsMax; | ||
ffmpegSettings.secretType = ['password', 'text'].includes(secretType) ? secretType : defaults.secretType; | ||
return ffmpegSettings; | ||
} | ||
return defaults; | ||
})(); | ||
FfmpegNode.cmdPath = cmdPath; | ||
FfmpegNode.cmdOutputsMax = cmdOutputsMax; | ||
FfmpegNode.secretType = secretType; | ||
FfmpegNode.type = 'ffmpeg'; | ||
@@ -408,11 +406,7 @@ | ||
credentials: { | ||
secret: { type: secretType }, | ||
secret: { type: FFMPEG.secretType }, | ||
}, | ||
settings: { | ||
ffmpeg: { | ||
value: { | ||
cmdPath, | ||
cmdOutputsMax, | ||
secretType, | ||
}, | ||
value: FFMPEG, | ||
exportable: true, | ||
@@ -419,0 +413,0 @@ }, |
{ | ||
"name": "@kevingodell/node-red-ffmpeg", | ||
"version": "0.1.1-beta.1", | ||
"description": "Spawn a long running ffmpeg process to handle video/image processing.", | ||
"version": "0.1.1-beta.2", | ||
"description": "Spawn a long-running ffmpeg process to handle video/image processing.", | ||
"main": "ffmpeg.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
# @kevingodell/node-red-ffmpeg | ||
###### | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://raw.githubusercontent.com/kevinGodell/node-red-ffmpeg/master/LICENSE) | ||
[![npm](https://img.shields.io/npm/dt/@kevingodell/node-red-ffmpeg.svg?style=flat-square)](https://www.npmjs.com/package/@kevingodell/node-red-ffmpeg) | ||
[![GitHub issues](https://img.shields.io/github/issues/kevinGodell/node-red-ffmpeg.svg)](https://github.com/kevinGodell/node-red-ffmpeg/issues) | ||
@@ -11,3 +15,3 @@ **A [Node-RED](https://nodered.org/) node used for spawning a long-running [ffmpeg](https://ffmpeg.org/) process to handle video/image processing.** | ||
* If you have difficulties making it work, please open a new [discussion](https://discourse.nodered.org/) and tag me `@kevinGodell`. | ||
* Please, do not send private messages asking for help because that will not benefit others with similar issues. | ||
* Do not send private messages asking for help because that will not benefit others with similar issues. | ||
@@ -23,6 +27,2 @@ ### Installation: | ||
``` | ||
* using yarn | ||
``` | ||
yarn add @kevingodell/node-red-ffmpeg | ||
``` | ||
* reboot the node-red server | ||
@@ -29,0 +29,0 @@ ``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41449
977