Menu

Byte-range requests for video: build a 206 server, test seeking in Chromium, fix moov placement
πŸ“°

Byte-range requests for video: build a 206 server, test seeking in Chromium, fix moov placement

DEV Community: nodeΒ·Mason KΒ·20 days ago
#BKEweGP3
#devtonodejs#devto#dev#webdev#tutorial
Reading 0:00
15s threshold

TL;DR

Seeking in a plain MP4 works by asking the server for byte ranges. We'll write a 25-line Node server that answers them, show what happens in Chromium when a server ignores them, and fix the other classic seek-killer: the moov atom at the end of the file.

πŸ“¦ Code: github.com/USER/range-demo (replace before publishing)

Versions used: node 22 , python 3.13 , ffmpeg 6.1.1 , playwright with Chromium 153.0.8010.12 . #webdev #tutorial

1. πŸ“– The protocol in four lines

From MDN's range request guide :

Accept-Ranges: bytes (anything but none ) means the server supports ranges. No header means it doesn't.

Client sends Range: bytes=0-1023 . Server replies 206 Partial Content with Content-Range: bytes 0-1023/146515 .

Out-of-bounds range gets 416 .

A server that doesn't support ranges replies 200 OK with the whole body.

2.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.