Wowza Community

HLS packaging destroys key frame alignment

Hi,

We are using Wowza for packaging mp4 files for ABR HLS delivery. The mp4 files are generated using FFmpeg+x264 and are all verified to be key frame aligned (KFA) with respect to PTS timestamps. We currently generate around 4-7 different renditions for each asset, ranging from 1080pHiP to 180pCBP.

It seems that wowza corrupts the KFA when it packages the mp4 files into MPEG-TS streams used for HLS delivery. The problem seems to arise for renditions containing B-frames (HiP/MP) for which x264 generates negative DTS on the first key frame (PTS for the first key frame in all renditions is zero).

Analyzing the resulting MPEG-TS segments after packaging with wowza, we see that all renditions using CBP are PTS aligned and all renditions using B frames (HiP/MP) are aligned, but CBP renditions are not aligned with HiP/MP renditions.

Our Wowza setup is pretty straight forward. We’re running 4.5.0 and we just add all mp4 files to the content directory, together with a SMIL file listing all renditions.

Here’s an example of what we see.

PTS/DTS values (in seconds) of first (key) frame in each mp4 rendition:

Rendition PTS DTS

1080p 0 -0.083417

720p 0 -0.083417

360p 0 0

180p 0 0

PTS/DTS values (in seconds) of first (key) frame in each MPEG-TS segment in each rendition:

Rendition PTS DTS

1080p 0.083 0

720p 0.083 0

360p 0 0

180p 0 0

It seems that wowza shifts the timestamps differently for the HiP/MP renditions (negative DTS) compared to CBP renditions.

I understand that you cannot have negative timestamps in MPEG-TS, but this is typically solved by adding an offset, e.g. 10 seconds, to all timestamps, for all renditions.

I read here [https://www.wowza.com/docs/how-to-debug-encoder-multi-bitrate-keyframe-alignment that wowza should default to align on PTS, which makes sense, but here it seems that wowza actually shifts the timestamps differently in different renditions to achieve DTS sync.

Are there any configuration options we can use to achieve PTS sync on our generated HLS streams?

Regards Stefan

Hello!

Thanks for contacting Wowza Forums!

Can you explain your workflow and requirements? Are you wanting simulated live over MPEG-TS for delivery? or is this true VOD?

Here is an article of how to achieve simulated live using VOD assets:

https://www.wowza.com/docs/how-to-schedule-streaming-with-wowza-streaming-engine-streampublisher

Here is an article that explains the supported playback of VOD content also:

https://www.wowza.com/docs/understanding-streaming-protocols-and-output-file-formats

Can you send your FFmpeg command you are using to convert the files?

Also, for the keyframe issue, here are 2 options you might can use:

-g 48 will define a GOP of 48 frames to create a two second GOP for your content. This works in conjunction with the no-scenecut option below. It also ensures that any segmented content that is delivered has equally sized chunks.

-x264opts no-scenecut will force keyframes to be created per the GOP value that FFmpeg uses. The default for libx264 is to create a keyframe when it detects a scene change. If this option is not used then keyframes will be misalgined for ABR content and segment sizes will be unpredictable.

Regards,

Jermaine