r/VIDEOENGINEERING • u/Smash-Gordon • 16h ago
VLC 4.0 finally has a "Previous Frame" function, twelve years after it was deemed impossible
VLC 3 has E for Next Frame and nothing for going the other way. If you ever asked about that on the old VideoLAN forums, someone probably linked you Rémi Denis-Courmont saying reverse frame-by-frame is "not feasible within bound and reasonable computational, memory and bandwidth limits because video codecs and container formats are not meant to be played in reverse." Those threads usually got locked after a few pages of people bringing up MPC-HC, PotPlayer and YouTube, and it's been a running joke on here ever since.
The GitLab ticket is #10252. vadiav opened it on December 29, 2013, and Jean-Baptiste Kempf tagged it Difficulty::guru the same day. In January 2023 Rémi left this comment on it:
No way in hell such a difficult feature can be done in 4.0 and/or before buffering redesign (5.0.0). I thought people would know stop scope creep by no[w].
It made it into 4.0 anyway (still unreleased), through Thomas Guillem's MR !3263. The approach is about what you'd expect, and he calls it "BE PRAGMATIC" himself. Seek back a batch of frames (10 at first), decode forward into a LIFO, pop the frames off in reverse. When the stack is empty, it seeks again. Switching back to Next Frame or Play also means another seek.
Those re-seeks are what the second half of the post is about. I worked on the same problem in a player of my own. It keeps a bounded two-way frame cache in system RAM to avoid most of them, and it coalesces rapid scrub and step input so a burst of key presses doesn't turn into a burst of seeks. Frames get copied off the hardware decoder's GPU surfaces into RAM.
Very interested of course in other implementations for this rapid frame by frame seeking if anyone knows details of what the state of the art video players do.
Write-up is here: https://gordonvidal.dev/why-vlc-cannot-step-backward/