Bandwidth information is required in the manifest, but not always provided by the demuxer. If not available via metadata calculate bandwith based on the size and duration of the first segment.
Signed-off-by: Peter Große <[email protected]> --- libavformat/dashenc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 1cd9563..1b12d4f 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -846,6 +846,17 @@ static int dash_flush(AVFormatContext *s, int final, int stream) if (ret < 0) break; } + + if (!os->bit_rate) { + // calculate average bitrate of first segment + double bitrate = (int)( (double) range_length * 8.0 * AV_TIME_BASE / (double)(os->max_pts - os->start_pts) ); + if (bitrate >= 0 && bitrate <= INT64_MAX) { + 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); } -- 2.10.2 _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
