VionetoVioneto
Back to the magazine

VIONETO MAGAZINE Playback & technology

HLS vs. MP4 for a website: compare the same clip

A locally tested clip with identical individual frames demonstrates the differences when switching from an MP4 file to HLS and how you can compare playback.

The same six colored patterns appear at the top as film strips and at the bottom as individual elements within a schematic list.
The illustration shows the same video content either as a single clip or in segments.Image: Vioneto · AI-generated illustration

A progressive MP4 file is often a good first attempt for a short clip on a website. HLS warrants its own test when viewers are accessing content under very different network conditions and when the player needs to switch between multiple quality levels. When comparing options, a simple rule helps: first keep the video content and encoding identical, and change only the delivery method.

What differs in the same test clip

For this comparison, we generated a 12-second synthetic clip using FFmpeg: 640 × 360 pixels, 25 frames per second, H.264, silent. The progressive version consists of an MP4 file with the essential metadata placed at the beginning. For the HLS version, we took the already-encoded video stream without re-encoding. This produced a playlist containing the initialization file init.mp4 and six fragmented MP4 segments, each two seconds long.

Both versions could be fully decoded locally. The printed output of the decoded video sequence, with 300 frames each, was identical. This test demonstrates how the same video stream can be packaged differently. It does not measure start time or data consumption in the browser. The HLS version had only one quality level and therefore could not switch to a lower bitrate.

FFmpeg: Settings for the HLS Muxer and fMP4

What the browser actually fetches

With progressive MP4, the player requests data from a file. If both the server and the player support byte-range requests, the network protocol can respond with status 206 to corresponding range requests. The entire file does not need to be downloaded before playback begins. In HLS, a playlist references media segments, while in fragmented MP4, the initialization segment is referenced. Switching during playback is only possible when multiple appropriate quality levels are available and a compatible player is used.

RFC 9110 on HTTP Scope Requests

RFC 8216 on HLS Playlists, Segments, and Variants

Choose the right format for your website

  1. Test both versions using the same clip on the actual target platform. Ensure the device, network profile, autoplay setting, and cache state are comparable.
  2. Miss the time from start click until the first visible image appears. Then jump to the same position further back and observe when the image restarts and which requests are triggered.
  3. If changing connections trigger HLS, additionally test multiple quality levels and throttle the network during playback. Check whether the player switches between quality levels and if the clip can be played continuously.

Based on the specific video. For a short product video, an MP4 file is easier to publish. For a longer lesson with viewers using different mobile networks, test results across multiple quality levels are more informative than file size alone.

Basics of HLS and Quality Switching

Prepare an MP4 with Fast Start for the website

Topics

Sources and further reading

  1. https://ffmpeg.org/ffmpeg-formats.html#hls
  2. https://www.rfc-editor.org/rfc/rfc9110.html#name-range-requests
  3. https://www.rfc-editor.org/rfc/rfc8216.html