Browse code

segment: Add an option to prepend a string to the list entries

Useful to generate lists with absolute urls.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>

Enrique Arizón Benito authored on 2014/03/19 05:18:59
Showing 2 changed files
... ...
@@ -480,6 +480,8 @@ Set segment duration to @var{t} seconds.
480 480
 Generate also a listfile named @var{name}.
481 481
 @item segment_list_size @var{size}
482 482
 Overwrite the listfile once it reaches @var{size} entries.
483
+@item segment_list_entry_prefix @var{prefix}
484
+Prepend @var{prefix} to each entry. Useful to generate absolute paths.
483 485
 @item segment_wrap @var{limit}
484 486
 Wrap around segment index once it reaches @var{limit}.
485 487
 @end table
... ...
@@ -37,6 +37,7 @@ typedef struct {
37 37
     AVFormatContext *avf;
38 38
     char *format;          /**< Set by a private option. */
39 39
     char *list;            /**< Set by a private option. */
40
+    char *entry_prefix;    /**< Set by a private option. */
40 41
     int  list_type;        /**< Set by a private option. */
41 42
     float time;            /**< Set by a private option. */
42 43
     int  size;             /**< Set by a private option. */
... ...
@@ -97,6 +98,9 @@ static int segment_hls_window(AVFormatContext *s, int last)
97 97
     for (i = FFMAX(0, seg->number - seg->size);
98 98
          i < seg->number; i++) {
99 99
         avio_printf(seg->pb, "#EXTINF:%d,\n", (int)seg->time);
100
+        if (seg->entry_prefix != NULL) {
101
+            avio_printf(seg->pb, "%s", seg->entry_prefix);
102
+        }
100 103
         av_get_frame_filename(buf, sizeof(buf), s->filename, i);
101 104
         avio_printf(seg->pb, "%s\n", buf);
102 105
     }
... ...
@@ -363,6 +367,7 @@ static const AVOption options[] = {
363 363
     {   "flat",            "plain list (default)",                    0,               AV_OPT_TYPE_CONST,  {.i64 = LIST_FLAT}, 0, 0, E, "list_type" },
364 364
     {   "hls",             "Apple HTTP Live Streaming compatible",    0,               AV_OPT_TYPE_CONST,  {.i64 = LIST_HLS},  0, 0, E, "list_type" },
365 365
     { "segment_wrap",      "number after which the index wraps",      OFFSET(wrap),    AV_OPT_TYPE_INT,    {.i64 = 0},     0, INT_MAX, E },
366
+    { "segment_list_entry_prefix",  "base url prefix for segments",   OFFSET(entry_prefix), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,       E },
366 367
     { "individual_header_trailer", "write header/trailer to each segment", OFFSET(individual_header_trailer), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E },
367 368
     { "write_header_trailer", "write a header to the first segment and a trailer to the last one", OFFSET(write_header_trailer), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E },
368 369
     { NULL },