Giter Club home page Giter Club logo

shotbit's Introduction

Shotbit

Shotbit is a NodeJS tool that allows you to extract movie scenes/shots easily.

ttt.mp4

Getting Started

To install Shotbit, run the following commands:

git clone [email protected]:andersonjoseph/shotbit.git
cd shotbit
pnpm install

Note: you must have ffmpeg installed

Usage

CLI

To use Shotbit CLI, run the following command:

pnpm cli -i <video-file> -o <output-path>

The following options are available:

Option Description Default
-o, --output Save the extracted scene or shot to the specified file. Required
-i, --input Set the resolution of the extracted scene or shot. Required
--similarityTreshold The similarity threshold parameter controls how similar the shots in a scene must be in order to be considered part of the same scene. A higher value will result in more scenes being extracted, while a lower value will result in fewer scenes being extracted. This parameter should be between 0 and 1 0
--minLength Set the minimum length of a shot in seconds. Shots shorter than the specified length will be ignored. 5
--noCache The no cache parameter controls whether or not the tool should use cached frames. If set, the tool will re-process all frames. This can be useful for debugging, but it can also slow down the process. false

Shotbit Class

The Shotbit class is the core class of Shotbit. It is used to generate and export shots and scenes. The class has a number of methods that allow you to control the generation and export process.


new Shotbit(options: ShotbitOptions)

The Shotbit constructor is used to create a new Shotbit instance to export shots from videos. The options parameter is a ShotbitOptions object that specifies the options for the Shotbit instance.

ShotbitOptions

Option Type Description Default
videoPath string The path to the input video file. Required
outputPath string The path to the output directory. Required
similarityTreshold number The similarity threshold for shot detection. 0
minLength number The minimum length of a shot in seconds. 5
noCache boolean Whether to disable caching of shot detection results. false

Example

import { Shotbit, ShotbitOptions } from 'shotbit';

const options: ShotbitOptions = {
  videoPath: 'input.mp4',
  outputPath: 'output',
  similarityTreshold: 0.5,
  minLength: 10,
  noCache: true,
};

const shotbit = new Shotbit(options);

Shotbit.getShots(): Promise<void>

The getShots() method begins the process of extracting shots from a video. It returns a void Promise that will be resolved when the extraction process is complete.


Shotbit.on(eventName: keyof ShotbitEvents)

The Shotbit class supports a list of events that fire when a process has begun or completed. These events can be used to track the progress of the Shotbit and to respond to events such as the completion of a process.

Here is a list of the events that the Shotbit class supports:

Event Description
started Shotbit process has started.
finished Shotbit process has finished running.
error An error has occurred.
startedRetrievingFrames The process of retrieving frames from a video has begun.
framesRetrieved The process of retrieving frames from a video has completed.
startedExportingShots The process of exporting shots from a video has begun.
shotsExported The process of exporting shots from a video has completed.

Example

shotbit.on('startedExportingShots', () => {
  // The shots extraction process has begun.
});

shotbit's People

Contributors

andersonjoseph avatar ciaokitty avatar

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.