Le quintidi 15 ventôse, an CCXXIII, Zhang Rui a écrit : > I'm using concatdec for streaming http segments. > which need options like timeout, user_agent.
Ok. > Your solution is enough for my case. > And as you said, my patch may be not desirable. I believe it depends on the use case, and it is not completely obvious which side your example falls on. But in the meantime I have started implementing per-file options for the concat demuxer, see the attached patch. Regards, -- Nicolas George
From fbbc4d5a4f99a0c58af63477a4daf056ceeea479 Mon Sep 17 00:00:00 2001 From: Nicolas George <geo...@nsup.org> Date: Thu, 5 Mar 2015 13:31:35 +0100 Subject: [PATCH] lavf/concatdec: add per-file options. [WIP] Signed-off-by: Nicolas George <geo...@nsup.org> --- libavformat/concatdec.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index f07cfd7..d0a7f1e 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -44,6 +44,7 @@ typedef struct { int64_t duration; ConcatStream *streams; int nb_streams; + AVDictionary *options; } ConcatFile; typedef struct { @@ -279,6 +280,7 @@ static int open_file(AVFormatContext *avf, unsigned fileno) { ConcatContext *cat = avf->priv_data; ConcatFile *file = &cat->files[fileno]; + AVDictionary *options = NULL; int ret; if (cat->avf) @@ -290,15 +292,17 @@ static int open_file(AVFormatContext *avf, unsigned fileno) cat->avf->interrupt_callback = avf->interrupt_callback; + av_dict_copy(&options, file->options, 0); if ((ret = ff_copy_whitelists(cat->avf, avf)) < 0) return ret; - if ((ret = avformat_open_input(&cat->avf, file->url, NULL, NULL)) < 0 || + if ((ret = avformat_open_input(&cat->avf, file->url, NULL, &options)) < 0 || (ret = avformat_find_stream_info(cat->avf, NULL)) < 0) { av_log(avf, AV_LOG_ERROR, "Impossible to open '%s'\n", file->url); avformat_close_input(&cat->avf); return ret; } + /* TODO report unused options */ cat->cur_file = file; if (file->start_time == AV_NOPTS_VALUE) file->start_time = !fileno ? 0 : @@ -332,6 +336,7 @@ static int concat_read_header(AVFormatContext *avf) int ret, line = 0, i; unsigned nb_files_alloc = 0; ConcatFile *file = NULL; + AVDictionary *common_options = NULL, **options = &common_options; int64_t time = 0; while (1) { @@ -351,6 +356,8 @@ static int concat_read_header(AVFormatContext *avf) } if ((ret = add_file(avf, filename, &file, &nb_files_alloc)) < 0) goto fail; + av_dict_copy(&file->options, common_options, 0); + options = &file->options; } else if (!strcmp(keyword, "duration")) { char *dur_str = get_keyword(&cursor); int64_t dur; @@ -376,6 +383,18 @@ static int concat_read_header(AVFormatContext *avf) } avf->streams[avf->nb_streams - 1]->id = strtol(get_keyword(&cursor), NULL, 0); + } else if (!strcmp(keyword, "option")) { + char *key = get_keyword(&cursor); + char *val = av_get_token((const char **)&cursor, SPACE_CHARS); + if (!val) { + av_log(avf, AV_LOG_ERROR, "Line %d: option value required\n", line); + FAIL(AVERROR_INVALIDDATA); + } + ret = av_dict_set(options, key, val, AV_DICT_DONT_STRDUP_VAL); + if (ret < 0) { + av_free(val); + goto fail; + } } else if (!strcmp(keyword, "ffconcat")) { char *ver_kw = get_keyword(&cursor); char *ver_val = get_keyword(&cursor); @@ -395,6 +414,7 @@ static int concat_read_header(AVFormatContext *avf) goto fail; if (!cat->nb_files) FAIL(AVERROR_INVALIDDATA); + av_dict_free(&common_options); for (i = 0; i < cat->nb_files; i++) { if (cat->files[i].start_time == AV_NOPTS_VALUE) @@ -417,6 +437,7 @@ static int concat_read_header(AVFormatContext *avf) return 0; fail: + av_dict_free(&common_options); concat_read_close(avf); return ret; } -- 2.1.4
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel