[FFmpeg-devel,7/8] libavformat/dashenc: support for hinting stream bandwidth using metadata option

Submitted by Peter Große on Jan. 21, 2017, 2:39 p.m.

Details

Message ID 20170121143909.29028-8-pegro@friiks.de
State New
Headers show

Commit Message

Peter Große Jan. 21, 2017, 2:39 p.m.
Bandwidth information is required in the manifest, but not always provided by the demuxer.
So enable hinting the stream bandwidth via a metadata field, supports same values as codec bitrate setting.

Example: -metadata:s:v:0 bitrate=3500k

Signed-off-by: Peter Große <pegro@friiks.de>
---
 libavformat/dashenc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 0c0248f..522a0eb 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -607,6 +607,17 @@  static int dash_init(AVFormatContext *s)
         char filename[1024];
 
         os->bit_rate = s->streams[i]->codecpar->bit_rate;
+        // if no bit rate detected, try whether bitrates are provided via metadata
+        if(!os->bit_rate) {
+            AVDictionaryEntry *bitrate;
+            bitrate = av_dict_get(s->streams[i]->metadata, "bitrate", NULL, 0);
+            if(bitrate) {
+                char *tail;
+                os->bit_rate = av_strtod(bitrate->value, &tail);
+                if (*tail)
+                    os->bit_rate = 0;
+            }
+        }
         if (os->bit_rate) {
             snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
                      " bandwidth=\"%d\"", os->bit_rate);