[FFmpeg-devel] [PATCH] hls: add underlying format option for hls input format

Ivan Grokhotkov igrokhotkov at spbtv.com
Wed Jul 9 13:23:01 CEST 2014


Hi,

By default, hls will autodetect the input format of the downloaded segments. 
This new option allows to force some specific format, which is useful for 
hardware decoders that accept only TS (by supplying 
hls_force_input_format="mpegtsraw" option to avformat_open_input).

The situation has been mentioned in the FFmpeg-users mailing list, so
this patch might be useful:
https://lists.ffmpeg.org/pipermail/ffmpeg-user/2013-October/018306.html

This option should probably be documented somewhere, but I failed to
find an appropriate place. Please comment, so I can update the patch.


Thanks,
Ivan


Signed-off-by: Ivan Grokhotkov <igrokhotkov at spbtv.com>
---
libavformat/hls.c | 7 +++++++
1 file changed, 7 insertions(+)


diff --git a/libavformat/hls.c b/libavformat/hls.c
index 3897723..7ed5fc0 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1318,6 +1318,7 @@ static int hls_read_header(AVFormatContext *s)
    for (i = 0; i < c->n_playlists; i++) {
        struct playlist *pls = c->playlists[i];
        AVInputFormat *in_fmt = NULL;
+        AVDictionaryEntry *dict_entry;

        if (pls->n_segments == 0)
            continue;
@@ -1336,6 +1337,12 @@ static int hls_read_header(AVFormatContext *s)
        ffio_init_context(&pls->pb, pls->read_buffer, INITIAL_BUFFER_SIZE, 0, pls,
                          read_data, NULL, NULL);
        pls->pb.seekable = 0;
+
+        dict_entry = av_dict_get(s->metadata, "hls_force_input_format", NULL, 0);
+        if (dict_entry){
+            in_fmt = av_find_input_format(dict_entry->value);
+        }
+
        ret = av_probe_input_buffer(&pls->pb, &in_fmt, pls->segments[0]->url,
                                    NULL, 0, 0);
        if (ret < 0) {
-- 
1.8.4.2




More information about the ffmpeg-devel mailing list