[FFmpeg-devel] [PATCH] [UPDATE] HLS, add option to skip down streams,

Amine kabab kabab1993 at gmail.com
Thu Apr 20 19:18:37 EEST 2017



On 18/04/2017 17:00, Amine kabab wrote:
> option to skip down streams in HLS
>

-------------- next part --------------
>From 5079f9b7114589626a4c9fff0fbb8f6e0d2f4fd9 Mon Sep 17 00:00:00 2001
From: amine kabab <kabab1993 at gmail.com>
Date: Thu, 20 Apr 2017 15:59:42 +0000
Subject: [PATCH] HLS skip down streams

---
 libavformat/hls.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index bac53a4..26d7679 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -194,6 +194,7 @@ typedef struct HLSContext {
 
     int cur_seq_no;
     int live_start_index;
+    int skip_down_streams;
     int first_packet;
     int64_t first_timestamp;
     int64_t cur_timestamp;
@@ -1652,11 +1653,20 @@ static int hls_read_header(AVFormatContext *s)
     /* If the playlist only contained playlists (Master Playlist),
      * parse each individual playlist. */
     if (c->n_playlists > 1 || c->playlists[0]->n_segments == 0) {
+        int all_failed = 1;
         for (i = 0; i < c->n_playlists; i++) {
             struct playlist *pls = c->playlists[i];
-            if ((ret = parse_playlist(c, pls->url, pls, NULL)) < 0)
+            av_log(NULL, AV_LOG_WARNING, "Trying %s\n", pls->url);
+            ret = parse_playlist(c, pls->url, pls, NULL);
+            if (c->skip_down_streams && ret >= 0) {
+                all_failed = 0;
+            } else if (!c->skip_down_streams && ret < 0){
                 goto fail;
+            }
         }
+
+        if (all_failed)
+            goto fail;
     }
 
     if (c->variants[0]->playlists[0]->n_segments == 0) {
@@ -2126,6 +2136,8 @@ static int hls_probe(AVProbeData *p)
 static const AVOption hls_options[] = {
     {"live_start_index", "segment index to start live streams at (negative values are from the end)",
         OFFSET(live_start_index), AV_OPT_TYPE_INT, {.i64 = -3}, INT_MIN, INT_MAX, FLAGS},
+    {"skip_down_streams", "continue playback of HLS when one of the variant streams are down",
+        OFFSET(skip_down_streams), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS},
     {NULL}
 };
 
-- 
1.8.3.1



More information about the ffmpeg-devel mailing list