Ok, time to concentrate on the next error shown from the mediastreamvalidator:
Measured peak bitrate compared to master playlist declared value exceeds error tolerance
I didn’t find any reference regarding this message within the RFC but in the HLS Authoring Specification from Apple:
For VOD content, the average segment bit rate MUST be within 10% of the AVERAGE-BANDWIDTH attribute.
Ok so let’s add this to the FFmpeg command that we have prepared in the last article.
FFmpeg supports limiting the video bitrate with the maxrate parameter. So for the 200K video variant it would be 2200k (2000k + 10%).
This must be done for each video variant.
After execution of the new command it seems that this was not working. The command line output helps us here:
VBV maxrate specified, but no bufsize, ignored
Also the documentation tells us the same:
Set max bitrate tolerance (in bits/s). Requires bufsize to be set.
Bufsize is the rate control of our max size. More details regarding the value here can be found in the FFmpeg Wiki. In general I recommend to start by using 150% of the average bitrate value but you definitely need to adjust this onto the different bitrates. So for the first variant it looks like:
The Bitrate Diff. looks now in a range where we want to have it and the error message is also gone:
The new command looks now as below:
./ffmpeg -listen 1 -i rtmp://martin-riedl.de/stream01 \ -filter_complex "[v:0]split=2[vtemp001][vout002];[vtemp001]scale=w=960:h=540[vout001]" \ -preset veryfast -g 25 -sc_threshold 0 \ -map [vout001] -c:v:0 libx264 -b:v:0 2000k -maxrate:v:0 2200k -bufsize:v:0 3000k \ -map [vout002] -c:v:1 libx264 -b:v:1 6000k -maxrate:v:1 6600k -bufsize:v:1 8000k \ -map a:0 -map a:0 -c:a aac -b:a 128k -ac 2 \ -f hls -hls_time 4 -hls_playlist_type event -hls_flags independent_segments \ -master_pl_name master.m3u8 \ -hls_segment_filename stream_%v/data%06d.ts \ -use_localtime_mkdir 1 \ -var_stream_map "v:0,a:0 v:1,a:1" stream_%v.m3u8