GOP size calculator for segment alignment

This is a tool for calculating a Group Of Pictures size that allows segment alignment between video and AAC-encoded audio. Segment alignment can be useful in segmented streaming protocols such as MPEG-DASH and HLS since it allows all segments to be of the same length. MPEG-DASH manifests with segment timelines will also be more compact.

Segment alignment is achieved if the duration of all video frames in a segment is equal to the duration of all audio frames. This can be a bit tricky since the AAC audio frames per packet size is fixed to 1024. (It's also possible to use 960 frames per packet, but that doesn't seem too common.) Video streams are usually segmented on whole GOPs, so the length of all video frames in a segment depends on the GOP size and the frame rate.

Using Math™, this tool will calculate the minimal GOP size that gives segment alignment and then simply multiply it with an integer to give you more options. Example: you want a GOP size of ~2 seconds @ 25fps with 48kHz audio → select 1.92 or 2.24 seconds.

Frames Seconds