Page MenuHomePhabricator

WebM transcodes should move cues to beginning of file for faster seeking
Open, Needs TriagePublic

Description

WebM video transcodes include a cue index of keyframe locations, by default placed at the end of the file by ffmpeg. Because it's at the end, if the user tries to seek within the file with the scrubber bar the browser will have to launch a sub-range request to go fetch the cues before it's able to find the position to seek to. This is an extra network round trip and can be slow.

There should be tools out there which can rewrite the file to move the cues to the beginning, which means we've already read the cues at the beginning of the file and seeking can happen at any time.

Event Timeline

I know ffmpeg can do it for .mov/.mp4 (faststart), but not sure about ogg/ogv's

@brion
https://www.matroska.org/downloads/mkclean.html

mkclean --remux --optimize "INPUT.webm" "OUTPUT.webm"

Dropping -cues_to_front 1 into the ffmpeg options should do the job; it'll do a temporary file copy transparently if necessary.

This saves from having to separately fetch the cues on first seek, which is nice, but is less performance-critical for .webm than faststart is for .mp4.

Easy patch opportunity :D