@elmotron9000/fmlpeg

Exposing useful functions for Elmotron9000 using fluent-ffmpeg.

Usage no npm install needed!

<script type="module">
  import elmotron9000Fmlpeg from 'https://cdn.skypack.dev/@elmotron9000/fmlpeg';
</script>

README

fmlpeg

Exposing useful functions for Elmotron9000 using fluent-ffmpeg.

Features

  • Concatenate videos
  • Add audio clips into videos
  • Get duration of media file
  • Generate video from photo
  • Generate subtitles for video
  • Allows videos of different resolutions
  • Embed subtitles into video file

How to Use

This exposes some useful functions for working with photos, audio, and video directly, but the intended purpose is primarily the SceneBuilder class with the Scene types for generating a single video containing audio clips, video clips, and slides.

You can import any of the helper functions from the package directly, such as getLengthOfFile.

To use SceneBuilder, import it from the module.

import { SceneBuilder } from "@elmotron9000/fmlpeg";

You can create a new SceneBuilder with a list of Scenes, or add them after the fact.

// Add scenes after creating it
const addingBuilder = new SceneBuilder();
const introSlide = {
    type: "photo",
    filename: "/tmp/photo0.png",
    duration: 15,
    audio: [],
};
const videoScene = {
    type: "video",
    filename: "/tmp/video0.mp4",
    audio: [],
};

addingBuilder.addScene(introSlide);
addingBuilder.addScene(videoScene);
await addingBuilder.build();

// Or pass them directly to the constructor
const constructorBuilder = new SceneBuilder([
    introSlide,
    videoScene,
]);
await constructorBuilder.build();

There are also build options that can be passed to the build() method. Subtitles are not generated by default.

export interface BuildOptions {
    subtitles: boolean;
    filename: string;
}

// Example usage
const builder = new SceneBuilder([
    // ... scenes
]);
await builder.build({
    subtitles: true,
    filename: "/tmp/final-cut.mp4",
});