Menu

Compressing videos to an exact 8 MB limit locally in the browser
πŸ“°

Compressing videos to an exact 8 MB limit locally in the browser

DEV Community: frontendΒ·eRechnung-KI.deΒ·1 day ago
#P4F0FV0g
#devtofrontend#devto#dev#kbps#1080p
Long article (318 words) β€” no AI summary yet.
Reading 0:00
15s threshold

Upload forms say "max 8 MB". The file is 41 MB. Most compressors will make it smaller; few let you say this small, and almost none tell you what that costs in bitrate before you commit.

The arithmetic first

For fixed duration and frame rate, the target splits into audio and video:

video_bitrate = ( target_bytes - audio_bytes ) * 8 / duration_seconds / 1000

Enter fullscreen mode

Exit fullscreen mode

8 MB is 8,388,608 bytes. At 128 kbps audio and a 90-second clip, audio takes 1,440,000 bytes, leaving about 6.9 MB β€” roughly 615 kbps for video. At 615 kbps a 1080p talking head is fine; a 1080p screen recording of code is not.

So the resolution should follow the budget:

Duration Budget after audio Suggested resolution

30 s ~1,900 kbps 1080p

90 s ~615 kbps 720p

5 min ~180 kbps 480p

Skipping that step gives you 1080p at 180 kbps, which is not compression.

Why local processing is the right default

Uploading 41 MB to a stranger's server to get 8 MB back means waiting, trusting a retention policy, and…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.