diff options
author | Peter Große <pegro@friiks.de> | 2017-01-30 13:49:44 +0100 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2017-01-31 00:08:21 +0200 |
commit | 9df9309d233f59d9706444a1e24ac24139f2640d (patch) | |
tree | f479e506af6efa9bd288f88c9ff0c5050337c980 | |
parent | e519dcd937c7c98815ba9884867590e302272016 (diff) | |
download | ffmpeg-9df9309d233f59d9706444a1e24ac24139f2640d.tar.gz |
dashenc: calculate stream bitrate from first segment if not available
Bandwidth information is required in the manifest, but not always
provided by the demuxer. In that case calculate the bandwith based
on the size and duration of the first segment.
Signed-off-by: Peter Große <pegro@friiks.de>
Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r-- | libavformat/dashenc.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 98722cd24e..21acb9006c 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -834,6 +834,16 @@ static int dash_flush(AVFormatContext *s, int final, int stream) if (ret < 0) break; } + + if (!os->bit_rate) { + // calculate average bitrate of first segment + int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE / (os->max_pts - os->start_pts); + if (bitrate >= 0) { + os->bit_rate = bitrate; + snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), + " bandwidth=\"%d\"", os->bit_rate); + } + } add_segment(os, filename, os->start_pts, os->max_pts - os->start_pts, start_pos, range_length, index_length); av_log(s, AV_LOG_VERBOSE, "Representation %d media segment %d written to: %s\n", i, os->segment_index, full_path); } |