segmenter_keyframe_alignment_margin
The segmenter_keyframe_alignment_margin directive defines the allowable time difference for segmenting keyframes in media streaming.
Description
The segmenter_keyframe_alignment_margin directive is utilized in the Kaltura Media Framework NGINX module to set a margin for the alignment of segmenter keyframes. This parameter determines the maximum time difference that can exist between a segment end and the corresponding keyframe in the media stream. It primarily serves to ensure that segments are cut at keyframes, maintaining video integrity and playback quality, especially in adaptive bitrate streaming scenarios.
When the segmenter processes the media stream, it evaluates the timestamps of the incoming frames to determine where to segment the stream. By specifying a keyframe alignment margin, administrators can influence how tightly the segments adhere to the keyframes, allowing for slight variances. A smaller margin may lead to more segments that start and end precisely on keyframes, but it may complicate the segmenting process if the video stream is not encoded with well-aligned keyframes. Conversely, a larger margin might facilitate more flexible segmenting but could result in segments that don't start on a keyframe, potentially affecting playback performance and user experience.
The directive takes a single argument, which is the time margin defined in seconds. This value guides the segmenter in deciding how much leeway it has when it encounters a frame that is not a keyframe, helping to optimize segment boundaries while preserving the quality of the stream.
Config Example
segmenter_keyframe_alignment_margin 0.5; # Allow a margin of 0.5 seconds for keyframe alignment
Setting the margin too low can lead to segmentation errors if keyframes are not perfectly aligned.
Setting the margin too high may result in segments starting at non-keyframe positions, potentially causing playback artifacts.