Untitled

 avatar
unknown
plain_text
2 years ago
520 B
6
Indexable
const ffmpeg = require('fluent-ffmpeg');
const fs = require('fs');

const videoPath = '/path/to/video.mp4';
const outputFolder = '/path/to/output/folder';
const frames = [100, 200, 300]; // frames to extract images from

// create the output folder if it doesn't exist
if (!fs.existsSync(outputFolder)) {
  fs.mkdirSync(outputFolder);
}

// extract images from the frames
frames.forEach(frame => {
  ffmpeg(videoPath)
    .seekInput(frame)
    .frames(1)
    .output(`${outputFolder}/frame-${frame}.png`)
    .run();
});