[FFmpeg-user] Getting peak bit rate info for HLS .m3u8 master playlist
Joel Lopez
badassmexican at gmail.com
Thu Nov 17 01:10:56 EET 2016
On Wed, Nov 16, 2016 at 2:54 PM, Moritz Barsnick <barsnick at gmx.net> wrote:
> On Wed, Nov 16, 2016 at 20:12:49 +0100, Carl Eugen Hoyos wrote:
>> 2016-11-16 19:50 GMT+01:00 Joel Lopez <badassmexican at gmail.com>:
>> > looking at? Do/How I look at the frames? Where do I look to get this
>> > non-trivial info? I can script it out once I know where to look.
>>
>> Forgive me for being unclear:
>> It is so difficult that I don't know how to do it and I don't know where
>> to look (but I do know that if you were able to do it you wouldn't have
>> to ask).
>>
>> (This is not about finding the biggest frame in a stream afaik, this
>> would of course be trivial.)
>
> I found this information:
>
> http://ramugedia.com/hls--how-determine-peak-bitrate
> (which doesn't point to any source for this info).
>
> It does look scriptable. It would be more difficult to implement for
> ffmpeg, as the hls demuxer would need to keep a memory of each
> segment's properties, and do the math at the end, but perhaps not
> impossible.
>
> Moritz
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
Thanks Moritz. I found that today too but my eyes glazed over as I
looked at the calculation. I think I'll bite the bullet and try to
figure it out.
I also found this today and it prints out what it says is a peak
bitrate. I got it to work on my machine but I'm not sure if it's
giving me the same number as Media Stream Validator.
http://stackoverflow.com/questions/26220557/how-to-get-h264-bitrate
#!/bin/bash
# Mimic the output of
# mplayer -lavdopts vstats FILE -fps 30 -vo null
# Example usage:
# ./vstats.sh file.hevc 30
FFPROBE=$HOME/src/ffmpeg/ffprobe
fps=$2
# default 30 fps
: ${fps:=30}
frames=$3
# Numper of frames to process
: ${frames:=65536}
awk -v FPS="${fps}" -v FRAMES="${frames}" '
BEGIN{
FS="="
}
/pkt_size/ {
br=$2/1000.0*8*FPS
if (br > max_br)
max_br=br
acc_br+=br
acc_bytes+=br
i+=1
printf("frame= %6d, f_size= %7d, s_size= %8dkB, br= %8.1fkbits/s,
avg_br= %8.1fkbits/s\n",
i, $2, int(acc_bytes/1024+0.5), br, acc_br/i)
if (i >= FRAMES)
exit
}
END {
print "----"
printf("Peak BR: %.1fkbits/s", max_br)
}
' <(${FFPROBE} -show_frames $1 2>/dev/null)
Example output:
frame= 1, f_size= 50805, s_size= 12kB, br=
12193.2kbits/s, avg_br= 12193.2kbits/s
frame= 2, f_size= 4749, s_size= 13kB, br=
1139.8kbits/s, avg_br= 6666.5kbits/s
frame= 3, f_size= 5781, s_size= 14kB, br=
1387.4kbits/s, avg_br= 4906.8kbits/s
frame= 4, f_size= 6135, s_size= 16kB, br=
1472.4kbits/s, avg_br= 4048.2kbits/s
frame= 5, f_size= 6239, s_size= 17kB, br=
1497.4kbits/s, avg_br= 3538.0kbits/s
frame= 6, f_size= 6487, s_size= 19kB, br=
1556.9kbits/s, avg_br= 3207.8kbits/s
frame= 7, f_size= 6550, s_size= 20kB, br=
1572.0kbits/s, avg_br= 2974.1kbits/s
frame= 8, f_size= 6567, s_size= 22kB, br=
1576.1kbits/s, avg_br= 2799.4kbits/s
frame= 9, f_size= 6390, s_size= 23kB, br=
1533.6kbits/s, avg_br= 2658.7kbits/s
frame= 10, f_size= 6540, s_size= 25kB, br=
1569.6kbits/s, avg_br= 2549.8kbits/s
frame= 11, f_size= 6929, s_size= 27kB, br=
1663.0kbits/s, avg_br= 2469.2kbits/s
frame= 12, f_size= 8037, s_size= 28kB, br=
1928.9kbits/s, avg_br= 2424.2kbits/s
frame= 13, f_size= 7965, s_size= 30kB, br=
1911.6kbits/s, avg_br= 2384.8kbits/s
frame= 14, f_size= 7833, s_size= 32kB, br=
1879.9kbits/s, avg_br= 2348.7kbits/s
frame= 15, f_size= 8281, s_size= 34kB, br=
1987.4kbits/s, avg_br= 2324.6kbits/s
frame= 16, f_size= 8235, s_size= 36kB, br=
1976.4kbits/s, avg_br= 2302.8kbits/s
frame= 17, f_size= 7969, s_size= 38kB, br=
1912.6kbits/s, avg_br= 2279.9kbits/s
frame= 18, f_size= 7953, s_size= 40kB, br=
1908.7kbits/s, avg_br= 2259.3kbits/s
frame= 19, f_size= 8867, s_size= 42kB, br=
2128.1kbits/s, avg_br= 2252.4kbits/s
frame= 20, f_size= 9686, s_size= 44kB, br=
2324.6kbits/s, avg_br= 2256.0kbits/s
----
Peak BR: 12193.2kbits/s
More information about the ffmpeg-user
mailing list