Question about Keyframe Interval in Custom Output

So, I've been experimenting with the Custom Output (ffmpeg) settings. My 4k60 footage was terribly laggy in the Vegas preview playback, so I tried different formats. I found out that a change in Keyframe Interval completely eliminates lag in Vegas.
It's set default as 120 frames (in custom output it's measured by frames rather than seconds). But if I put lower, like 30, it works so much better in Vegas. The trade off apparently is higher GPU usage, so this is best used in a dual streaming/recording setup.
I'd just like to understand why this happens. I imagine it's something to do with less compression, which makes Vegas read the files faster, but I'm not sure.
 

carlmmii

Active Member
It shouldn't result in higher GPU usage. If it does, it should be completely negligible in the context of this encoding environment.

The keyframe interval is how many frames the encoding will go before it adds a full keyframe. All the other frames are known as "inter-frames", or I-frames.

Keyframes are basically like jpeg's -- they're self contained images, requiring no extra data to decode. Video players and editors can jump directly to a keyframe and display it immediately because all the data needed to decode it is right there.

I-frames are different in that they store the change between previous frames (oversimplification, but that's the general idea). This results in much less data required to store each frame, but in order to actually show it the player has to start from the previous keyframe and reconstruct each frame between then and the I-frame.

If you have your keyframe interval set to 120, then any time you jump to a random frame in your timeline, your editor has to reconstruct between 1 and 120 frames. Reducing the keyframe interval to 30 means your editor will have a maximum of 30 frames it will ever have to reconstruct, which will mean much more responsive editing, but higher file sizes.
 

koala

Active Member
The keyframe interval is how many frames the encoding will go before it adds a full keyframe. All the other frames are known as "inter-frames", or I-frames.
You're making a small mistake with terminology here. The terminology is confusing, so many people make this mistake.
There are Intra-frames, called I-frames, who encode a full image without depending on any other frame.
There are Inter-frames, called either P-frames or B-frames. P for predictive, B for bidirectionally predictive. A P-frame encodes the difference between the last I-frame or P-frame(s), thus refers so some previous frame(s). A B-frame encodes the difference between any previous as well as following frames to achieve highest compression. You read correctly: it also does some kind of lookahead and refers to a frame that is to be displayed after this.
The encoder inserts a I-frame every keyframe interval and fills the frames between them with a mix of P and B frames.

Video processing software uses I-frames as key frame for scrubbing/seeking through video material, because they can be decoded and displayed directly. On the other hand, if you scrub through P- or B-frames, you need to decode every previous frame since the last I-frame to get a full image to show. If the distance between I-frames is high, scrubbing needs as much time as just playing the video, so reducing the keyframe interval allows better scrubbing or scrubbing in the first place.
Some video editors also preprocess video and creates some internal preview video cache just for scrubbing that only contains key frames reconstructed from all P and B frames, so seeking is immediate after the creation of the internal cache.
 
You two were super helpful, thanks for the answers! As for GPU usage, my streaming PC's 1050 TI (yeah I know) went 100% when recording with something like 10 frames in keyframe quantity. Gotta do further testing though. Anyway, editing 4k60 footage with no lag is so sweet.
 

rockbottom

Active Member
Have you checked your video decode settings in Vegas?

Options > Preferences > File I/O, Enable Hardware Decoding for Supported Formats & Set the Hardware Decoder to Nvidia NVDEC

Also if you go to Options > Preferences > Video, you can turn on GPU Acceleration

All of my OBS recordings run buttery smooth with the Preview Window set at Best/Full.
 
Top