UNPKG

@calipsa/video-utils

Version:
30 lines 1.19 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const fluent_ffmpeg_1 = __importDefault(require("fluent-ffmpeg")); const stream_utils_1 = require("@calipsa/stream-utils"); exports.default = async ({ path, rate = 1, format = 'jpg', ffmpegCommandOptions, configureFfmpeg, }) => new Promise((resolve, reject) => { const outStream = new stream_utils_1.StreamWithFrames(rate); const vcodec = format === 'png' ? 'png' : 'mjpeg'; const proc = (0, fluent_ffmpeg_1.default)(path, ffmpegCommandOptions) .output(outStream, { end: true, }) .noAudio() .format('image2pipe') // -f .videoCodec(vcodec) // -vcodec .size('640x480') .outputOption('-q:v', '2') .on('error', reject) // .on('start', commandLine => { // console.log(`Spawned Ffmpeg with command: ${commandLine}`) // }) .on('end', () => { resolve(outStream.buffers); }); configureFfmpeg?.(proc); proc.run(); }); //# sourceMappingURL=index.js.map