FORUMS: list search recent posts

h.264 keyframes

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jerry Smith
h.264 keyframes
on Sep 27, 2017 at 8:49:43 am

I'm exporting an animated video to h.264. Roughly speaking the 4 minute video is made up of stills that change 200 times. So it changes every 30 frames. We're using 24 fps.

The thing that really seems to affect the file size is the keyframe distance.

level 5.2 with keyframe distance of 5: 270MB
level 4 with keyframe distance of 5: 180MB
level 5.2 with keyframe distance of 75: 71MB
level 5.2 with keyframe off: 100MB
level 5.2 with keyframe distance of 300: 61MB

QUESTION 1: Why is the optimum keyframe distance of roughly 300 so much bigger than the 30 frame time scale indicated by changes?

QUESTION 2: If you are choosing a keyframe for all devices, what do you choose? This is something you hear all the time now: video available on all platforms on all devices. It's not easy to just play trial and error any longer since the creator has no idea really where it is going to be played back. In this case, would you just choose the last option?

Thanks in advance


Return to posts index

Walter Soyka
Re: h.264 keyframes
on Sep 27, 2017 at 9:27:29 am

[Jerry Smith] "The thing that really seems to affect the file size is the keyframe distance."

[Jerry Smith] "QUESTION 1: Why is the optimum keyframe distance of roughly 300 so much bigger than the 30 frame time scale indicated by changes?"

Interframe compression like H.264 works by eliminating visual redundancy over time. These schemes store two kinds of frames in the stream: complete frames (keyframes or I-frames) that contain all the image information for one frame in one place, and partial frames (B-frames and P-frames) that only contain change information must refer to other frames in the stream to reconstitute the image for that frame.

This is a tradeoff between size (the partial frames use less data and the I-frames use more) and quality/complexity (a single I-frame stands alone and is easy to decode, while B- and P-frames require processing several frames and may accumulate more artifacts because of tight encoding constraints).

When you explicitly set an H.264 keyframe distance, you are telling the compressor how often to place I-frames into the stream. When keyframes are placed closer together, you force the compressor to store more complete frames in the stream, whether it actually needs to or not. A complete picture takes up a lot more space than a little note that says "nothing has changed since the last frame."


[Jerry Smith] "QUESTION 2: If you are choosing a keyframe for all devices, what do you choose? This is something you hear all the time now: video available on all platforms on all devices. It's not easy to just play trial and error any longer since the creator has no idea really where it is going to be played back. In this case, would you just choose the last option?"

Services like Vimeo and YouTube actually re-encode your media into several different streams with different resolution and quality/bit rate targets. This allows the player to switch among them according to bandwidth and user preference.

I only consider manual keyframe control in specific circumstances, where I know exactly how the original file will be used.

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Jerry Smith
Re: h.264 keyframes
on Sep 27, 2017 at 11:00:19 am

Thanks Walter,

So, in this case, you would turn off keyframes and accept a 100MB file size rather than go with the 300 keyframe distance and get a file size that is 40% less??


Return to posts index


Cassius Marques
Re: h.264 keyframes
on Sep 27, 2017 at 1:10:45 pm

[Jerry Smith] "So, in this case,"

You've never said which case! Where would you be displaying the video? Do you have any constraints? Is the lower size video displaying fine or does it shows artifacts? If it is, are you using 2-pass encoding?

Cassius Marques
http://www.zapfilmes.com


Return to posts index

Jerry Smith
Re: h.264 keyframes
on Sep 27, 2017 at 3:27:02 pm

I meant in the case of this particular video. I don't know exactly where the video will be displayed; that's sorta what gives my question some BITE! Yes, I've been using 2pass VBR. In general, the quality has been very good without artifacts. So, I'm sorta trying to see how small I can make the file.

Here's a related question that you Cassius might know something about: when does YouTube decide to show the 720p rather than the 1080p because of insufficient bandwidth?


Return to posts index

Walter Soyka
Re: h.264 keyframes
on Sep 27, 2017 at 3:46:28 pm

[Jerry Smith] "I meant in the case of this particular video. I don't know exactly where the video will be displayed; that's sorta what gives my question some BITE!"

What are you doing with the file you're making? How are you distributing it?

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index


Cassius Marques
Re: h.264 keyframes
on Sep 27, 2017 at 6:16:36 pm

[Jerry Smith] " I don't know exactly where the video will be displayed"

Its usually the medium that decides the format and the specs. Since you don't know, the smallest size that looks good to you is probably what you should aim for.

[Jerry Smith] "...when does YouTube decide to show the 720p..."

Sorry, no idea about Youtube's innerworkings. But they will convert the video nonetheless, so if youtube (or any online plataform for that matter) is the case. You shouldn't really bother with it, if you have a decent connection, go for a high bitrate/quality spec and let the plataform optimize it.

Cassius Marques
http://www.zapfilmes.com


Return to posts index

Walter Soyka
Re: h.264 keyframes
on Sep 27, 2017 at 1:10:48 pm

[Jerry Smith] "So, in this case, you would turn off keyframes and accept a 100MB file size rather than go with the 300 keyframe distance and get a file size that is 40% less??"

If you're uploading to Vimeo or YouTube or the like, your file will get recompressed by them for delivery anyway, so I'd go for best quality.

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]