UNPKG

clumsy-graphics

Version:

a tool for rapidly developing animations where frames are described using svg elements à la react 🙃

24 lines (23 loc) 1.01 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertAnimationMp4ToGif = void 0; const child_process_1 = __importDefault(require("child_process")); function convertAnimationMp4ToGif(api) { const { animationMp4SourcePath, animationGifOutputPath, gifAspectRatioWidth, } = api; // https://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality const aspectRatioScaleOption = gifAspectRatioWidth ? `scale=${gifAspectRatioWidth}:-1:flags=lanczos,` : ''; child_process_1.default.execSync(` ffmpeg \ -y \ -i ${animationMp4SourcePath} \ -vf "${aspectRatioScaleOption}split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \ -loop 0 \ ${animationGifOutputPath} `); } exports.convertAnimationMp4ToGif = convertAnimationMp4ToGif;