reencoder-cli
v0.0.10
Published
Batch video reencode with ffmpeg and ffprobe. Project local configurations. Configurations variations. Glob support.
Downloads
4
Readme
reencoder-cli
Batch video reencode with ffmpeg and ffprobe. Project local configurations. Configurations variations. Glob support.
Installation
Globally as a cli
npm install -g reencoder-cli
Locally as a library
npm install -s reencoder-cli
Configuration
Add .reencoderrc.json
to the execution directory or any of its parents.
See examples in the 'examples/' directory.
{
"description": "The example is for repeatedly converting and collating videos in nested subdirectories to a uniform format, 1080p, 720p or 480p.",
"description": "It will skip files which exist in the output dir already and it will not clear the output folder.",
"inputDir": "./",
"outputDir": "./Converted",
"clearOutputDir": false,
"default": "720",
"concurrency": 1,
"parameters": [
"-hwaccel", "auto",
"-i", "@@inputDir/**/*@(.mp4|.mov|.avi|.wmv)",
{
"1080": [
"-vf", "scale=trunc(oh*a/2)*2:1080",
"-maxrate", "2M",
"-preset", "fast",
"-b:a", "128k",
"-r", 24,
"-profile:v", "high",
"-tune", "film",
"-level", "4.1",
"-movflags", "+faststart",
"-bufsize", "2M",
"-ac", 2,
"-ar", 44100,
"@@outputDir/@@inputFileName.@@outputGroupName.mp4"
],
"720": [
"-vf", "scale=trunc(oh*a/2)*2:720",
"-maxrate", "1.2M",
"-preset", "fast",
"-b:a", "128k",
"-r", 24,
"-profile:v", "high",
"-tune", "film",
"-level", "4.1",
"-movflags", "+faststart",
"-bufsize", "2M",
"-ac", 2,
"-ar", 44100,
"@@outputDir/@@inputFileName.@@outputGroupName.mp4"
],
"480": [
"-vf", "scale=trunc(oh*a/2)*2:480",
"-maxrate", "0.8M",
"-preset", "fast",
"-b:a", "128k",
"-r", 24,
"-profile:v", "high",
"-tune", "film",
"-level", "4.1",
"-movflags", "+faststart",
"-bufsize", "2M",
"-ac", 2,
"-ar", 44100,
"@@outputDir/@@inputFileName.@@outputGroupName.mp4"
]
}
]
}
Options
default : Defaults to ''
. Specifies which named groups should run. If unspecified will run all groups.
inputDir : Defaults to './'
.
outputDir : Defaults to './Converted'
.
concurrency : Defaults to 1
. Specifies the number of encodes to run in parallel.
clearOutputDir : Defaults to false
.
Parameters
Irregular
-i : The standard input parameter for ffmpeg is a glob.
-y : The absence of -y
assumes -n
, which instead of overwriting is to skip without prompt.
Reference: main options
Objects
Parameters included as named values of objects will be included in the ffmpeg execution parameters only when their name matches, (when a library) an entry in the outputGroupNames
variable, or (when a cli) arguments in the terminal.
This allows for some simple configuration variations.
Objects can be nested.
String replacement
Available string replacement variables are declared here:
@@inputFile : Absolute input file path.
@@inputFileBase : Full file name, including extension.
@@inputFileBaseSanitized : Full file name, including extension, with special characters and spaces removed.
@@inputFileBaseSanitizedLowerCase : Full file name, including extension, with special characters and spaces removed, lowercase.
@@inputFileDir : Sub directory relative to inputDir
.
@@inputFileExt : File extension.
@@inputFileName : Front part of the file name.
@@inputFileNameSanitized : Front part of the file name, with special characters and spaces removed.
@@inputFileNameSanitizedLowerCase : Front part of the file name, with special characters and spaces removed, lowercase.
@@outputDir : Absolute output file path.
@@outputGroupName : Nested configuration name.
Execution
With default output:
$ reencoder
With specified outputs:
$ reencoder 1080 720 480
As a library:
const { reencode, getConfig } = require('reencoder-cli')
const config = getConfig(); // Lookup .reencoderrc.json
const promise = reencode({
config, // Config can be specified here, or it will be fetched from .reencoderrc.json through parent directories
status = (state) => console.log( // Outputs to console: reencode 6.25% 1/3 18.75% nested/one.mp4
state.mode,
state.totalPercentComplete,
`${state.currentItem}/${state.total}`,
state.currentPercentComplete,
state.currentInputFile
)
})
await promise; // promise.kill() will prematurely terminate the reencoding