npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

reencoder-cli

v0.0.10

Published

Batch video reencode with ffmpeg and ffprobe. Project local configurations. Configurations variations. Glob support.

Downloads

27

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