@elmotron9000/fmlpeg
v0.2.0
Published
Exposing useful functions for Elmotron9000 using `fluent-ffmpeg`.
Downloads
37
Readme
fmlpeg
Exposing useful functions for Elmotron9000 using fluent-ffmpeg
.
Features
- [x] Concatenate videos
- [x] Add audio clips into videos
- [x] Get duration of media file
- [x] Generate video from photo
- [x] Generate subtitles for video
- [x] Allows videos of different resolutions
- [x] 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",
});