10 two-second samples cost up to 41% of a full encode, not 22%
Before squeezing a long video, one way to preview the size is to take a few seconds of it, compress those first, and scale the result up to the full length. The scaling error is one question. The other is what the previe
Before squeezing a long video, one way to preview the size is to take a few seconds of it, compress those first, and scale the result up to the full length. The scaling error is one question. The other is what the preview itself costs, and that is the one this post measures: how much of the full encode time do 1, 2, 3, 5 and 10 two-second samples eat?
In this run, 3 samples took 8.3% to 13.9% of the full encode, and 10 samples took 23.8% to 40.8%. Ten samples are only 22% of a 90-second clip, so time ran ahead of footage. Each claim is tagged measured, computed or inferred.
The clips and the setup
All numbers come from one Apple-silicon Mac, with each case run once and one at a time. The three clips are 90 seconds long, 1280Γ720, 30 fps, with no audio track. They were all encoded with x264, preset medium, CRF 23. A static one imitates a lecture recording. A moving one is a generated pattern that never stops, with noise on every frame. A cut-heavy one swaps its source every second or two, and that one also contains a few seconds of Wikimedia Commons video credited to Israel Police (CC BY-SA 3.0) and Forza1000 (CC BY-SA 4.0), cropped and re-encoded for the test.
Everything else is synthetic, so real footage with sound, other encoders and other rate-control modes may behave differently and were not tested.
Samples were evenly spaced, each encoded as its own 2-second MP4. The full encodes (measured) took 3.2 s for the static clip, 49.4 s for the moving one and 20.1 s for the cut-heavy one.
What the clock said
Each cell is sample encode time, then that time as a share of the full encode of the same clip (measured).
| Clip | 1 sample | 2 samples | 3 samples | 5 samples | 10 samples |
|---|---|---|---|---|---|
| Static lecture (full 3.2 s) | 0.13 s / 4.1% | 0.26 s / 8.0% | 0.38 s / 11.9% | 0.67 s / 21.0% | 1.30 s / 40.8% |
| Moving pattern (full 49.4 s) | 1.29 s / 2.6% | 2.86 s / 5.8% | 4.11 s / 8.3% | 7.06 s / 14.3% | 13.57 s / 27.5% |
| Cut-heavy (full 20.1 s) | 0.72 s / 3.6% | 0.88 s / 4.4% | 2.79 s / 13.9% | 3.57 s / 17.8% | 4.76 s / 23.8% |
The footage share is plain arithmetic on sample length (computed): 3 samples are 6.7% of 90 s, 5 are 11.1% and 10 are 22.2%. At 10 samples the time share was 1.2 times the footage share on the moving clip, 1.1 times on the cut-heavy one and 1.8 times on the static one.
The odd cell is the cut-heavy clip, where 2 samples took 0.88 s and 3 took 2.79 s. A single run per cell cannot say whether that jump is real or noise, so read that row as a rough size, not a curve.
The shortest clip pays the biggest share
Dividing the 10-sample time by ten (computed) gives about 0.13 s per sample on the static clip, 0.48 s on the cut-heavy clip and 1.36 s on the moving one. The static clip's whole encode is only 3.2 s, so any fixed cost per sample weighs on it most; the cut-heavy clip, whose full encode is shorter than the moving one's, paid the smallest share, so total encode length alone does not explain the order.
A likely reason for the gap is that each sample is a separate encode: the encoder starts again and the sample must open with a full keyframe. This part is inferred, because start-up and keyframes were not timed separately. The size side is measured: one 2-second sample of the static clip was 74,727 B, of which one keyframe took 70,634 B (94.5%). In the full 90-second encode, the 11 keyframes took 48.5% of the bytes.
What the extra samples bought
Time is only worth spending if the estimate improves. Scaling by duration, the average absolute error over 200 random picks (measured) was:
- Moving pattern: about 3.1% with one sample and 2.9% with ten. One sample was enough.
- Cut-heavy: 105.0% with one sample, 31.1% with ten. This is the only clip where more samples clearly helped, and ten still left an average miss of 31.1%. A single sample ranged from β99.0% to +344.4%.
- Static lecture: 125.9% with one and 129.4% with ten, and the best ten-sample case was still +90.5%. Every sample starts on a keyframe, so adding more of them does not fix it.
So the 24% to 41% bill at 10 samples bought a small error on one clip only, the moving one, which already had it with a single sample. Weighting each sample by the source bytes of its slice brought the cut-heavy clip down to 8.0% at ten samples, but made the static clip worse (141.4%). That is not a general fix.
Where ImgIng fits in
One browser tool with a trial panel of its own is ImgIng ( https://imging.ai/ ). In its video compressor, an optional trial opens when the output is H.264 SDR in an MP4. The page limits it to three segments of two seconds or less and reports the sample size and the time spent. On the static clip the page chose its own positions, about 8%, 48% and 88% of the length. Its text says the samples carry no audio and cannot give the whole file's size or prove quality is intact.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.