Why my 12-hour video took ages to start
My media library sits on a Mac mini at home, and Plex plays it on the Apple TV in the living room. It includes an ambient video almost 12 hours long, the kind made to play in the background. Every time I pressed play or resume, the Plex app on the Apple TV took ages to load it.
One evening, I opened a terminal and asked Claude Code to look at the Plex server. This post is the story of two wrong guesses, one of them mine, and how measuring found the real cause.
Two wrong guesses
My guess was that the Plex server did not really stream, and made the Apple TV download the whole 31.7 GB file before playing it. That was wrong. In fact, the Apple TV asks the server for the video piece by piece, as it plays. The server sends each piece as it is, without converting it, which Plex calls Direct Play.
The first explanation from the assistant was half right. It found two things: the file had an unusually large index, which I come back to below, and the Apple TV received data slowly, at about 2.6 MB/s. It also suggested connecting the Apple TV with a cable, in case it was on Wi-Fi. When I replied in one line that it was already wired, the assistant went back to investigating.
Measuring instead of guessing
Instead of coming up with a new theory, the assistant tested each part of the chain, one at a time:
- The drive that holds the video delivered it at 77 MB/s.
- The Plex server sent the same file to my laptop at 47 MB/s.
- The Apple TV received only about 2.6 MB/s over its cable, even though the server could have sent it much faster.
- The video itself needs only about 0.7 MB/s to play.
So the drive and the server were fine, and the slow side was the Apple TV. And since playing the video needs only 0.7 MB/s, well below the 2.6 MB/s the Apple TV received, it played smoothly once it had started. The question became what the Apple TV had to download before it could show the first picture.
A table of contents with 2.6 million lines
An MP4 file carries an index, a kind of table of contents that tells the player where each frame sits in the file, how big the frame is, and when to show it. A player reads the whole table before it shows anything.
My video runs at 60 frames per second for almost 12 hours. That makes 2,573,708 frames, each with its own line in the table. As an MP4, its index alone weighed 85 MB. At 2.6 MB/s, that is more than 30 seconds of downloading before the first frame.
The Apple TV also opened a new connection to the server when I resumed after a pause, which suggests that the Apple TV read the whole index again each time. That part is an inference, not a measurement, but it matches the slow resumes.
The usual advice for an MP4 that is slow to start online is to move its index to the start of the file, an option often called "fast start". It would not have helped: in my file, the index was already at the start. The problem was not where the index was, but how big it was.
Same video, different box
The assistant offered a few fixes. One was to split the video into one-hour parts, each with a smaller index. I said no. Another was to let the Plex server convert the video while it plays, at a lower quality. The last was to keep the video as it is, and change only the file format around it.
MP4 is only one kind of box for video and sound. MKV, also called Matroska, is another, and it can hold the same video and sound unchanged. Its index does not list every frame, only the points where a player can jump in. In my video, that is 7,743 points, about one every five or six seconds.
I chose that last fix: copy the video and the sound into an MKV as they are, without converting them, so the picture stays exactly the same.
I asked for the copy to run on the Mac mini itself, next to the drive, with ffmpeg, a free command-line video tool. It took 19 minutes for the 31.7 GB file. The result, MP4 against MKV:
- Index
85 MB against 180 KB, about 475 times smaller. - Entries in the index
2,573,708 frames against 7,743 jump points. - File size
31.7 GB against 31.6 GB. - Start on the Apple TV
Ages against almost instant.
I did not time the new start with a stopwatch, but the difference did not need one. My reaction at the time, typed in a hurry, was "it's blazing faaaaaaaaast".
To check that this was not specific to my file, I made a 12-hour test video at 60 frames per second with ffmpeg. As an MP4, its index weighed 68 MB, and jumping to the middle meant reading all of it. As an MKV, the index weighed 232 KB, and the same jump read less than 300 KB.
I never found out why the Apple TV received data so slowly. With the MKV, it no longer mattered.
Only very long videos are worth converting. Two things to know before you convert your own files:
- Plex treated the MKV as a new video, not as a new version of the old one. The resume point and the rating stayed with the MP4, and were lost when I deleted it.
- QuickTime Player does not open MKV files. For a video you also watch on a Mac, or share with others, keep the MP4.
What I keep from it
- A first guess is only a hypothesis, mine or the assistant's. Neither found the cause here. Measuring did.
- Correct the assistant early. One line about the cable spared me a fix that would have changed nothing.
- Stay in charge of the decisions. The assistant proposed, and I chose.