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 ESMTPS id 36F43407DE for ; Mon, 27 Jan 2025 08:27:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4ACCB68BB5C; Mon, 27 Jan 2025 10:27:05 +0200 (EET) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6C3B968BA74 for ; Mon, 27 Jan 2025 10:26:58 +0200 (EET) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-437a92d7b96so42529345e9.2 for ; Mon, 27 Jan 2025 00:26:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datarhei.com; s=google; t=1737966417; x=1738571217; darn=ffmpeg.org; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=jGIXqREzVUfk+Np3WLTHncMxMMI3vdvgFYsEjdhCKdo=; b=IkjO1CWdK6UdSml0DRPhqt4ce3nuPTDfjGNowLe/ycgZ/W+c8fFvIjtKh5O6G57wVD GmDx/puV9lnZRLe5hbxa4KLe4YFjSbTG8/daBEjFR9gpyZs/QkqhbHtCUoL42FArg652 rv+MPaz6kRSdBljXHxR9aFbix4SUlG9Pe4qINa6Jx3mIQl4hAKYDW5YAbLNQ26ExpbhG bAuZlR0+PCCd2eGlHq+dZ0rPXvNj8ULljgFOVZMb5gX63zFjJMdfyhcpl7Xj1knhPGz4 dzpXYLbTNm/e3WUiryFgBn2V7xUKtMFO4yNGmpRcvDr3TvEwj1GJAMaoomZ7y2rO+Njd TTkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737966417; x=1738571217; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jGIXqREzVUfk+Np3WLTHncMxMMI3vdvgFYsEjdhCKdo=; b=MnKyA6r1cuPKrWf40DX2xpT2Gl0/vTj/Ld4swb/BRtjCQ2WxJioEkDx/1QD9Ydxp0Z GFg6ui/DFHiqVFgv7c+ycIvJd9gApmZvsx+Kr8mQSQY2/yGXpEXVmlbfwXTbtnFDrUQj INCWK3uHCgNbGbDRKkqD+tegpjvIrCImtUWvd6LZRJoY2aWoN9UaMjhLYCzBZpeSpPga 8gbkOkOaSCQ3k+58Cet35iDoP9eBZM7697cxeVYEvaEJxaBgPXv70Fe9890OPbGa3HkY OPLKogUL79q+K6YBIdosVLebNApkOroO1QugJ9oCgtzOfIQjfUq23rLwxdTzGShFc0De /UaA== X-Gm-Message-State: AOJu0YzhlRY3cuQ/xOvblSnjHOS2UgNf7NKKkwSAW1S37GQ9vGGzp5ZF mI9MTqr3waphpxm//EYoQyM9v3gkbMiu7mwlQtOQcM6pJqyrJ+LKyAL1WzBIIiblj6S+KmXh8NI = X-Gm-Gg: ASbGncvO3Tog/GPvcaaU4onx6wzaoEPRwiHEdRtgvK4vdlRMa4uFrK8x/oPrycXimQZ 79eVcVmvDwx3h202qY3H/o+qNIcOSXXELzLshh0YMVedr5iKKoaxZuwZOuoR4k3aVDhPQh9LLyg p6mhw/xtNnpDbnB3HO0GoQODXmV6b/AZt6A9eqhAMvvZ9MH9EOytisAZ827KRulXb0uN6ruUqUk B1OLE/YAHB7u3TwY4k9EtP46s2mVBE6X4xsYXpJ4M+V9IHtdFjgM/52JvELjGuFJykDaJDxqqmt rblecvKz7PaAEPKfxpPPIxFd X-Google-Smtp-Source: AGHT+IEVy9lDVqc3L6rU80r/evmW1vJOedI47ozL1IpB1xrckc0Z3wZZTmmwMjnARlNQq2cCSQwKmQ== X-Received: by 2002:a05:600c:3b88:b0:436:488f:4d8 with SMTP id 5b1f17b1804b1-438913cdba3mr438217115e9.11.1737966416789; Mon, 27 Jan 2025 00:26:56 -0800 (PST) Received: from smtpclient.apple ([2a04:ee41:4:b3b0:49c0:cd01:9cb2:8ed6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c2a1bad92sm10358563f8f.61.2025.01.27.00.26.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jan 2025 00:26:56 -0800 (PST) From: Ingo Oppermann Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3818.100.11.1.3\)) Date: Mon, 27 Jan 2025 09:26:45 +0100 References: <20250124115910.3550-1-ingo@datarhei.com> To: FFmpeg development discussions and patches In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3818.100.11.1.3) Subject: Re: [FFmpeg-devel] [PATCH v1] avformat/hlsenc: fix hls_time not respected 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 24 Jan 2025, at 16:30, Gyan Doshi wrote: > > > > On 2025-01-24 05:29 pm, Ingo Oppermann wrote: >> This fixes the criterion when to split the segments based on the elapsed time >> for the current segment instead of using the theoretical elapsed time since >> start based on hls_time and the number of written segments. >> >> hls_time is used to define the minimum length of a segment, however this is >> not respected in all cases when a stream has variable GOP sizes. >> >> Imagine a stream starts with a key frame every 10 seconds for e.g. 40 seconds. >> After that, key frames will come every second. This will result in segments >> that are first 10 seconds, then 1 second for some time and later 2 seconds as >> expected. > > Better to make it flexible like how the segment muxer does it, by having an optional minimum segment duration parameter. Then it's upto the user. > See d39b34123d. According to the documentation "hls_time" is already supposed to be the minimum duration of a segment: "Segment will be cut on the next key frame after this time has passed." (https://ffmpeg.org/ffmpeg-formats.html#Options-26). It does this under normal circumstances, e.g. ffmpeg -t 30 -f lavfi -i testsrc2 -codec:v libx264 -g 25 -f hls -hls_time 2 -hls_list_size 0 split.m3u8 Every segment is 2 seconds even though the GOP size 1 second. > > Also Patchwork warns about the line length in the commit message. Should be <=72 Will fix this in the following version of the patch. > > Regards, > Gyan > > >> >> How to reproduce: >> ffmpeg -t 40 -f lavfi -i testsrc2=s=1280x720:r=25 -codec:v libx264 -g 250 part1.mp4 >> ffmpeg -t 40 -f lavfi -i testsrc2=s=1280x720:r=25 -codec:v libx264 -g 25 part2.mp4 >> echo "file part1.mp4\nfile part2.mp4" > list.txt >> ffmpeg -f concat -i list.txt -codec copy part.mp4 >> ffmpeg -i part.mp4 -codec copy -f hls -hls_time 2 -hls_list_size 0 -hls_segment_filename 'part_%d.ts' part.m3u8 >> cat part.m3u8 >> >> Signed-off-by: Ingo Oppermann >> --- >> libavformat/hlsenc.c | 12 +++--------- >> 1 file changed, 3 insertions(+), 9 deletions(-) >> >> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c >> index 6148685f40..2c5d60500d 100644 >> --- a/libavformat/hlsenc.c >> +++ b/libavformat/hlsenc.c >> @@ -2474,7 +2474,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) >> HLSContext *hls = s->priv_data; >> AVFormatContext *oc = NULL; >> AVStream *st = s->streams[pkt->stream_index]; >> - int64_t end_pts = 0; >> int is_ref_pkt = 1; >> int ret = 0, can_split = 1, i, j; >> int stream_index = 0; >> @@ -2512,14 +2511,9 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) >> return AVERROR(ENOMEM); >> } >> - end_pts = hls->recording_time * vs->number; >> - >> if (vs->sequence - vs->nb_entries > hls->start_sequence && hls->init_time > 0) { >> - /* reset end_pts, hls->recording_time at end of the init hls list */ >> - int64_t init_list_dur = hls->init_time * vs->nb_entries; >> - int64_t after_init_list_dur = (vs->sequence - hls->start_sequence - vs->nb_entries) * hls->time; >> + /* reset hls->recording_time at end of the init hls list */ >> hls->recording_time = hls->time; >> - end_pts = init_list_dur + after_init_list_dur ; >> } >> if (vs->start_pts == AV_NOPTS_VALUE) { >> @@ -2560,8 +2554,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) >> } >> can_split = can_split && (pkt->pts - vs->end_pts > 0); >> - if (vs->packets_written && can_split && av_compare_ts(pkt->pts - vs->start_pts, st->time_base, >> - end_pts, AV_TIME_BASE_Q) >= 0) { >> + if (vs->packets_written && can_split && av_compare_ts(pkt->pts - vs->end_pts, st->time_base, >> + hls->recording_time, AV_TIME_BASE_Q) >= 0) { >> int64_t new_start_pos; >> int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size > 0); >> double cur_duration; >> >> base-commit: e20ee9f9aec94f8cea1bf4fd8ed3fb096fb205e5 > > _______________________________________________ > 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".