Keyframe alignment problem with Wowza and FFMPEG

Hi guys.

I have a problem which I don’t know how to solve it. The problem is our customers have an unstable bandwidth and when they watch videos, changing bitrate happens a lot. For example they start with 128kbps but after 3 seconds they go up to 5mbps and after 10 seconds they’ll back down on 64kbps. After sometimes, video freeze or going back and forward automatically. Its like i’m watching 3rd bitrate on 00:01:30, when I shift to 4th bitrate video jump to 00:01:35. Sometimes picture freeze, audio go back on beginning of chunk and start playing! When audio reaches to video, video will continue to playback!

It happens a lot and I really don’t know how to fix it. I encoded my videos with FFMPEG exactly as Wowza instructed but I still have the problem. It seems I have keyframe alignment problem but I don’t know how to fix it.

I use Wowza perpetual 4.1.0 (build 12602) with JW Premium.

My protocol is HLS.

Here is the way I encoded videos to 7 bitrates:

ffmpeg.exe -y -i Input.mp4 -s 400x224 -y -strict experimental -acodec aac -ab 64k -ac 2 -ar 48000 -vcodec libx264 -vprofile baseline -level 30 -g 48 -b 50000 -threads 64 output_50.mp4

ffmpeg.exe -y -i Input.mp4 -s 512x288 -y -strict experimental -acodec aac -ab 64k -ac 2 -ar 48000 -vcodec libx264 -vprofile baseline -level 30 -g 48 -b 150000 -threads 64 output_150.mp4

ffmpeg.exe -y -i Input.mp4 -s 640x360 -y -strict experimental -acodec aac -ab 64k -ac 2 -ar 48000 -vcodec libx264 -vprofile baseline -level 30 -g 48 -b 300000 -threads 64 output_300.mp4

ffmpeg.exe -y -i Input.mp4 -s 704x400 -y -strict experimental -acodec aac -ab 128k -ac 2 -ar 48000 -vcodec libx264 -vprofile baseline -level 30 -g 48 -b 500000 -threads 64 output_500.mp4

ffmpeg.exe -y -i Input.mp4 -s 898x480 -y -strict experimental -acodec aac -ab 128k -ac 2 -ar 48000 -vcodec libx264 -vprofile baseline -level 30 -g 48 -b 700000 -threads 64 output_700.mp4

ffmpeg.exe -y -i Input.mp4 -s 960x540 -y -strict experimental -acodec aac -ab 128k -ac 2 -ar 48000 -vcodec libx264 -vprofile baseline -level 30 -g 48 -b 1000000 -threads 64 output_1000.mp4

ffmpeg.exe -y -i Input.mp4 -s 1280x720 -y -strict experimental -acodec aac -ab 128k -ac 2 -ar 48000 -vcodec libx264 -vprofile baseline -level 30 -g 48 -b 1500000 -threads 64 output_1500.mp4

And here is latest video which has the same problem:

http://tv.digikala.com/Video/Review/Mobile/Apple_iPhone_6_Review

Hi,

The issue you may be experiencing is that unless 2 pass encoding is used the output from each encode will not be aligned to each other.

Please see this article

Frequently-requested-FFMPEG-command-examples-for-Wowza

Specifically the example at

  1. Generate keyframe aligned multi-bitrate VOD rendition (Linux)

Andrew

The issue you may be experiencing is that unless 2 pass encoding is used the output from each encode will not be aligned to each other.

Hello,

As far as I know two-pass encoding is used for bitrate estimation: first pass is used to analyze the media and the second for actual encoding at the target bitrate.

In the example, keyframe alignment is achieved using:

-g 48 -sc_threshold 0

aka setting the GOP size to 48 (one key-frame every 48 frames) and setting the scene cut detection threshold to 0.

You can also use -force_key_frames.

https://ffmpeg.org/ffmpeg.html

The original poster didn’t use -sc_threshold 0.

Best regards.