Commit 941e7961cc for ffmpeg
commit 941e7961cc87092708698c65dd3fd564f877c3bd
Author: Romain Beauxis <romain.beauxis@gmail.com>
Date: Sat Nov 7 16:52:52 2026 -0600
avformat: add a seek_flags option
seek2any adds one flag to every seek, so each other flag would need an
option of its own.
Add seek_flags, a set of AVSEEK_FLAG_* added to every
avformat_seek_file(), with an any value, and deprecate seek2any.
diff --git a/doc/APIchanges b/doc/APIchanges
index c729b61a44..a007a9e9a5 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,11 @@ The last version increases of all libraries were on 2026-06-23.
API changes, most recent first:
+2026-11-xx - xxxxxxxxxx - lavf 63.19.100 - avformat.h
+ Add AVFormatContext.seek_flags.
+ Deprecate AVFormatContext.seek2any in favor of AVSEEK_FLAG_ANY in
+ AVFormatContext.seek_flags.
+
2026-11-xx - xxxxxxxxxx - lavc 63.28.100 - packet.h
Add AV_PKT_FLAG_EOS.
diff --git a/doc/formats.texi b/doc/formats.texi
index 0722e3f512..584eaf8d55 100644
--- a/doc/formats.texi
+++ b/doc/formats.texi
@@ -76,9 +76,18 @@ It may be needed to increase max_interleave_delta to avoid flushing the longer
streams before EOF.
@end table
+@item seek_flags @var{flags} (@emph{input})
+Set flags added to every seek. Default is none.
+
+Possible values:
+@table @samp
+@item any
+Allow seeking to non-keyframes on demuxer level when supported.
+@end table
+
@item seek2any @var{integer} (@emph{input})
Allow seeking to non-keyframes on demuxer level when supported if set to 1.
-Default is 0.
+Default is 0. This option is deprecated, use @code{seek_flags any} instead.
@item analyzeduration @var{integer} (@emph{input})
Specify how many microseconds are analyzed to probe the input. A
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 679d15676c..68900b9734 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1865,12 +1865,17 @@ typedef struct AVFormatContext {
*/
unsigned int correct_ts_overflow;
+#if FF_API_SEEK2ANY
/**
* Force seeking to any (also non key) frames.
* - encoding: unused
* - decoding: Set by user
+ *
+ * @deprecated use AVSEEK_FLAG_ANY in seek_flags
*/
+ attribute_deprecated
int seek2any;
+#endif
/**
* Flush the I/O context after each packet.
@@ -2056,6 +2061,13 @@ typedef struct AVFormatContext {
* - demuxing: Set by user
*/
int recursion_limit;
+
+ /**
+ * Flags added to the flags of every avformat_seek_file(): AVSEEK_FLAG_ANY.
+ * - encoding: unused
+ * - decoding: Set by user
+ */
+ int seek_flags;
} AVFormatContext;
/**
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index 537870c5c9..eccc85bc63 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -55,7 +55,11 @@ static const AVOption avformat_options[] = {
#if FF_API_OLD_ID3V2_COMMENT
{"legacy_id3v2_comm_keys", "also export id3v2 COMM descriptors as bare metadata keys", 0, AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_LEGACY_ID3V2_COMM_KEYS }, 0, 0, D|AV_OPT_FLAG_DEPRECATED, .unit = "fflags" },
#endif
-{"seek2any", "allow seeking to non-keyframes on demuxer level when supported", OFFSET(seek2any), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, D},
+#if FF_API_SEEK2ANY
+{"seek2any", "allow seeking to non-keyframes on demuxer level when supported", OFFSET(seek2any), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, D|AV_OPT_FLAG_DEPRECATED},
+#endif
+{"seek_flags", "flags added to every seek", OFFSET(seek_flags), AV_OPT_TYPE_FLAGS, {.i64 = 0 }, 0, INT_MAX, D, .unit = "seek_flags"},
+{"any", "allow seeking to non-keyframes on demuxer level when supported", 0, AV_OPT_TYPE_CONST, {.i64 = AVSEEK_FLAG_ANY }, INT_MIN, INT_MAX, D, .unit = "seek_flags"},
{"analyzeduration", "specify how many microseconds are analyzed to probe the input", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, (double)INT64_MAX, D},
{"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D},
{"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), AV_OPT_TYPE_INT, {.i64 = 1<<20 }, 0, INT_MAX, D},
diff --git a/libavformat/seek.c b/libavformat/seek.c
index 4a09d01335..dd3a237983 100644
--- a/libavformat/seek.c
+++ b/libavformat/seek.c
@@ -765,8 +765,13 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
if (stream_index < -1 || stream_index >= (int)s->nb_streams)
return AVERROR(EINVAL);
+#if FF_API_SEEK2ANY
+FF_DISABLE_DEPRECATION_WARNINGS
if (s->seek2any > 0)
flags |= AVSEEK_FLAG_ANY;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ flags |= s->seek_flags & AVSEEK_FLAG_ANY;
flags &= ~AVSEEK_FLAG_BACKWARD;
if (!(flags & (AVSEEK_FLAG_BYTE | AVSEEK_FLAG_FRAME))) {
diff --git a/libavformat/version.h b/libavformat/version.h
index 6a80f3ac4e..e063e12b98 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
#include "version_major.h"
-#define LIBAVFORMAT_VERSION_MINOR 18
+#define LIBAVFORMAT_VERSION_MINOR 19
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
diff --git a/libavformat/version_major.h b/libavformat/version_major.h
index 9a7955d9e4..72e7766353 100644
--- a/libavformat/version_major.h
+++ b/libavformat/version_major.h
@@ -51,6 +51,8 @@
#define FF_API_STREAM_GROUP_ENTRIES (LIBAVFORMAT_VERSION_MAJOR < 64)
+#define FF_API_SEEK2ANY (LIBAVFORMAT_VERSION_MAJOR < 64)
+
#define FF_API_R_FRAME_RATE 1
#endif /* AVFORMAT_VERSION_MAJOR_H */