From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id DCDD14F780 for ; Mon, 23 Jun 2025 02:03:09 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 59B5B68EEFD; Mon, 23 Jun 2025 05:03:05 +0300 (EEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11olkn2095.outbound.protection.outlook.com [40.92.19.95]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id E14D368EDB0 for ; Mon, 23 Jun 2025 05:02:58 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CjJMgREFGdJcxOd74usR6hikyNeqKr52Yu4vXN/aPPXIAwjTkQxoikDl2svEB2pORYlRT7rmEJoXGvsM3NPjm4UlwCs+zUesI1Gd8s0wPvBtmWGk4rl4LUaS5F6wjzXkfvCmJPo4CvMBCz9OGHU0jmN3Xid1/AOsq+wegJq6NReLq2Yjpyow+VM8l4n+JtAoX53g+l6h+i/gk9gYYiNi+M7MHa84S9ScD3PLfCpgCntQ1Z9TNvH1LouE8Ncya3sZ9FEbnLGMGKZRpMOpOQ8P8x1iOUxVxZftf/iZgGBvgkrqjvoIvhsL3NW54VepzdYVA40vwZDBBimh74YzKNjmJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=ZeJrOX9vaPTIG3kyrWf5rSFSc3NXF1E/GacAST+0rXY=; b=RCZfEYHhhPot1PekytKfAGsWaMSpxqPiYJ98n832+3Su2AiOr5R25jBQbWxwEnxP8hjwlEJbc19mWjuPNmcFZ2CgSRK8eCTgcB2ML2Dr/WO3oVRQcQAkYFQEmiAS96gA4xT1Gm/ddKhWnoTflz1dMNXbL+lsc5pIsPiqlPUF3plfFcBDMwBtHifIIfB/3aKsAvdlI3SaSvrBSrnRJdamORi8hbWTpT0+fBNd5ErEBekmWKl0m6kcZ1XJTVUJfsMVirhigpsduX/aqnx2Je7vnEa8qYnZk6f9HVGhygu6GpgKzoY7TshUKlj1MDvSg5V+X9oSUp+O3h057k6uTcVP9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZeJrOX9vaPTIG3kyrWf5rSFSc3NXF1E/GacAST+0rXY=; b=KDV+xDRzHPHCkaIB7+8mhRTyExVkAt/VRvYuxlV1k/TJChTAjP+cJou1ufPJTho8qRm3/qQ3EdAUba9zMFjFfMz8nEbEcIFrGhQxueectEKsPhRMS1onX57MJR8um46cSbMWR86AVJMTM/T8f1BT0YpDJcmh1HD6y/RvdXsHpULIe0A9IZ1fEbohpWTmFn7woD0YOP9OBaO71BRydZpCpRtDZlEf18Gtde8MmhRGMGZBxkGd4NTCnDZB40XIav7MSq+kGM56HKC3dy3Ay6/r9jbZZMNSY/Qe01hxlXFrkyFLdT6yoY8xbXAlbYTOXczDpRMGY/tkfsUw5/DV9FIfIg== Received: from DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM (2603:10b6:8:b::20) by BL3P223MB0193.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:34a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8857.28; Mon, 23 Jun 2025 02:02:55 +0000 Received: from DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM ([fe80::bf09:8e9:b07f:98a7]) by DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM ([fe80::bf09:8e9:b07f:98a7%6]) with mapi id 15.20.8857.026; Mon, 23 Jun 2025 02:02:55 +0000 From: "softworkz ." To: FFmpeg development discussions and patches Thread-Topic: [FFmpeg-devel] [PATCH 05/10] doc/muxers: Add documentation for segment_limit option Thread-Index: AQHb3Ce1JEyc6RJW1UWZRoOvVHgo7LQBilOAgAAK5iCAAA9qAIAAB4fggAEmNYCADSRzcA== Date: Mon, 23 Jun 2025 02:02:55 +0000 Message-ID: References: <53b693320f1cf07ee6094342a60002bc9cfc3d79.1749794067.git.ffmpegagent@gmail.com> <764ebc53-28d4-8671-117b-d76b453770b9@passwd.hu> <4e2b3b0c-27ea-c803-b2d5-4dc8bc602a18@passwd.hu> In-Reply-To: <4e2b3b0c-27ea-c803-b2d5-4dc8bc602a18@passwd.hu> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM8P223MB0365:EE_|BL3P223MB0193:EE_ x-ms-office365-filtering-correlation-id: ef20d832-582f-4419-e5ad-08ddb1fa11ad x-microsoft-antispam: BCL:0; ARA:14566002|461199028|19110799006|15080799009|8062599006|7092599006|8060799009|102099032|40105399003|440099028|3412199025; x-microsoft-antispam-message-info: =?us-ascii?Q?RT4O9tK8c4KdN79facR7qmKua/DvtqEr+on8/ot9XPDyqOCOq/Tv0ycfgl49?= =?us-ascii?Q?pdOJ9ES0jAoMTTqPKOOPQHKJZ7jBIyGc01HifpOupX5uuWSci9y6Rr/PBDcW?= =?us-ascii?Q?eoSkWnWT6P09Gloiz6xp1whIb6V12x67N6zu18bN0hBQGSVIpTTnorRO8ymc?= =?us-ascii?Q?84KfceNIlIe3Es4PJqjeStJQWPQ2Rtk3Ra7Ky2Gdk8gvz3IPDinfyqe2s7ws?= =?us-ascii?Q?Su1hlV4a32xfxcHFHwKLm1aMkjSePsarKDE5bfQi8csG3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UK+sN58y1EPg8Pe3Sow=3D=3D?= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?zdJm6hR4tIq9VFJDI4mb8h7LcgAZBNwoe++CNFOx1MJGppS2XImgGUPt34mC?= =?us-ascii?Q?GNdL2KOyeeQ4VDK1WuSQwE5HHl87bmhDnYrpVqJuJD3GhnnDbyz7C3DJHart?= =?us-ascii?Q?ALMJ7+DU43ZDVr2EtJfg1sIkghLhS80QjESLIipYvTvRKccrGqhn4lgFQT7M?= =?us-ascii?Q?nZo0uPNpSoIgkrCxYowMv+xsEljSEwRhl/ekawR68TLbmPiNP5pAmuAMx1F5?= =?us-ascii?Q?FfwR7LkUJSn/GhKxs/sHDGJXdJTnN1mFVuQ99h1X7lVLIP3wl6JXYOrvr3/k?= =?us-ascii?Q?4lQMtoRkXa5j9ebEN66jG+y6Aw7XcX/I/mh4S88511iX8y9tXqaN29+oSpJa?= =?us-ascii?Q?s6yov1FGma3+TFV533HF6Gs8DHPhZBL7UnaBz6BgLfHpU58Fcq8U6EpgCEO3?= =?us-ascii?Q?PBcU10SAhGQ2jzj0mSxvPwuQyi4jnXvhYQQCUu6Y1/ujCfg5d2OaY7tIii25?= =?us-ascii?Q?9HKMtDQxIx2j5ol6E9C2sW3sWHKUzkusrpU0+x8KA+v/lqMIN9P9lYU302VR?= =?us-ascii?Q?wWQGyKpKWM1PpmaziBYWym7z4kfNtHZHqLnOAoPVti6YEyr/hhvCOvmZFF0U?= =?us-ascii?Q?/vfW2hvsGQjspmn/y5Pd+qrtT3hJjZ0WfSMMIAexoh76YyLDWWV+LG97dJ3E?= =?us-ascii?Q?rn3ipgn63ld73Luwi5EmGGjD9MAiys9hQ2orFMKy6vQjsbnx0fPJIEGuYndy?= =?us-ascii?Q?0+dZyxKhE26ysRsi++dYf9XS8iFHhj6nHUS2DaT7vqo+fHTEdnv5HESKJUvC?= =?us-ascii?Q?OLW72tgWo/3ag6zGk1S6RjoFXZ0t73regVrakqAVRN00JXTTrNOvSfzNRqir?= =?us-ascii?Q?KPCF6wJbV0klqmStCHiS8c2sCiQ4Tx9DFb0dFkWQm6zDHJeaEomonro0mue7?= =?us-ascii?Q?wEqjfVT3IeMM41DsAX+shhJ1I6KQWvqTzkwTvYQfIbOhQKfysw2Rbhve4AQq?= =?us-ascii?Q?417KneEqgoce+5BF2D79Yx7z+yNPMvZKj6kxFPTOdDIikkzQ/5n7pn+49gBi?= =?us-ascii?Q?va12dkGaCzxv7/Adyugv0iw9H9WnsbVt8VvQhBxdbPKK8iAZpf4v67jU5sQM?= =?us-ascii?Q?7T1PV3KKvEZe4op36R2TzI3B2VIp9gJJHflzrnB/0yCMnWstlMwfQjTT5krx?= =?us-ascii?Q?npA1Z88lcAzIox+2Np9tgF13I4UeHzJHZAx9y4U7rKTn1jkFPvtjyCQCAP7H?= =?us-ascii?Q?xgNQDRGBCRGGCU2lg6vIszpgt1U7nNMBU3o6NESawi4JmaCuv3Pzu4LgcZ4?= =?us-ascii?Q?=3D?= MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-8534-20-msonline-outlook-c7cf3.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: ef20d832-582f-4419-e5ad-08ddb1fa11ad X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jun 2025 02:02:55.2906 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3P223MB0193 Subject: Re: [FFmpeg-devel] [PATCH 05/10] doc/muxers: Add documentation for segment_limit option 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: > -----Original Message----- > From: ffmpeg-devel On Behalf Of Marton > Balint > Sent: Samstag, 14. Juni 2025 18:00 > To: FFmpeg development discussions and patches > Subject: Re: [FFmpeg-devel] [PATCH 05/10] doc/muxers: Add documentation > for segment_limit option > > > > On Fri, 13 Jun 2025, softworkz . wrote: > > [...] > > >>> (Please note, that the default is 0, which means that nothing is > >>> dropped and there's no change in behavior when it's 0). > >>> > >>> Probably it's best to look at an example. Let's say we have: > >>> > >>> - a 300s video > >>> - that we want to stream via HLS > >>> - Segment-Duration: 3s - makes 100 segments > >>> - Now we want to create the segments on-demand only, > >>> so we deliver a synthetic playlist with 100 3s segments, > >>> even though we don't have any segment yet > >>> - Once specific segments are needed, we create them on-the-fly > >>> > >>> That's a situation that the commit message is about: > >>> > >>> Existing segments 0-30 and 70-99 => we already have them on disk > >>> > >>> 31-69 need to be created > >>> > >>> This option allows to stop precisely after 69. > >>> Otherwise, it would start overwriting segment 70 before stopping > >>> via 'q' or break signal. > >>> > >>> So, in order to generate segments 31-69, you will set > >>> segment_start_number to 31 and the segment_limit to 38. > >>> This causes the muxer to write and complete segment 69 > >>> in the exact same way like when it would be creating segment > >>> 70, but without starting to write segment 70 - which would > >> destroy > >>> the existing segment 70 (which is good already). > >> > >> Buy you have to seek in the input to achieve that, don't you? And > >> you can > >> just as easily specify the input duration to not overwrite segment > >> 70... > > > > Here we're getting at the core of the problem: When specifying -to or > > a duration, you cannot achieve the exact same "cut" like the segment > > muxer does it. It usually cuts by video key frames. And when it does > > the cut it also cuts all other streams at that moment. Timestamp > > offsets between video and audio are common, often the audio is > > somewhat ahead of the video (specifically in case of TV broadcast > > streams), but it varies. Also, when transcoding before segmenting, > > it's not easy to predict the exact video key frame times. > > > > For each segment n to segment n+1 the cut must be done in a way > > that for each stream, there is neither a duplicate nor a missing > > frame. That is what makes it non-trivial. > > > > In the end, it always comes down to the same conclusion: the only > > way to get the exact same cut point through all streams like the > > segment muxer does it - is to let the segment muxer do it. > > > > At least that was my conclusion from intensive work on this, some > > years ago. > > But this is also a problem for the first segment. You can set > segment_start_number to 31, but you still have to know where to seek > exactly, because setting segment_start_number alone won't make the > segment > muxer "ignore" data for the first 30 segments... > > So what does not make sense to me is that you want to rely on segment > muxer behaviour for ending the segments, but not for starting them. The > way I see it you either know exactly where the segments supposed to > start > and end, in which case you don't really need this option, because you > can set -ss and -to as you need. Or you don't, in which case this option > alone won't help you. Hi Marton, you are right to ask about the side of starting at a specific segment. This is something I wanted to bring up just after the patch for the ending segment, because that's a topic which is way more difficult. The core requirement is to achieve the exact same segmentation each time when running FFmpeg to create a defined subset of HLS segments. When transcoding is involved (before segmentation), it can even depend on the decoder WRT the positions at which it is emitting key frames, and then also the segment muxer with its various parameters to control the segment cut positions. Several parameters need to be set up precisely in a way that the transcoding operation will pick up the same "rhythm" of operation like it would have when starting from zero. The recipe is like this: - Probe the preceding segment of where you want to start e.g. when you want to generate segments n,..., n+10, you probe existing segment n-1. But you can only do so when it already exists (otherwise you can just estimate) - Get the PTS time of the first video frame (assuming it's a "key-frame" or similar) - Compensate for input/output time offsets (or make sure there are none) - Subtract 1 from this time - Depending on the operation: - If video encoding involved: use this as -ss value - Otherwise, subtract a second (or half) and use this as -ss value - Set the segment muxer start segment to n-1 - Then I have two more options for the segment muxer: min_frame_time and skip_first_segment - min_frame_time gets the pts-minus-1 value this causes the muxer to remain inactive until it sees a video frame with a time greater than that - then it starts operation - skip_first_segment tells it not to write the first segment Summary: You can never get the first segment immediately "right", where "right" means identical to how it would be written as part (in the middle) of a sequence. So we start one segment earlier, still try to be precise about its start to ensure that encoder and segment muxer get into the proper "segmentation rhythm", and discard the first segment which is most likely "wrong" (=different) WRT its cut at the start. Obviously, this is not a very nice solution. It only works when all the supplied parameters are precisely set in the right way. That made me hesitant to even submit a patch to add those options. Maybe there's a better way, that I've just been failing to see..? Best regards, sw PS: I want to retain audio-video offsets like in case of tV broadcast signals _______________________________________________ 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".