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npm/get-video-metadata@1.0.5/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/get-video-metadata@1.0.5/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getVideoMetadata = void 0;\nconst mz_1 = require(\"mz\");\nconst process = require(\"process\");\n/**\n * Returns the Video-MetaData of a local file\n * @param {String} videoFile Path to local file\n * @throws {Error} Will get thrown if file does not exist, ffmpeg/ffprobe is missing or can not be read\n * @returns {VideoMetadata} Metadata of the local video-file\n */\nasync function getVideoMetadata(videoFile) {\n    const executable = process.env.FFPROBE_EXEC || 'ffprobe';\n    const output = (await mz_1.child_process.exec(`${executable} \n-v error \n    -select_streams v:0 \n    -show_entries stream=width,height,duration,codec_type,codec_name,codec_long_name,bit_rate,size,r_frame_rate\n    ${videoFile}`.replaceAll('\\n', '').replaceAll('\\r', ''), {\n        windowsHide: true\n    }).catch((reason) => {\n        throw new Error(reason);\n    }))[0];\n    const data = output.replaceAll('[STREAM]', '').replaceAll('[/STREAM]', '').split('\\n').filter(l => l !== '').reduce((acc, curr) => (acc[curr.split('=')[0]] = curr.split('=')[1], acc), {});\n    return {\n        codec: { name: data['codec_name'], longName: data['codec_long_name'], type: data['codec_type'] },\n        aspectRatio: determineAspectRatio(parseInt(data['width']), parseInt(data['height'])),\n        width: data['width'],\n        height: data['height'],\n        frameRate: data['r_frame_rate'].split('/')[0] / data['r_frame_rate'].split('/')[1],\n        bitRate: data['bit_rate'],\n        duration: data['duration']\n    };\n}\nexports.getVideoMetadata = getVideoMetadata;\nfunction determineAspectRatio(width, height) {\n    const divider = gcd(width, height);\n    return `${width / divider}:${height / divider}`;\n}\nfunction gcd(a, b) {\n    a = Math.abs(a);\n    b = Math.abs(b);\n    if (b > a) {\n        const temp = a;\n        a = b;\n        b = temp;\n    }\n    while (true) {\n        if (b == 0)\n            return a;\n        a %= b;\n        if (a == 0)\n            return b;\n        b %= a;\n    }\n}\n"]}