diff options
author | Jan Ekström <jan.ekstrom@aminocom.com> | 2018-03-23 14:41:28 +0200 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2018-03-25 01:07:10 +0200 |
commit | 5b31dd1c6b1e35d91ce068d6cd20eb4a3d3faa38 (patch) | |
tree | 283a04c4185ca1b7142a71897345e9d2d7e3697f /libavformat | |
parent | 87455b78cc5191d59394f27751da85d588f05d07 (diff) | |
download | ffmpeg-streaming-5b31dd1c6b1e35d91ce068d6cd20eb4a3d3faa38.zip ffmpeg-streaming-5b31dd1c6b1e35d91ce068d6cd20eb4a3d3faa38.tar.gz |
avformat/hlsenc: use stream's maximum bit rate as fall-back advertised rate
Enables having proper bit rate values being written into the master
playlist in case of hard-constrained VBR where the maximum bit
rate utilized is known before hand.
Does the same thing as movenc.c, for example.
Signed-off-by: Jan Ekström <jan.ekstrom@aminocom.com>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/hlsenc.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index b7c6fbd..34fa8484 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1174,6 +1174,21 @@ static int get_relative_url(const char *master_url, const char *media_url, return 0; } +static int64_t get_stream_bit_rate(AVStream *stream) { + AVCPBProperties *props = (AVCPBProperties*)av_stream_get_side_data( + stream, + AV_PKT_DATA_CPB_PROPERTIES, + NULL + ); + + if (stream->codecpar->bit_rate) + return stream->codecpar->bit_rate; + else if (props) + return props->max_bitrate; + + return 0; +} + static int create_master_playlist(AVFormatContext *s, VariantStream * const input_vs) { @@ -1300,9 +1315,9 @@ static int create_master_playlist(AVFormatContext *s, bandwidth = 0; if (vid_st) - bandwidth += vid_st->codecpar->bit_rate; + bandwidth += get_stream_bit_rate(vid_st); if (aud_st) - bandwidth += aud_st->codecpar->bit_rate; + bandwidth += get_stream_bit_rate(aud_st); bandwidth += bandwidth / 10; ccgroup = NULL; |