* [FFmpeg-devel] [PATCH 1/2 RESEND] avformat/rtsp: set AVFMTCTX_UNSEEKABLE flag
@ 2025-05-28 12:08 Kaarle Ritvanen via ffmpeg-devel
2025-05-28 12:08 ` [FFmpeg-devel] [PATCH 2/2 RESEND] avformat/seek: fail seeking immediately Kaarle Ritvanen via ffmpeg-devel
0 siblings, 1 reply; 4+ messages in thread
From: Kaarle Ritvanen via ffmpeg-devel @ 2025-05-28 12:08 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Kaarle Ritvanen
for live RTP streams. Some external applications, such as Qt Multimedia,
depend on this flag being set correctly.
Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
---
libavformat/rtsp.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 5ea471b40c..e7c00c69fa 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -629,8 +629,8 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
rtsp_parse_range_npt(p, &start, &end);
s->start_time = start;
/* AV_NOPTS_VALUE means live broadcast (and can't seek) */
- s->duration = (end == AV_NOPTS_VALUE) ?
- AV_NOPTS_VALUE : end - start;
+ if (end != AV_NOPTS_VALUE)
+ s->duration = end - start;
} else if (av_strstart(p, "lang:", &p)) {
if (s->nb_streams > 0) {
get_word(buf1, sizeof(buf1), &p);
@@ -720,6 +720,8 @@ int ff_sdp_parse(AVFormatContext *s, const char *content)
char buf[SDP_MAX_SIZE], *q;
SDPParseState sdp_parse_state = { { 0 } }, *s1 = &sdp_parse_state;
+ s->duration = AV_NOPTS_VALUE;
+
p = content;
for (;;) {
p += strspn(p, SPACE_CHARS);
@@ -753,6 +755,9 @@ int ff_sdp_parse(AVFormatContext *s, const char *content)
av_freep(&s1->default_exclude_source_addrs[i]);
av_freep(&s1->default_exclude_source_addrs);
+ if (s->duration == AV_NOPTS_VALUE)
+ s->ctx_flags |= AVFMTCTX_UNSEEKABLE;
+
return 0;
}
#endif /* CONFIG_RTPDEC */
--
2.49.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 4+ messages in thread
* [FFmpeg-devel] [PATCH 2/2 RESEND] avformat/seek: fail seeking immediately
2025-05-28 12:08 [FFmpeg-devel] [PATCH 1/2 RESEND] avformat/rtsp: set AVFMTCTX_UNSEEKABLE flag Kaarle Ritvanen via ffmpeg-devel
@ 2025-05-28 12:08 ` Kaarle Ritvanen via ffmpeg-devel
2025-05-28 12:19 ` Zhao Zhili
0 siblings, 1 reply; 4+ messages in thread
From: Kaarle Ritvanen via ffmpeg-devel @ 2025-05-28 12:08 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Kaarle Ritvanen
when AVFMTCTX_UNSEEKABLE is set. Depending on the codec, the execution
of this function may take several seconds. This is an optimization for
the case where the stream is already known unseekable.
Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
---
libavformat/seek.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libavformat/seek.c b/libavformat/seek.c
index c0d94371e6..1a7d3d6741 100644
--- a/libavformat/seek.c
+++ b/libavformat/seek.c
@@ -643,6 +643,9 @@ int av_seek_frame(AVFormatContext *s, int stream_index,
{
int ret;
+ if (s->ctx_flags & AVFMTCTX_UNSEEKABLE)
+ return AVERROR(ENOSYS);
+
if (ffifmt(s->iformat)->read_seek2 && !ffifmt(s->iformat)->read_seek) {
int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
if ((flags & AVSEEK_FLAG_BACKWARD))
--
2.49.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2 RESEND] avformat/seek: fail seeking immediately
2025-05-28 12:08 ` [FFmpeg-devel] [PATCH 2/2 RESEND] avformat/seek: fail seeking immediately Kaarle Ritvanen via ffmpeg-devel
@ 2025-05-28 12:19 ` Zhao Zhili
2025-05-28 13:26 ` Kaarle Ritvanen via ffmpeg-devel
0 siblings, 1 reply; 4+ messages in thread
From: Zhao Zhili @ 2025-05-28 12:19 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> On May 28, 2025, at 20:08, Kaarle Ritvanen via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote:
>
> when AVFMTCTX_UNSEEKABLE is set. Depending on the codec, the execution
> of this function may take several seconds. This is an optimization for
Why this depending on the codec? Could you provide a case that takes several seconds?
> the case where the stream is already known unseekable.
>
> Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
> ---
> libavformat/seek.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/libavformat/seek.c b/libavformat/seek.c
> index c0d94371e6..1a7d3d6741 100644
> --- a/libavformat/seek.c
> +++ b/libavformat/seek.c
> @@ -643,6 +643,9 @@ int av_seek_frame(AVFormatContext *s, int stream_index,
> {
> int ret;
>
> + if (s->ctx_flags & AVFMTCTX_UNSEEKABLE)
> + return AVERROR(ENOSYS);
> +
> if (ffifmt(s->iformat)->read_seek2 && !ffifmt(s->iformat)->read_seek) {
> int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
> if ((flags & AVSEEK_FLAG_BACKWARD))
> --
> 2.49.0
>
> _______________________________________________
> 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".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2 RESEND] avformat/seek: fail seeking immediately
2025-05-28 12:19 ` Zhao Zhili
@ 2025-05-28 13:26 ` Kaarle Ritvanen via ffmpeg-devel
0 siblings, 0 replies; 4+ messages in thread
From: Kaarle Ritvanen via ffmpeg-devel @ 2025-05-28 13:26 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Kaarle Ritvanen
On Wed, 28 May 2025, Zhao Zhili wrote:
> Why this depending on the codec? Could you provide a case that takes
> several seconds?
I encountered the problem with an RTP live stream using H.264 in
intra-refresh mode. I think the delay is related to seek_frame_generic
trying to find keyframes in the stream.
--
Kaarle Ritvanen
Data King Ltd
_______________________________________________
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".
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-28 13:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-28 12:08 [FFmpeg-devel] [PATCH 1/2 RESEND] avformat/rtsp: set AVFMTCTX_UNSEEKABLE flag Kaarle Ritvanen via ffmpeg-devel
2025-05-28 12:08 ` [FFmpeg-devel] [PATCH 2/2 RESEND] avformat/seek: fail seeking immediately Kaarle Ritvanen via ffmpeg-devel
2025-05-28 12:19 ` Zhao Zhili
2025-05-28 13:26 ` Kaarle Ritvanen via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git