Video Compressor
Operator: Abdulla Al Fahad. How tools are built and checked
Most phone video is recorded at a size that email and chat apps refuse: a two-minute clip can run past 100 MB. Re-encoding it is the usual fix, but the common routes are an upload to someone's server or a desktop program. This page does the re-encode in the browser tab, so the file stays on your computer, and you set the trade-off directly: a target size in megabytes or a quality preset, then a resolution cap, a frame rate, and whether the sound stays.
The trade-off you accept is time. A web page has no way to drive a fast hardware encoder, so the browser plays the chosen part of the video at normal speed, draws every frame at the new size, and records that canvas with MediaRecorder. A two-minute range takes about two minutes. The page shows a progress bar with the time left and a Cancel button, and it shows the sizes before and after so you can see whether the file actually got smaller.
Key features
- Reads MP4, WebM, MOV and M4V through the browser's own decoder, and shows the resolution, length, file size and average bitrate.
- Trim start and end, typed in seconds or minutes and seconds, or copied from the player's current time.
- A target size in megabytes with 8, 10, 25 and 50 MB shortcuts, or a quality preset from Smallest file to High quality.
- Resolution limit of 1080, 720, 480 or 360 px on the shorter side, never enlarging.
- Frame rate of original, 30, 24 or 15 fps.
- Sound kept at 128 kbit/s, or removed.
- Automatic, MP4 or WebM output, with a fall back to the other container when the browser refuses one.
- Progress with a percentage and time left, a live preview of the frames, and Cancel.
- Before and after sizes, a verdict, and a download named after the original with -compressed added.
Why encoding takes as long as the clip
A target size is turned into a video bitrate with arithmetic. The target in bytes is multiplied by 8 to get bits, divided by 1.03 to leave 3% for the container, and divided by the seconds in the range; the sound bitrate is then taken off. Worked through for 25 MB over a 120-second range with sound kept: 25 × 1,048,576 × 8 ÷ 1.03 ÷ 120 is about 1,697 kbit/s, less 128 kbit/s of audio, which leaves 1,569 kbit/s for video. The page rounds that to the nearest 1,000 bit/s and reports an estimate of 25.0 MB.
Quality presets start from the picture instead. The page multiplies the output width, height and frames per second by bits per pixel per frame: 0.10 for High quality, 0.06 for Balanced and 0.035 for Smallest file. A 1280 × 720 picture at 30 frames per second on Balanced asks for 1,659 kbit/s of video, which comes to about 13 MB a minute once the 128 kbit/s of sound is added. Choosing Original for the frame rate counts as 30 fps in that sum, because the browser does not report the source rate to the page.
Two limits apply to either method. The video bitrate never goes below 150 kbit/s, because a picture below that falls apart, and never above 16 Mbit/s, where extra bits stop helping. A target too small for the range is raised to the floor, and a warning gives the size that will really result. A 1 MB target over ten minutes with sound becomes the 150 kbit/s floor and comes out at about 20 MB, so the fix is to shorten the range or remove the sound.
The resolution limit scales the shorter side of the picture, so 720 means 1280 × 720 for landscape footage and 720 × 1280 for portrait. A video already inside the limit is never enlarged, and both sides are rounded to even numbers, which the encoders require.
How it works
The chosen range is played in a hidden video element that uses the same local file. Each frame the element presents is drawn onto a canvas at the output size, and captureStream turns that canvas into a video track at the chosen frame rate. The page does not run a WebAssembly encoder; the browser's own MediaRecorder encodes the canvas stream.
The sound is taken through the Web Audio API. The element's audio is routed into a MediaStreamDestination that feeds the recorder, and that is the only connection in the audio graph, so nothing is sent to the speakers.
The length the file reports is measured from a clock that pauses with the recording, so it matches the range that was encoded. Chromium writes WebM without a duration, so the page writes one into the header after the recording stops; if that step fails the file still plays, and the result panel says the length could not be written.
Common use cases
- A parent wants to send a football goal to a group chat that caps uploads at 25 MB. They trim the clip to the twenty seconds that matter, keep the sound, and aim for 25 MB; the page turns that into a video bitrate it can show before anything is encoded.
- A designer needs a 40-second screen capture for a slide deck. They choose a 720 px limit and Smallest file, remove the sound because the deck is silent, and compare the before and after sizes in the result panel.
- A field engineer records a 15-minute inspection on a 4K phone, trims it to the two minutes that show the fault, caps the resolution at 480 px and aims for 8 MB to attach to a ticket.
- A small shop owner wants a product walk-through on the website to load faster. They pick Balanced at 720 px, which the page estimates at about 13 MB a minute with sound, and check the result against the original before deciding whether it is worth using.
How to use this tool
- Drop a video on the box, or click it and choose one. The page shows the resolution, length and average bitrate.
- Set the start and end of the part you want to keep.
- Choose a target size in MB or a quality preset, then the resolution limit, frame rate and sound.
- Read the estimated size and any warnings, then click Compress video.
- Keep the tab in front while the preview runs, or click Cancel.
- Compare the before and after sizes, play the result, and download it.
Example
A 2-minute trim from a 1920 × 1080 phone clip, aimed at 25 MB
Source: 1920 × 1080 px, 6:10 long, 412 MB
Start 0:30.00, End 2:30.00 (120 seconds kept)
Aim for: a file size, 25 MB
Resolution limit 720 · Frame rate original · Sound kept · AutomaticWhat the page plans and reports
Output: 1280 × 720 px
Video: 1,569 kbit/s, sound 128 kbit/s
Estimated size: about 25.0 MB, from a 412 MB original
Encoding: about 2 min of real time
After encoding: before and after sizes shown, with a verdict on how the result comparesTips for best results
- Trim first. The bitrate is spread over the range you keep, so a 25 MB target over 60 seconds allows roughly twice the video bitrate of the same target over 120 seconds. The estimate and the encoding time both follow the trimmed range.
- Aim for about half the original size or less. When the estimated size reaches 95% of the original file's size for the part you keep (the file size scaled by the share of the video's length you keep), a warning says the new file may not be smaller, and the result panel gives the same verdict once it has measured the file.
- Remove the sound when the clip is silent or the music will be replaced anyway. At a 25 MB target the 128 kbit/s audio track is about 7.5% of the bits, and removing it hands that share to the picture.
- Keep the tab in front while it encodes. A background tab is throttled by the browser, so the page pauses its playback and recording while the tab is hidden. When you come back, the progress panel shows a note that encoding was paused in the background and resumed. The length of the file leaves out the hidden time, so the wait is longer by that much.
- Choose MP4 when the file has to open on an iPhone or in a Mac app, and WebM when it is going to a Chromium browser such as Chrome or Edge. Automatic picks WebM in Chromium browsers and MP4 elsewhere; if the browser refuses that container, it tries the other one.
- Watch the live preview while it encodes. It shows the frames as they are drawn at the output size, so a wrong crop or a resolution that is too low is visible early. It does not show the encoder's own artifacts, which only the result panel can reveal.
Common pitfalls
The result can be larger than the original. Footage that is already efficient can come out bigger when the target is above what the source needs. The page says so in red and shows both sizes; it never claims a shrink it did not measure.
The bitrate is a target, not a promise. Footage with a lot of detail or fast motion can come out above the planned bitrate, and a still scene can come out below it. The result panel shows the planned and measured bitrates side by side, so you can see the gap for your own file before you decide to use it.
Encoding runs in real time, so a range longer than 60 minutes is refused, and a long range is a long wait. The page cannot make the encoder faster.
The output is re-encoded from the picture the page draws. Subtitle tracks, chapter markers and data tracks such as GPS or timecode are not carried over.
A file the browser cannot decode will not open, and the error names the likely codec problem. HEVC (H.265) video from recent iPhones is the most common case; Safari can usually play it. The page asks the browser for H.264 in MP4 or VP8/VP9 in WebM; if the browser refuses both, it uses its own default format, and the result panel shows the container it wrote.
The 150 kbit/s floor is real. A tiny target for a long clip cannot be met without losing the picture, so the page encodes at the floor and tells you the size it will actually produce.
Best practices
- Check the platform's limit before you pick a target. Most limits are in MB and count the whole message, so aim a little under them.
- Keep the first encode short. Trim to a few seconds, check the picture and the size, then encode the full range once the settings are right.
- Keep the original until you have checked the result plays in the app it is going to. Players differ in how they treat WebM, and MP4 is the safer choice for anything that will be opened on a phone.
Why the size is a plan rather than a promise
A video encoder spends the bits it is given unevenly. A still scene needs very few, a fast pan or a crowd needs many, and the encoder shares the budget across the clip as it goes. The page gives it an average, and MediaRecorder keeps near that average for footage with ordinary motion. Noise and rapidly changing frames push the output above the average, and very still shots leave it below.
That is why the result panel reports two bitrates, the planned one and the one measured on the file. A difference of a factor of two is possible and is not an arithmetic error; it is the encoder working on hard material. If the file is still over the limit you need, lower the target or the resolution and encode again.
Choosing between a size and a quality
A file size is the right choice when a platform sets a limit, because the page works backwards from the number you type. A quality preset is the right choice when the picture matters more than the number. The presets scale with the pixels drawn, so a 480 px limit on 16:9 footage (854 × 480) draws about 44% of the pixels of 720 p (1280 × 720) and asks for about 44% of the bits. At 360 px on Smallest file, the plan is about 2.7 MB a minute with sound kept, or about 1.8 MB without it.
The two methods can disagree on the same clip. Balanced at 720 px and 30 fps asks for about 1.66 Mbit/s of video, so a two-minute clip comes out near 26 MB with sound. A 25 MB target over the same two minutes asks for 1.57 Mbit/s of video. Those two numbers are close because they were chosen to be; the difference is which one you start from.
Frequently asked questions
Will this make my video smaller than a desktop encoder?
Not by itself. The size depends on the bitrate you aim for and on the footage. The page uses the browser's own encoder, which is good for everyday footage but is not tuned the way a desktop encoder is. The before and after sizes tell you what you got.
Does the video leave my computer?
No file leaves the tab. The source is read from disk through a local object URL, the output is kept in memory until you download it, and the page has no code that sends either one to a server.
Why does it take as long as the clip?
The canvas can only be recorded as the frames play, and the browser's recorder runs at that rate. A three-minute range takes about three minutes, and a hidden tab makes it longer.
Why is my output WebM when I wanted MP4?
Automatic picks WebM in Chromium browsers such as Chrome and Edge, and MP4 elsewhere. If you choose MP4 and the browser can write it, you get MP4; if it cannot, the page falls back to WebM, and the format line under the settings says which one the browser will write.
Why did the sound disappear?
Either you chose Remove, or the source had no audio track. The result panel notes when the source appears to have been silent.
Which browsers can record a canvas, and what happens in one that cannot?
The page needs MediaRecorder and canvas.captureStream. Where either is missing, a notice appears above the settings and Compress video stays disabled, so no partial file is produced. Recent versions of Chrome, Edge, Firefox and Safari provide both.