From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id A7CD540511 for ; Thu, 22 Dec 2022 12:11:20 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6420368B9B7; Thu, 22 Dec 2022 14:11:16 +0200 (EET) Received: from out203-205-251-80.mail.qq.com (out203-205-251-80.mail.qq.com [203.205.251.80]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A0A5D6804F9 for ; Thu, 22 Dec 2022 14:11:09 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1671711064; bh=bGyndwfbtRV1IUVNaJU4AEbqQIGIY/Lgwx7QQXYXxg0=; h=Subject:From:To:Date:In-Reply-To:References; b=RtP4skEg8W6HmKSnmLVsIqSwcO1sLJy6u7EX5GfE/VIHX68mdjaWmhYh8O1Mz+LAA 6UY6PMrYAprDIq8nu6mYPTvSRkrn3ogq6Pf4MuwqmgN3d3YIcXZHdfftblLF99+eIr xCY3fvVFBWqMnJ3EyCiizt9ZzM2wOSDk8XkybZSk= Received: from zhilizhao-LC4 ([113.118.115.165]) by newxmesmtplogicsvrsza2-0.qq.com (NewEsmtp) with SMTP id 2C3134D7; Thu, 22 Dec 2022 20:11:03 +0800 X-QQ-mid: xmsmtpt1671711063tuux7aczq Message-ID: X-QQ-XMAILINFO: MFWpArBVhhGTN5ORdLEbE4vW+XZcEgYCoLPe+0fHrlyJI/k8Twgn5rR87YsGDx GPbxCKJDDWdRwQT80rHmtOnKb7MCfZjg4LfB4k9DFIk+hVYZG+7SNjtTgov6LlaFlw1GxJ5Tmv41 vTxhReUznifwa+1ACdnZ6IKyPA69+vPRh7EeuqpqeC/1bdnb5icIzx35eoILyQ8BR2ao0BwdoTyE N2ebbLm0yI59onU3ysOopKTFfOUjhSoixO0nbMsp8aWyGeVEJdZULEvMcXKEh/Zxp6ebzufeybDc 9X20VYbP0Z14114FwAW0Wj1LVFFRNi7XtdBqDPU//UG8+CzOlwPGuViKYH8AIFL4yW0qJ/Yw+yNn TwqnOWl+ymp/kU71LkoFIqILEN+Hc2mJlBBktute13pkMjtmpImeN5Pres/wyCOL+iXUNkKb6Gvs bCVaI9z6YCdX88Ohw7E0SB4QkYaVVEKIl+7GNj+Vge2xnnXeVu0QgxaMjc5HcO0XJnRqapdj0MQA lXuSIoMUVB+9XX7Xmo4MbLQlxTGFyTB0zUQcjUQS6MOS/Ei+e2WiUjXEJhPTUUIXL/dgCHjvbdLN pkG7X0CsWhvZ+Ci+Mj3EWV61yHyNMatWRfWnjKAqtzt1io4vp/qOWdjsCg/FvmE7Kz9y9bJ0YqM1 NUSAh5cKBvUIYSRylKRYVWQrGEuOzb/ldx05sqQyd9eOvwC7XkfbBZuml8zm16XGJJPNo4mddu9q vk8/CCefGLlctUnIRVhpHNh/kEua0fmLCmWWpVlGPMWNPMG0L3LRTv/Ox3FBJUtfAIrqv+QuuF2n mE5fOn4g6TLQOnEJDLmJdGWbC/TjX9up2zKTybwzRQgE2/7hqxWo/YzDauQ6GVeaKRq1ZmxdLQjI yZdeLKv/DJcAVeiGJ+7AMlqDTFCBZRDOaZCeNXP8t5f3FV5badhCGOy3X2ng2avOtjbQpTZ2uPR+ 3OBEInG+VQtrKeBi2EJXpMIgtwvXtDflylfBvu0pY= X-OQ-MSGID: From: Zhao Zhili To: FFmpeg development discussions and patches Date: Thu, 22 Dec 2022 20:11:03 +0800 In-Reply-To: <9A8AE84C-B549-47E0-99FF-40AE6CB4F58A@agora.io> References: <9A8AE84C-B549-47E0-99FF-40AE6CB4F58A@agora.io> User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v2] avformat/mov: fix buffering issue for special HTTP(s) mp4. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Tue, 2022-12-20 at 09:20 +0000, Chen, Jinkai wrote: > Problem: > Using ffplay play on these sources: > https://ali-sprite-video.yyouwang.com/video/works/202211/1667997073624_73.mp4 > https://images.voghion.com/productImages/04_01_C_30011_2020220106GiuseppeFanara0012.mp4 > > Solution: > Add a private option, it will use separated IO context(HTTP > connection) > for each AVStream. Preventing from reading audio and video in > long distance(offset), which cause seeking(HTTP request) frequently. > > Storing the user options when open input, > and make sure that can be passed to demuxer context. I'm afraid such workaround is difficult to maintain for long term. You can achieve the same result (with a little overhead) with multiple AVFormatContexts, which is still abuse of network transport. The only elegant way I can get to handle such broken files is download to local storage and remux. > > Signed-off-by: Gamhoi Chan chenjinkai@agora.io>> > --- > libavformat/avformat.c | 1 + > libavformat/demux.c | 5 ++++- > libavformat/internal.h | 5 +++++ > libavformat/isom.h | 1 + > libavformat/mov.c | 14 +++++++++++++- > 5 files changed, 24 insertions(+), 2 deletions(-) > > diff --git a/libavformat/avformat.c b/libavformat/avformat.c > index 19c7219471..4453727f34 100644 > --- a/libavformat/avformat.c > +++ b/libavformat/avformat.c > @@ -129,6 +129,7 @@ void avformat_free_context(AVFormatContext *s) > av_freep(&s->chapters); > av_dict_free(&s->metadata); > av_dict_free(&si->id3v2_meta); > + av_dict_free(&si->options); > av_packet_free(&si->pkt); > av_packet_free(&si->parse_pkt); > av_freep(&s->streams); > diff --git a/libavformat/demux.c b/libavformat/demux.c > index 2dfd82a63c..2377bfdab0 100644 > --- a/libavformat/demux.c > +++ b/libavformat/demux.c > @@ -237,8 +237,11 @@ int avformat_open_input(AVFormatContext **ps, > const char *filename, > if (fmt) > s->iformat = fmt; > > - if (options) > + if (options) { > av_dict_copy(&tmp, *options, 0); > + si->options = NULL; > + av_dict_copy(&si->options, *options, 0); > + } > > if (s->pb) // must be before any goto fail > s->flags |= AVFMT_FLAG_CUSTOM_IO; > diff --git a/libavformat/internal.h b/libavformat/internal.h > index ce837fefc7..7caae8b93e 100644 > --- a/libavformat/internal.h > +++ b/libavformat/internal.h > @@ -186,6 +186,11 @@ typedef struct FFFormatContext { > * Contexts and child contexts do not contain a metadata option > */ > int metafree; > + > + /** > + * options from avformat_open_input > + */ > + AVDictionary *options; > } FFFormatContext; > > static av_always_inline FFFormatContext > *ffformatcontext(AVFormatContext *s) > diff --git a/libavformat/isom.h b/libavformat/isom.h > index 64fb7065d5..dad049a2df 100644 > --- a/libavformat/isom.h > +++ b/libavformat/isom.h > @@ -326,6 +326,7 @@ typedef struct MOVContext { > int64_t extent_offset; > } *avif_info; > int avif_info_size; > + int use_stream_pb; > } MOVContext; > > int ff_mp4_read_descr_len(AVIOContext *pb); > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 29bd3103e3..0d5818b327 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -4519,6 +4519,18 @@ static int mov_read_trak(MOVContext *c, > AVIOContext *pb, MOVAtom atom) > st->index, dref->path, dref->dir, dref->filename, > dref->volume, dref->nlvl_from, dref->nlvl_to); > } > + } else if (c->use_stream_pb) { > + FFFormatContext *const si = ffformatcontext(c->fc); > + AVDictionary *opts = NULL; > + av_dict_copy(&opts, si->options, 0); > + ret = c->fc->io_open(c->fc, &sc->pb, c->fc->url, > AVIO_FLAG_READ, &opts); > + av_dict_free(&opts); > + if (ret < 0) { > + av_log(c->fc, AV_LOG_ERROR, > + "use_stream_pb, stream %d, error opening url %s.\n", > + st->index, c->fc->url); > + return ret; > + } > } else { > sc->pb = c->fc->pb; > sc->pb_is_copied = 1; > @@ -9119,7 +9131,7 @@ static const AVOption mov_options[] = { > { "enable_drefs", "Enable external track support.", > OFFSET(enable_drefs), AV_OPT_TYPE_BOOL, > {.i64 = 0}, 0, 1, FLAGS }, > { "max_stts_delta", "treat offsets above this value as invalid", > OFFSET(max_stts_delta), AV_OPT_TYPE_INT, {.i64 = UINT_MAX-48000*10 }, > 0, UINT_MAX, .flags = AV_OPT_FLAG_DECODING_PARAM }, > - > + { "use_stream_pb", "Each steam has its own AVIOContext.", > OFFSET(use_stream_pb), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS }, > { NULL }, > }; > > -- > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".