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

yaffu

v2.1.0

Published

Yet Another FFmpeg Util

Downloads

36

Readme

yaffu - Yet Another FFmpeg Util

Programmatically combine videos into a merged output with a dynamic layout.

grid

Dependencies

  • FFmpeg
  • Node 20

Install

npm install yaffu@latest

Example

Run the example/grid.js script which demos genericCombine (mixes all audio and stacks all video on a centered grid):

git clone https://github.com/erwinv/yaffu
cd yaffu

corepack enable
corepack install

# build modules
pnpm install
pnpm build

# run examples
cd example
pnpm install
node grid.js

Output (1080p)

https://github.com/erwinv/yaffu/assets/1235980/4523aca7-e1ea-48d0-9913-081ce9996433

Using genericCombine is as simple as:

import { ffmux, genericCombine } from 'yaffu'

const inputPaths = [
  //...
]
await ffmux(genericCombine(inputPaths, 'combined.mp4'))

Timeline Example

Suppose audio/video inputs are given with the following timeline:

        0    5    10   15   20   25   30   35   40   45   50   55   60   65   70   75   80
--------|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|--
alice        [===========]                 [=======================================]
bob             [===========]                   [========================]
charlie            [===========]                     [==============]
david                 [===========]                       [====]
screen                                [=======================================]

See example/timeline.js to see how to encode the above timeline using the API.

Output (720p)

https://github.com/erwinv/yaffu/assets/1235980/ad6e7a41-a0ad-46f5-a7a4-5e30a07ec0c3

API

High-level API

  • mixAudio downmixes and mixes all input audio to stereo
  • compositeGrid stacks all video input on a grid layout (max 16 or 4x4 grid)
  • compositePresentation main tile (presentation) on the left, vertically stacked tiles on the right (max 4)
  • genericCombine is a convenient wrapper that does both mixAudio and compositeGrid

Low-level API

  • FilterGraph filter graph builder class
  • ffmux executes the filter graph and muxes to the defined output
  • ffconcatDemux concatenates all input files using FFmpeg's concat demuxer
  • ffprobe probe media file's metadata
import { FilterGraph, ffmux } from 'yaffu'

const inputPaths = [
  //...
]

const graph = new FilterGraph(inputPaths)

// build filter graph by piping streams through filters to output streams
graph
  .pipe(['0:a', '1:a'], ['aout']) // input stream ids, output stream ids
  .filter('amix', [], { normalize: 0 }) // filter name, direct options, key-value options
  .filter('dynaudnorm') // filter with no opts (use default opts)

// map stream/s to output file
graph.map(['aout'], 'output.aac')

// run the muxer
await ffmux(graph)