[FFmpeg-devel] [PATCH] [HACK] hls demuxer: subscribe only to one variant.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Apr 15 20:21:01 CEST 2012


This probably will break lots of things (in particular probing
will not work for the variants, and that will cause longer
startup delays).
However something like this seems to be necessary to fix
trac issue #983.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
 libavformat/hls.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 4b5cd07..df90e9d 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -416,6 +416,7 @@ reload:
         ret = open_input(v);
         if (ret < 0)
             return ret;
+        av_log(v->parent, AV_LOG_INFO, "Opened variant %d\n", v->index);
     }
     ret = ffurl_read(v->input, buf, buf_size);
     if (ret > 0)
@@ -486,6 +487,9 @@ static int hls_read_header(AVFormatContext *s)
     }
 
     /* Open the demuxer for each variant */
+    /* However disable all streams except those in the first,
+     * some servers will refuse to provide data when reading more
+     * than one variant at a time */
     for (i = 0; i < c->n_variants; i++) {
         struct variant *v = c->variants[i];
         AVInputFormat *in_fmt = NULL;
@@ -499,7 +503,7 @@ static int hls_read_header(AVFormatContext *s)
         }
 
         v->index  = i;
-        v->needed = 1;
+        v->needed = !i;
         v->parent = s;
 
         /* If this is a live stream with more than 3 segments, start at the
@@ -537,6 +541,7 @@ static int hls_read_header(AVFormatContext *s)
                 goto fail;
             }
             st->id = i;
+            st->discard = i ? AVDISCARD_ALL : AVDISCARD_NONE;
             avcodec_copy_context(st->codec, v->ctx->streams[j]->codec);
             if (v->bandwidth)
                 av_dict_set(&st->metadata, "variant_bitrate", bitrate_str,
-- 
1.7.10



More information about the ffmpeg-devel mailing list