If you've ever had a video that plays perfectly on your computer but shows nothing but a black rectangle in a browser, congratulations: you've met the wonderfully confusing world of video formats. The good news is that for the web, the choices boil down to a short, memorable shortlist.
The box and what's inside it
People say “MP4” like it's the whole story, but a video file really has two parts. There's the container — MP4, WebM, MOV — which is basically the box. And there's the codec — H.264, HEVC, VP9, AV1 — which is how the video inside that box is squished down. A browser can happily open the box and still choke on what's inside if it doesn't understand the codec. Almost every “why won't this play” mystery comes down to this one distinction.
When in doubt: H.264 in an MP4
If you only make your video one way, make it an MP4 using H.264 video and AAC audio. It's the closest thing the web has to a format that plays absolutely everywhere, on basically every device, with no fiddling. It's not the most efficient option going, but it is the one that just works — and for a rickroll, “just works” is the entire job.
The HEVC trap
Here's the one that catches people out. HEVC (also called H.265) makes smaller files at the same quality, so a lot of phones now record in it by default. The problem is that browser support is patchy and tangled up in licensing. So your phone plays its own HEVC clip beautifully, you upload it, and in a browser it's a black screen or an error. If a valid-looking MP4 refuses to play on the web, HEVC is almost always the reason — and the cure is to re-encode it to plain old H.264.
Fixing a stubborn file in one line
The free tool FFmpeg will convert a stubborn file to the safe format with a single command, swapping the video to H.264 and the audio to AAC without messing with the actual footage. Run it, and the same file that gave you a black screen will usually play everywhere. When in doubt, re-encode to the boring, reliable option and get on with your prank.