UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

5 lines • 1.81 kB
import{o as normalizeLowercaseStringOrEmpty}from"./string-coerce-CpTFcSwY.mjs";import{t as resolveSystemBin}from"./resolve-system-bin-BxjtTRjs.mjs";import{n as runExec}from"./exec-c5tqm8tb.mjs"; //!src/media/ffmpeg-limits.ts const MEDIA_FFMPEG_MAX_BUFFER_BYTES=10485760;const MEDIA_FFPROBE_TIMEOUT_MS=1e4;const MEDIA_FFMPEG_TIMEOUT_MS=45e3;const MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS=1200; //!src/media/ffmpeg-exec.ts function resolveExecOptions(e,t){if(t?.input!==void 0&&t.stdinFileDescriptor!==void 0)throw new Error(`media exec accepts either input or stdinFileDescriptor, not both`);return{input:t?.input,...t?.stdinFileDescriptor!==void 0?{stdinFileDescriptor:t.stdinFileDescriptor}:{},logOutput:false,maxBuffer:t?.maxBufferBytes??10485760,timeoutMs:t?.timeoutMs??e}}function requireSystemBin(e){const t=resolveSystemBin(e,{trust:`standard`});if(!t){const t=process.platform===`darwin`?`e.g. brew install ffmpeg`:`e.g. apt install ffmpeg / dnf install ffmpeg`;throw new Error(`${e} not found in trusted system directories. Install it via your system package manager (${t}).`)}return t}function resolveFfmpegBin(){return requireSystemBin(`ffmpeg`)}async function runFfprobe(e,t){const{stdout:n}=await runExec(requireSystemBin(`ffprobe`),e,resolveExecOptions(MEDIA_FFPROBE_TIMEOUT_MS,t));return n}async function runFfmpeg(e,t){const{stdout:n}=await runExec(resolveFfmpegBin(),e,resolveExecOptions(MEDIA_FFMPEG_TIMEOUT_MS,t));return n}function parseFfprobeCodecAndSampleRate(e){const[t,n]=e.trim().split(/[,\r\n]+/,2).map(e=>normalizeLowercaseStringOrEmpty(e));const r=n&&/^\d+$/.test(n)?Number(n):0;return{codec:t||null,sampleRateHz:Number.isSafeInteger(r)&&r>0?r:null}}export{MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS as a,runFfprobe as i,resolveFfmpegBin as n,runFfmpeg as r,parseFfprobeCodecAndSampleRate as t};