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 751E544535 for ; Mon, 19 Dec 2022 04:24:58 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 253B168A9F0; Mon, 19 Dec 2022 06:24:55 +0200 (EET) Received: from APC01-PSA-obe.outbound.protection.outlook.com (unknown [40.107.255.139]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 93D9268A8D9 for ; Mon, 19 Dec 2022 06:24:47 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iStgwep/DHbKZCHYiqMe+jIEHnNVkFroCoWs44LETF4ivMRPKP8Re+0PGQkM2fJdgdQSAAmH96cLt8gg3mArGBMRH+Fj1r4b/Q5W1fffd3VHLsiLcd77iS4AIzPu6GxliCBv0hKy1IBFukRgNAXK5hB1COZWEhL7WyPV6WS92xhgCwmjCuSApYExw0icT5xilmtbhD+XfSRg31OM2p3lpSHJZywfgXFR0oTTeML+NS13VYCDMCAOxUx9TeN/qxJCcJRD5CniZUT3VyzS5JZeBk+a85pXfzVpiuKJljTCJLvyjcvACzOoBQsmic5gatcpw5CWRQiBSyA77lpEnHWAAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=P+ZOQB3AKkQ5z26V6zUAUzY8C3VBFysXVRXsu6V5BmQ=; b=NjU/jfsrCsD8Pp5dZiabDGzaOIfsAPjKeiIGrPcBW+ZkKUAwHR8oxSaJx4h6U29DTL0JOcBhEiCxrGqJZqnwjk/cTht42BmVctx7TO0P8mfcWgwsH+enpLBbZvqvulYPXcvJ09Ql1M+LX20pvA+iNu8Bav/+1X11a8Paoa5cXJfTg0dbq0U0sdJmDldgf9bq/rtC3cC+9XwPHlekFuB+NkQXiLKY5Xzf5FpoWxLLRmhF02PbgZ1BFTDqVp+UZVrcB3l4xotSnhCe23DPXpSuLI+jiQF3V9XZvdQ5n97nORCgbguwxZnONdmi7nJ3kPEdaIyNEyCl0yPwVrzySigekA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=agora.io; dmarc=pass action=none header.from=agora.io; dkim=pass header.d=agora.io; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agora.io; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P+ZOQB3AKkQ5z26V6zUAUzY8C3VBFysXVRXsu6V5BmQ=; b=vNI4b1fwuC+i4B1cCmuK19w73dbzO2/QNZL4TQmbnvao6z6Px2uG44HqyIi6sburQTjRdfD3P/h1Z5nTR/g411plPD1wavxR3zN6lUCB5Y4d3KpqftpMPkI8Oew9rDo6R/ivhAwiwt4u2W4+TWYicm9Lu19HNy8b9GdlN6on97s6RMk7bvGzr3KxBV+rGv91YkLYRHD/O9nmGP/swIEKrODN2tIhkQUfiMPN5XaZ0mH4sXYFaCguh/G5V03RwJIt+M/xHk/oOTWVMRoPmfFLuMGiHRfO7J4/JjAO4n53AfLpcJivQNuKpYDFpN061fXfoUYiLWYpnTE2Jmj9LXMYww== Received: from TY0PR02MB5328.apcprd02.prod.outlook.com (2603:1096:400:144::8) by SEYPR02MB5509.apcprd02.prod.outlook.com (2603:1096:101:3e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.16; Mon, 19 Dec 2022 04:24:43 +0000 Received: from TY0PR02MB5328.apcprd02.prod.outlook.com ([fe80::e82:3e95:b5ef:329f]) by TY0PR02MB5328.apcprd02.prod.outlook.com ([fe80::e82:3e95:b5ef:329f%8]) with mapi id 15.20.5924.016; Mon, 19 Dec 2022 04:24:43 +0000 From: "Chen, Jinkai" To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH] avformat/mov: fix buffering issue on playing HTTP(s)/mp4. Thread-Index: AQHZE2HRFjMXdqGJBEKl0yRPVXQgAg== Date: Mon, 19 Dec 2022 04:24:42 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=agora.io; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: TY0PR02MB5328:EE_|SEYPR02MB5509:EE_ x-ms-office365-filtering-correlation-id: 5a06e058-3094-450c-16e4-08dae178f3e6 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PFqYJeQAOlzyF+R9GJAshA55xjmZODrL7+NYCtPBktlOZr0qAKzwRbexW20978OS3sZDgCCp7V4N8S7scnH/c/Ebxfh6SJ8qRbuzQ3HVdt1UBm+HXPjjp7Ob06/IZchRyC3z8hxM3jKrtZ4g/vBA0zGTrSVFqQeBovGuzVQeaf3QEZh3UKX/XTekS8PfFPbUofrpH067NVhOtGKDwZtTV9enKjiDdkZlvKPMELhQiEqMKovEMSfo4tPdkEZL2xy9/MVxeBww+gmfvPTQu/4hK6OMoW6OpSsBs/XixzNuUvSbA0T509+gbO+GVUTnz8kbpmmda8K1pdx1nF4ky/KkWM9f5LUONTmClrEPqMywWBbiZ8wskj7ciaX5PZ7+SwdNW3X8KU9gHGZuB63lQMFbbtWOPrc8yy3JRXRLhQvCkmsf76F1eNviYfioZ+1z2C85qwmop++Yb2inKsSv8MFuyHiDOGQ34fm/LomM14aborOb8xkffiysvwu8gdppQZAiBlIHtxTZlrfPFKqH2I/5iIS0qFPEK45Tck8ZCh7zhtrP/zVbP3qByfkkPs8/PF5NDj+ImsB2cEXYgGqN7jJOf7h9e1rQ/qGS/3gNIGbML8ZNi8aqpN6fogEeKfIzn0s7/5bnxoPo8+F4EfU5ItItpH6FqoFIi1piIuTZwu+ZeFo/flCVoynuQT42Oxtr7hi+IRSYFoCYir6yqzgy3YQj3kx8e9dVGOlRM7lzrLJ40r7RxF3PdjDfUYbbEmKLsmXJ x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TY0PR02MB5328.apcprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(346002)(396003)(376002)(136003)(366004)(39840400004)(451199015)(66946007)(76116006)(91956017)(86362001)(66476007)(66446008)(64756008)(66556008)(8676002)(316002)(5660300002)(36756003)(8936002)(2616005)(33656002)(41300700001)(6506007)(6512007)(186003)(26005)(83380400001)(71200400001)(38070700005)(122000001)(6916009)(38100700002)(6486002)(478600001)(166002)(966005)(2906002)(45980500001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?E6n4bhpoHTKD3OESSnlsOib65d+2W/u+X6mVC8uLiMQ0F97b7m2NJrvXm9RZ?= =?us-ascii?Q?Q9RQgRITUUUBY+kz4y8RAi6ajFbYTdV3ctslL5ms9yWTJAIa+l9cg5dwbR2V?= =?us-ascii?Q?EtReIOUJcuRvLeHSg1sStRc3s0kLY0QSxHsJE8JWVgCqAWDu9WOx8YEfMJNW?= =?us-ascii?Q?73wsTBwTv/YCLHfBeXjhV3pHrJXRo2gg0HTm0diSZ9bFVVDvpxxZ4rSMpt+g?= =?us-ascii?Q?g99aYqkh2o14xBBrj3HkQ+ZuhFkzHSkzPa/2oejsLk3BxEECu/v9Q9eI1913?= =?us-ascii?Q?16iw3gTcEIfQ8zKo3WOCaDcb7p9gQn5rD4xT2B/5tlc7ybZHzKMAu1LQbLxd?= =?us-ascii?Q?iCfm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wCX7b2Mv?= =?us-ascii?Q?cT/xxGvB+BiGadWEg98dkUql0mzsHOICCOtsQ4ntff71wzCffD/S89Lna/GQ?= =?us-ascii?Q?Nlzab6uXy11hQ6XqBJkAsqg5Pzmca0QfgwMratev3ahTBvDedR8GdzYuy7/e?= =?us-ascii?Q?jchQ3S0+ALXZIz/Ot54GeAJW4anupOyr+cENj+VuQCUqgCmRSAr/vAwReUtT?= =?us-ascii?Q?LUbdEQWpKfxjJ6dFlD/y55FV2sqsHitVCBYuPm5oa1IiTywnZ2d7Oyeo2sqy?= =?us-ascii?Q?f+pRkcQmRlnO/6HJXd+FkMNwDtHwGAWZA+WuW8k3+LSDcVphE+bruN9Ewd2J?= =?us-ascii?Q?9YxMVRXvnA7yOR1HCVak3WoaPzIJ2z205soy6Jaw?= MIME-Version: 1.0 X-OriginatorOrg: agora.io X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TY0PR02MB5328.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a06e058-3094-450c-16e4-08dae178f3e6 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2022 04:24:42.9989 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 60275374-3eaa-49c2-83c3-cc189d126981 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: LtO9dYfSs/0jVvhBvfChOPYR+pK/BgRdiUHAKF2rWnV/t9DkifRNjXWIx2lNwoSCjcfuoYrpd4m+5uESU2dHNw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR02MB5509 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] [PATCH] avformat/mov: fix buffering issue on playing 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: Using separated HTTP connection for each stream, prevent from reading audio and video in long distance, which cause seeking(http request) repeatedly. Storing the user options when open input, and make sure that can be passed to demuxer context. Some source can reproducing the issue: https://ali-sprite-video.yyouwang.com/video/works/202211/1667997073624_73.mp4 https://images.voghion.com/productImages/04_01_C_30011_2020220106GiuseppeFanara0012.mp4 Signed-off-by: CJK > --- libavformat/avformat.c | 1 + libavformat/demux.c | 5 ++++- libavformat/internal.h | 5 +++++ libavformat/mov.c | 16 ++++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) 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/mov.c b/libavformat/mov.c index 29bd3103e3..1e1a7c2f7f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4456,6 +4456,7 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; + URLContext *url_context; int ret; st = avformat_new_stream(c->fc, NULL); @@ -4501,6 +4502,8 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) mov_build_index(c, st); + url_context = ffio_geturlcontext(c->fc->pb); + av_assert0(url_context); if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { MOVDref *dref = &sc->drefs[sc->dref_id - 1]; if (c->enable_drefs) { @@ -4510,6 +4513,19 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n", st->index, dref->path, dref->dir, dref->filename, dref->volume, dref->nlvl_from, dref->nlvl_to); + } else if (strcmp(url_context->prot->name, "http") == 0 || + strcmp(url_context->prot->name, "https") == 0) { + 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, + "mov/http(s) stream %d, error opening url %s.\n", + st->index, c->fc->url); + return ret; + } } else { av_log(c->fc, AV_LOG_WARNING, "Skipped opening external track: " -- 2.24.3 (Apple Git-128) _______________________________________________ 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".