This is a series of articles. Follow the link here to get an overview over all articles.
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
Can possible to use -filter_complex split=4 ( i mean 4 variant Stream ) …
Yes your right. You can add as many variants as you want.
Thank you very much for the article, it was very useful to me.
I have a query, because the master.m3u8 file disappears after a while, making it impossible for someone to connect to the url?
The command is as follows:
ffmpeg -re -i bbb_sunflower_native_60fps_normal.mp4 \
-filter_complex “[v:0]split=3[vtemp002][vout001][vout003];[vtemp002]scale=w=960:h=540[vout002]” \
-preset veryfast -g 25 -sc_threshold 0 \
-map [vout001] -c:v:0 libx264 -b:v:0 1100k -maxrate:v:0 1100k -bufsize:v:0 2200k \
-map [vout002] -c:v:1 libx264 -b:v:1 2000k -maxrate:v:1 2200k -bufsize:v:1 3000k \
-map [vout003] -c:v:2 libx264 -b:v:2 6000k -maxrate:v:2 6600k -bufsize:v:2 8000k \
-map a:0 -map a:0 -map a:0 -c:a aac -b:a 128k -ac 1 \
-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 v:2,a:2” stream_%v.m3u8
It happens to me that after a few minutes, the master.m3u8 file disappears, leaving only the stream_X.m3u8 files
I appreciate your help
That’s strange. I never hat this issue myself. Did you check the output of FFmpeg in your console? Is there anything related to the master.m3u8?
Well it’s very strange I just see
Opening ‘master.m3u8’ for writing
and after that it just disappears, and continues the log with
Opening ‘stream_0.m3u8.tmp’ for writing6.33 bitrate = N / A dup = 6 drop = 0 speed = 0.198x
I’m trying to reproduce the output of a camera with the multi-resolution video option, and I started doing it with mp4.
In principle it does, but it cuts a lot and this happens that the master.m3u8 disappears and when doing a refresh of the url, I cannot reproduce the video
I appreciate any comment and help
it happen to me during live stream i fixed by adding -master_pl_publish_rate 10 because i set the manifest to 10 segment
but i think the error you have is maybe memory or cpu speed bottle nick
because the speed reduced and frames lost too