Coder Social home page Coder Social logo

prevvy's Introduction

prevvy

insanity54

Create a tiled video preview image using ffmpeg... FAST!

Motivation

FFmpeg has this capability built in...

ffmpeg -i ./example.mp4 -y -vframes 1 -q:v 2 -vf 'select=not(mod(n\,23744)),scale=160:-1,tile=6x5:color=Black' output.jpg

... but for long videos, it is very slow. This is because ffmpeg must process every frame in the video, a task that is not well suited for microinstances in datacenters.

This module is designed to accomplish the job of getting a tiled screenshot image FAST, by calling ffmpeg multiple times in parallel, each time using ffmpeg's Input Seeking feature to seek to a point in the video, take a 1 frame snapshot, before combining all the snapshots together (again with ffmpeg) to form a tiled image of snapshots.

Example Output

Image Output Example

Caveats

  • This project addresses speed for large (several GB) videos only. On small size videos, this module is potentially slower than using FFmpeg's tile filter.
  • Frame selection accuracy is not a priority. In other words, the frames selected to be combined into the output are not going to be the same frames that ffmpeg would have chosen, given the same options.

API Usage

  const videoPath = '/tmp/input.mp4'
  const imagePath = '/tmp/output.png';

  let options = {
    input: videoPath,
    output: imagePath,
    width: 128,
    cols: 6,
    rows: 3
  };

  let prevvy = new Prevvy(options);

  /**
   * Optional: the prevvy instance extends EventEmitter, emitting progress events.
   */
  prevvy.on('progress', async (data: { percentage: number }) => {
    await job.updateProgress(data.percentage);
  });

  await prevvy.generate();

CLI Usage

DEBUG=prevvy node ./cli.js generate --input 'https://example.com/my-video.mp4' --output ./my-storyboard.png

prevvy's People

Contributors

insanity54 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

prevvy's Issues

spawn ffprobe ENOENT

(node:8544) UnhandledPromiseRejectionWarning: Error: spawn ffprobe ENOENT

(node:8544) UnhandledPromiseRejectionWarning: Error: spawn ffprobe ENOENT
at notFoundError (\node_modules\cross-spawn\lib\enoent.js:6:26)
at verifyENOENT (\node_modules\cross-spawn\lib\enoent.js:40:16)
at ChildProcess.cp.emit (\node_modules\cross-spawn\lib\enoent.js:27:25)
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)

Error: ffmpeg exited with code 1: Error initializing complex filters.

| Error: ffmpeg exited with code 1: Error initializing complex filters.
| Invalid argument
|
|     at ChildProcess.<anonymous> (/futureporn/node_modules/fluent-ffmpeg/lib/processor.js:182:22)
|     at ChildProcess.emit (node:events:378:20)
|     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
| Thumbnail process complete.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.