Repository navigation
feat(send): send an MP4 or MOV file as a video - #238
Open
ertembiyik wants to merge 1 commit into
Open
ertembiyik wants to merge 1 commit into
ertembiyik wants to merge 1 commit into
Conversation
3 tasks done
ertembiyik
force-pushed
the
ertembiyik/send-video
branch
from
November 25, 2026 07:04
0f6afb9 to
3fd9833
Compare
tg send --file sent every non-photo file with force_file, so a video arrived as a file to download and never played in the chat. A file whose video track can be read now goes with documentAttributeVideo: duration and frame size come from its moov box, supports_streaming is set when the index precedes the data. The file is uploaded as it is. --force-document keeps the old result, and a video file that cannot be read stays a document. Co-Authored-By: Claude Fable 5.2 <[email protected]>
ertembiyik
force-pushed
the
ertembiyik/send-video
branch
from
November 25, 2026 07:06
3fd9833 to
b890578
Compare
This was referenced Nov 25, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
tg send --file clip.mp4posts a video as a file to download: every non-photo upload setsforce_file(d50d90d), so nothing plays in the chat, and there is no way around it, sincetg apican't upload. An MP4 or MOV file now goes as a video, the way JPEG, PNG and WebP images go as photos.--force-documentsends it as a file, as before.Before (0.16.0, trimmed)
After
How it works
src/utils/video-metadata.tsreads the file'smoovbox: the duration frommvhd, the frame size from the video track'stkhd, swapped when the video is stored sideways (a phone held upright). About 120 lines, no dependency and no ffmpeg.inputMediaUploadedDocumentwithdocumentAttributeVideoand the file name, withoutforce_file.supports_streamingis set only whenmoovcomes beforemdat.video/*, has no video track or is cut short goes as a document. WebM and MKV stay documents.Yours to decide
This changes the default for existing callers: an MP4 that arrived as a file now arrives as a video. I followed the rule photos already have (by type,
--force-documentto opt out). If you prefer opt-in, say so and I'll put it behind a flag: it is one condition insendFile.Independent of #239 (a caption formatted with
--html). Both edit the same paragraphs ofdocs/media.mdanddocs/cli-commands.md; I will mergemaininto whichever is left after the first one lands.How I checked it
Unit tests: the reader on made-up MP4 bytes (32- and 64-bit times, sideways, data before the index, no video track, another format, a cut file); the
messages.sendMediarequest for a video, for--force-documentand for a video file that can't be read.The reader against real encoder output, locally: MP4, MOV, a rotated clip, one without faststart, a fragmented one, an audio-only M4A and a WebM, compared with
ffprobe.Live, one send to Saved Messages of a 3-second 640×360 test clip:
sentAs: "video"; the stored message has thevideoflag,documentAttributeVideowith duration 3, 640×360 andsupports_streaming, and two thumbnails Telegram made.bun run check,bun run test(1346 pass),bun run test:e2e(438 pass).Not covered: the live suite still sends only made-up bytes as a document. A video without sound wasn't tried. A fragmented MP4 is sent with duration 0, since its
mvhdhas none.Tests pass locally and use made-up data only
README, docs and affected demos follow the product content standard
Title follows the repo's commit style: Conventional Commits (
feat: …,fix: …) unlessAGENTS.mdsays otherwise🤖 Generated with Claude Code