diff --git a/docs/cli.md b/docs/cli.md index be77f4c..76e365f 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -107,7 +107,7 @@ For owner requests, `--timeout` also cancels Telegram RPCs and file uploads. Can - `--retries ` — retry transient network/transport failures for `send photo` (default: `2`). - `--retry-backoff` accepts either a millisecond value or `constant|linear|exponential`. - `--force-document` — send photo/video as uncompressed document. `send file` only. Without it `send file` sends `.mp4/.mov/.m4v/.webm/.mkv/.avi/.3gp` as a streamable video. - - `send video` always sends a streamable video; `--width/--height/--duration` override metadata, otherwise it is read with `ffprobe` when installed. `--no-streaming` disables progressive playback. + - `send video` always sends a streamable video; `--width/--height/--duration` override metadata, otherwise it is read with `ffprobe` when installed (PATH, Homebrew or `/usr/bin`; `TGCLI_FFPROBE` pins a binary). `--no-streaming` disables progressive playback. ## media - media download --chat --id [--output PATH] diff --git a/package-lock.json b/package-lock.json index d4f35ad..cbda322 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dapi/tgcli", - "version": "2.12.1", + "version": "2.12.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@dapi/tgcli", - "version": "2.12.1", + "version": "2.12.2", "license": "MIT", "dependencies": { "@modelcontextprotocol/sdk": "^1.27.1", diff --git a/package.json b/package.json index 537fd4a..70152f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dapi/tgcli", - "version": "2.12.1", + "version": "2.12.2", "type": "module", "description": "Telegram CLI + MCP server powered by MTProto and the official MCP SDK", "main": "mcp-server.js", diff --git a/telegram-client.js b/telegram-client.js index c113548..5d3b78d 100644 --- a/telegram-client.js +++ b/telegram-client.js @@ -317,10 +317,33 @@ function parseVideoDimension(value, name) { // Reads width/height/duration with ffprobe when it is installed; silently returns {} otherwise. // Telegram renders a video without these fields, but with them the preview keeps its aspect // ratio and shows the duration before playback. +// The tgcli wrapper runs with a minimal PATH, so look in the usual Homebrew/Linux +// locations as well; TGCLI_FFPROBE pins an explicit binary. +function resolveFfprobe() { + const candidates = [ + process.env.TGCLI_FFPROBE, + 'ffprobe', + '/opt/homebrew/bin/ffprobe', + '/usr/local/bin/ffprobe', + '/usr/bin/ffprobe', + ].filter(Boolean); + for (const candidate of candidates) { + if (candidate === 'ffprobe') { + const check = spawnSync('ffprobe', ['-version'], { stdio: 'ignore', timeout: 5_000 }); + if (check.status === 0) return candidate; + continue; + } + if (fs.existsSync(candidate)) return candidate; + } + return null; +} + function probeVideoMetadata(filePath) { if (process.env.TGCLI_DISABLE_FFPROBE === '1') return {}; + const ffprobe = resolveFfprobe(); + if (!ffprobe) return {}; try { - const probe = spawnSync('ffprobe', [ + const probe = spawnSync(ffprobe, [ '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'stream=width,height:format=duration',