[FFmpeg-devel,2/3] lavf/dashenc: add format_options option, mirroring segment.c

Submitted by Rodger Combs on Sept. 26, 2017, 7:54 p.m.

Details

Message ID 20170926195500.88129-2-rodger.combs@gmail.com
State New
Headers show

Commit Message

Rodger Combs Sept. 26, 2017, 7:54 p.m.
---
 libavformat/dashenc.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 92d398ab50..7ed48905f5 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -100,6 +100,7 @@  typedef struct DASHContext {
     AVRational min_frame_rate, max_frame_rate;
     int ambiguous_frame_rate;
     const char *utc_timing_url;
+    const char *format_options_str;
 } DASHContext;
 
 static struct codec_string {
@@ -785,6 +786,17 @@  static int dash_init(AVFormatContext *s)
             dict_set_int(&opts, "cluster_time_limit", c->min_seg_duration / 1000, 0);
             dict_set_int(&opts, "cluster_size_limit", 5 * 1024 * 1024, 0); // set a large cluster size limit
         }
+
+        if (c->format_options_str) {
+            ret = av_dict_parse_string(&opts, c->format_options_str, "=", ":", 0);
+            if (ret < 0) {
+                av_log(s, AV_LOG_ERROR, "Could not parse format options list '%s'\n",
+                       c->format_options_str);
+                av_dict_free(&opts);
+                return ret;
+            }
+        }
+
         if ((ret = avformat_init_output(ctx, &opts)) < 0)
             return ret;
         os->ctx_inited = 1;
@@ -1190,6 +1202,7 @@  static const AVOption options[] = {
     { "init_seg_name", "DASH-templated name to used for the initialization segment", OFFSET(init_seg_name), AV_OPT_TYPE_STRING, {.str = "init-stream$RepresentationID$.m4s"}, 0, 0, E },
     { "media_seg_name", "DASH-templated name to used for the media segments", OFFSET(media_seg_name), AV_OPT_TYPE_STRING, {.str = "chunk-stream$RepresentationID$-$Number%05d$.m4s"}, 0, 0, E },
     { "utc_timing_url", "URL of the page that will return the UTC timestamp in ISO format", OFFSET(utc_timing_url), AV_OPT_TYPE_STRING, { 0 }, 0, 0, E },
+    { "format_options", "set list of options for the underlying mp4 muxer", OFFSET(format_options_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E },
     { NULL },
 };