UNPKG

framo

Version:

Glorious media processing right in your browser with Typescript support

52 lines 2.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Utility = void 0; const filmstrip_model_1 = require("../models/filmstrip.model"); class Utility { static getScale(dimensions) { var _a, _b; if (!dimensions.height && !dimensions.width) { return ''; } return `scale=${(_a = dimensions.width) !== null && _a !== void 0 ? _a : -2}:${(_b = dimensions.height) !== null && _b !== void 0 ? _b : -2}`; } static getFrameCount(mediainfoResult) { var _a, _b, _c; return parseInt((_c = (_b = (_a = mediainfoResult.media) === null || _a === void 0 ? void 0 : _a.track[0]) === null || _b === void 0 ? void 0 : _b.FrameCount) !== null && _c !== void 0 ? _c : 0, 10); } static getVideoDuration(mediainfoResult) { var _a, _b, _c; return parseFloat((_c = (_b = (_a = mediainfoResult.media) === null || _a === void 0 ? void 0 : _a.track[0]) === null || _b === void 0 ? void 0 : _b.Duration) !== null && _c !== void 0 ? _c : '0'); } static getOutputFilename(index, extension) { return `out_${index}_${Date.now()}.${extension}`; } static getFilmstripTileString(totalFramesInFilmstrip, config) { let tileString = `tile=`; if (config.orientation === filmstrip_model_1.FilmstripOrientation.HORIZONTAL) { tileString += `${totalFramesInFilmstrip}x1`; } else { tileString += `1x${totalFramesInFilmstrip}`; } if (config.padding) { tileString += `:padding=${config.padding}`; } if (config.margin) { tileString += `:margin=${config.margin}`; } if (config.color) { tileString += `:color=${config.color}`; } if (config.initPadding) { tileString += `:init_padding=${config.initPadding}`; } return tileString; } static getFilenameWithPadding(index, prefix, totalDigitsInFilename, extension) { const filenumber = index.toString().padStart(totalDigitsInFilename, "0"); return `${prefix}_${filenumber}.${extension}`; } } exports.Utility = Utility; //# sourceMappingURL=utility.js.map