Skip to content

Why Is the Screen Still Black If the First Frame's Bytes Have Arrived?

A hand moves a red index card ahead of the frames on a strip of film.

Too long, didn’t read. A player can have the bytes for the first frame and still be waiting for the playback index. MP4 Fast Start puts the index ahead of the video data. Try the slider to see how that changes when the first frame appears in a sequential download.

Why a video can stay black after you press Play

You put a demo video on a product page. Someone presses Play on a slow connection. The bytes for the first frame arrive, and the screen stays black.

In the two MP4s below, the first frame’s video data starts at byte 44 with the index at the end and at byte 795 with Fast Start. Yet FFmpeg decodes the first frame sooner in the Fast Start copy.

The player can hold a frame’s bytes in a buffer. It needs the playback index to find where the frame starts and how many bytes to give the decoder. Apple’s guide to finding a sample

Start at the moment the first frame’s bytes arrive, with the server sending the file in order.

When the first frame's bytes arrive in a sequential download, the player checks whether it has read the index. With the index at the end it still has to wait for the index. With Fast Start it can decode the first frame because it has already read the index.

The player with the index at the end can decode the frame once that index arrives. Fast Start puts the index ahead of the video, so both pieces can be ready near the start of the download. FFmpeg’s MP4 format guide

See when the first frame appears

The slider starts at 200 ms. Fast Start already has a picture. The copy with the index at the end is still waiting. Drag the slider to see when the same frame appears in each copy.

Recorded with FFmpeg over a sequential download. The server ignored Range requests.

Index at end
Waiting for first frame

First frame at 615 ms

Fast Start
First decoded frame, showing a multicolored test pattern.

First frame at 98 ms

Each time is the median of three trials, measured from the first request arriving at the server to FFmpeg producing the first complete decoded frame. The local server sent up to 1,024 bytes per write, with 30 ms between writes.

The same video at new byte addresses

The playback index lives in the moov box. The encoded video lives in mdat. Here’s what the two files look like at the beginning.

On the same byte scale, video starts at byte 44 with the index at the end and at byte 795 with Fast Start.
The first 1,000 bytes of each MP4, drawn to scale.

The numbers mark the first frame’s position in each file. Fast Start updates the index with the new byte addresses so the player knows where to read. Apple’s guide to finding a sample

Mediabunny wrote both copies of this two-second clip. All 24 encoded video packets matched byte for byte. Download the MP4 with the index at the end or with the index at the front. Mediabunny’s guide to copying media data

A player can ask for the end of the file

A byte-range request lets a player ask for just the tail of the file. If the server honors it, the player can read an index at the end before the rest arrives. The replay above uses sequential delivery. How HTTP sends large files · HTTP range requests

An ultramarine film reel unspools a strip across ivory paper, with a red tab at its leading end.
An ultramarine film reel unspools a strip across ivory paper, with a red tab at its leading end.

Use FFmpeg Fast Start on an existing MP4

Run this on a regular MP4 to write a Fast Start copy. FFmpeg applies this option to non-fragmented output. FFmpeg’s MP4 output options

ffmpeg -i "input.mp4" -map 0 -c copy -movflags +faststart "output.mp4"
  • Copy the streams. -map 0 selects every stream. -c copy keeps the video and audio encoded as they are.
  • Check the order. Run ffprobe -v trace output.mp4. Look for the top-level moov entry before mdat.

If you export from a web app, Mediabunny offers fastStart: "in-memory". It buffers the output in memory before writing it. Mediabunny’s MP4 output options