Video Playback pre-buffering to ease quick startup needs

I have a project using a series of h.264 files (the format is non-negotiable, they’re generated by another part of the pipeline), and it loads and prepares videos offscreen and then crashes in on a hard cut with a play() command. The issue is that first frame from a play() can take quite a while to come back from the underlying player, so the first 4-10 frames are stalled and create a noticeable hitch. If I start the videos earlier and cut into them part-way through playback, it obviously isn’t an issue, but I lose the first x frames of the video. I was curious if there was a way to force a movie player to pre-buffer so it’s prepared to play when needed, instead of waiting for the first play command to try to populate its buffer and start preparing for full-run playback (what i assume is happening, based on the delay). I have several seconds of off-screen time between videos being prepared and needing to be on screen.

Platform: OSX using QT video

Side note: Looking through the docs, I’m not sure if there’s a way to load frame texture data onto the CPU nicely. Maybe I could load entire videos frame-by-frame (I don’t need audio) into a sort of manual buffer. I have the RAM. Ideas?


Hi,

I am not a QuickTime expert, but if it’s anything like how Windows handles video, your delay is caused by the video player determining what codec the video is using, setting up the video render pipeline (a.k.a. topology, graph, etc.) and decoding the first few frames. It will buffer those frames for you, probably in GPU (device) memory, so it’s not something you should be concerned with.

For your scenario, it must be possible to start the video player in paused mode, so that it’s ready to run in a moment’s notice. See if you can find something in the docs that allows you to do just that. If the player API doesn’t support that, you may be out of luck when it comes to the easy solutions.

-Paul

In my scenario, I “load” the asset, get a response that it’s a valid video and can be played, but I don’t actually “play” the video until I need it. What I believe to be true is that until I .play(), it never actually generates the playback pipeline, just sits around twiddling its thumbs. Now, I could probably do something extremely hacky like play(), wait a few ticks until I get the checkPlaythroughOk() == true, and seek back to 0.0, but that seems like an exceedingly silly thing just to be able to play on demand (and might not be a valid strategy, anyway, depending on how the buffer gets used). I was hoping for a less hacky solution.