Skip to content

Fix embedding/playback of portrait 4K videos, bump max video resolution to 8K#30683

Open
comdev1337 wants to merge 1 commit into
telegramdesktop:devfrom
comdev1337:fix-video-max-frame-size
Open

Fix embedding/playback of portrait 4K videos, bump max video resolution to 8K#30683
comdev1337 wants to merge 1 commit into
telegramdesktop:devfrom
comdev1337:fix-video-max-frame-size

Conversation

@comdev1337

Copy link
Copy Markdown
Contributor

Fixes #30678
See: #30678 (comment)

  • FFmpeg may validate decoder-allocation dimensions, not just visible frame dimensions. Some H.264/HEVC frames are internally padded for alignment, so a visible 2160x3840 frame can trip max_pixels even though 2160 * 3840 == 3840 * 2160. The patch keeps Telegram’s real visible-frame validation intact, but gives FFmpeg max_pixels a small alignment slack.
  • The upload/playback frame-area cap is raised from 4K to 8K, 7680x4320 videos can be embedded
  • 8K videos must not allocate full-size ARGB thumbnails/cover frames during inspection. A full 7680x4320 BGRA image is ~126 MiB and exceeds the existing 64 MiB frame-storage check, so the patch renders small thumbnail/cover frames while preserving the real video dimensions separately.
  • Video document attributes now use the decoded video dimensions, not the generated thumbnail size, so scaled-down thumbnails do not accidentally turn an 8K video into 320x180 metadata.
  • Playback startup now reads dimensions from the decoded frame metadata first and waits for the UI’s requested render size before allocating image storage, avoiding full-resolution first-frame allocation.

@comdev1337 comdev1337 changed the title Fix embedding/playback of portrait 4K videos, bump kMaxFrameArea to 8K Fix embedding/playback of portrait 4K videos, bump max video resolution to 8K May 11, 2026
@john-preston

Copy link
Copy Markdown
Member

Thanks for fixing the regression. But other changes I don't think are desired right now, they can be discussed, but separate from regression fix for the files that played before but stopped playing in the latest version.

I don't want to raise sending / playable files dimensions to 8K, they were never sent / played before and this change has nothing to do with recent regression. Also, rendering the initial frame in streaming downscaled to isn't what I want, because I cache that frame separately as a "full first frame", and 320x320 won't be good for most of the videos.

@john-preston

Copy link
Copy Markdown
Member

For now I've merged the fixing regression part.

@comdev1337 comdev1337 force-pushed the fix-video-max-frame-size branch from 958f34c to d103e9e Compare May 12, 2026 09:51
@comdev1337 comdev1337 force-pushed the fix-video-max-frame-size branch from d103e9e to e7dc330 Compare May 12, 2026 09:57
@comdev1337

Copy link
Copy Markdown
Contributor Author

Fair enough, I should have split these. Removed the 665a288 part.

Also, rendering the initial frame in streaming downscaled to isn't what I want, because I cache that frame separately as a "full first frame", and 320x320 won't be good for most of the videos.

Bumped kMaxFrameStorageBytes to 128 MiB instead

@kalandrack69

Copy link
Copy Markdown

Day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weird behavior of 4K video uploads

3 participants