Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ For owner requests, `--timeout` also cancels Telegram RPCs and file uploads. Can
- `--retries <n>` — 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|username> --id <msgId> [--output PATH]
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
25 changes: 24 additions & 1 deletion telegram-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading