On Sun, 29 Jan 2017, Peter Große wrote:
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 <[email protected]>
---
v2: reword commit message
---
libavformat/dashenc.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 98722cd..ae1bb0b 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
+ double bitrate = (int)( (double) range_length * 8.0 * AV_TIME_BASE /
(double)(os->max_pts - os->start_pts) );
Sorry for not pointing it out in the last round, but promoting this to
double feels a bit superfluous. Just cast to int64_t instead, that should
be just fine for this use case. (Floats can end up rounded differently on
different platforms, and even though it doesn't really matter here, having
it completely determinisic when easily possible is desireable.)
// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel