[FFmpeg-devel] [PATCH v2 1/3] avformat/avformat: Deprecate AVFMT_ALLOW_FLUSH

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Tue Sep 26 02:54:30 EEST 2023


It is of no value to the user, because every muxer can always
be flushed with a NULL packet. As its documentation shows
("If not set, the muxer will not receive a NULL packet in
the write_packet function") it is actually an internal flag
that has been publically exposed because there was no internal
flags field for output formats for a long time. But now there is
and so use it by replacing the public flag with a private one.

Reviewed-by: James Almer <jamrial at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 doc/APIchanges                |  4 ++++
 libavdevice/pulse_audio_enc.c |  5 ++++
 libavformat/avformat.h        |  6 +++--
 libavformat/fifo.c            |  5 ++++
 libavformat/fifo_test.c       |  5 ++++
 libavformat/hlsenc.c          |  5 ++++
 libavformat/matroskaenc.c     | 15 ++++++++++++
 libavformat/movenc.c          | 45 +++++++++++++++++++++++++++++++++++
 libavformat/mpegtsenc.c       |  5 ++++
 libavformat/mux.c             |  6 +++++
 libavformat/mux.h             |  6 +++--
 libavformat/oggenc.c          | 25 +++++++++++++++++++
 libavformat/tee.c             |  5 ++++
 libavformat/version_major.h   |  1 +
 14 files changed, 134 insertions(+), 4 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index f333ff5b24..ca7ffbb97e 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,10 @@ The last version increases of all libraries were on 2023-02-09
 
 API changes, most recent first:
 
+2023-09-26 - xxxxxxxxxx - lavf 60.xx.100 - avformat.h
+  Deprecate AVFMT_ALLOW_FLUSH without replacement. Users can always
+  flush any muxer by sending a NULL packet.
+
 2023-09-19 - xxxxxxxxxx - lavu 58.25.100 - avutil.h
   Make AV_TIME_BASE_Q compatible with C++.
 
diff --git a/libavdevice/pulse_audio_enc.c b/libavdevice/pulse_audio_enc.c
index 9e594c6424..5acbf798ef 100644
--- a/libavdevice/pulse_audio_enc.c
+++ b/libavdevice/pulse_audio_enc.c
@@ -802,6 +802,11 @@ const FFOutputFormat ff_pulse_muxer = {
     .get_output_timestamp = pulse_get_output_timestamp,
     .get_device_list      = pulse_get_device_list,
     .control_message      = pulse_control_message,
+#if FF_API_ALLOW_FLUSH
     .p.flags              = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH,
+#else
+    .p.flags              = AVFMT_NOFILE,
+#endif
     .p.priv_class         = &pulse_muxer_class,
+    .flags_internal       = FF_FMT_ALLOW_FLUSH,
 };
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 43175ba332..a8e245000f 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -486,7 +486,9 @@ typedef struct AVProbeData {
 #define AVFMT_NOBINSEARCH   0x2000 /**< Format does not allow to fall back on binary search via read_timestamp */
 #define AVFMT_NOGENSEARCH   0x4000 /**< Format does not allow to fall back on generic search */
 #define AVFMT_NO_BYTE_SEEK  0x8000 /**< Format does not allow seeking by bytes */
-#define AVFMT_ALLOW_FLUSH  0x10000 /**< Format allows flushing. If not set, the muxer will not receive a NULL packet in the write_packet function. */
+#if FF_API_ALLOW_FLUSH
+#define AVFMT_ALLOW_FLUSH  0x10000 /**< @deprecated: Just send a NULL packet if you want to flush a muxer. */
+#endif
 #define AVFMT_TS_NONSTRICT 0x20000 /**< Format does not require strictly
                                         increasing timestamps, but they must
                                         still be monotonic */
@@ -522,7 +524,7 @@ typedef struct AVOutputFormat {
     /**
      * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER,
      * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS,
-     * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH,
+     * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS,
      * AVFMT_TS_NONSTRICT, AVFMT_TS_NEGATIVE
      */
     int flags;
diff --git a/libavformat/fifo.c b/libavformat/fifo.c
index 9a3a23729c..8fb4975a5c 100644
--- a/libavformat/fifo.c
+++ b/libavformat/fifo.c
@@ -715,11 +715,16 @@ const FFOutputFormat ff_fifo_muxer = {
     .p.name         = "fifo",
     .p.long_name    = NULL_IF_CONFIG_SMALL("FIFO queue pseudo-muxer"),
     .p.priv_class   = &fifo_muxer_class,
+#if FF_API_ALLOW_FLUSH
     .p.flags        = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
+#else
+    .p.flags        = AVFMT_NOFILE | AVFMT_TS_NEGATIVE,
+#endif
     .priv_data_size = sizeof(FifoContext),
     .init           = fifo_init,
     .write_header   = fifo_write_header,
     .write_packet   = fifo_write_packet,
     .write_trailer  = fifo_write_trailer,
     .deinit         = fifo_deinit,
+    .flags_internal = FF_FMT_ALLOW_FLUSH,
 };
diff --git a/libavformat/fifo_test.c b/libavformat/fifo_test.c
index 0f12d88b0f..3861c4aee4 100644
--- a/libavformat/fifo_test.c
+++ b/libavformat/fifo_test.c
@@ -147,6 +147,11 @@ const FFOutputFormat ff_fifo_test_muxer = {
     .write_trailer  = failing_write_trailer,
     .deinit         = failing_deinit,
     .p.priv_class   = &failing_muxer_class,
+#if FF_API_ALLOW_FLUSH
     .p.flags        = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH,
+#else
+    .p.flags        = AVFMT_NOFILE,
+#endif
+    .flags_internal = FF_FMT_ALLOW_FLUSH,
 };
 
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 08f3746ce7..999fc0de75 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -3184,8 +3184,13 @@ const FFOutputFormat ff_hls_muxer = {
     .p.audio_codec    = AV_CODEC_ID_AAC,
     .p.video_codec    = AV_CODEC_ID_H264,
     .p.subtitle_codec = AV_CODEC_ID_WEBVTT,
+#if FF_API_ALLOW_FLUSH
     .p.flags          = AVFMT_NOFILE | AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_NODIMENSIONS,
+#else
+    .p.flags          = AVFMT_NOFILE | AVFMT_GLOBALHEADER | AVFMT_NODIMENSIONS,
+#endif
     .p.priv_class     = &hls_class,
+    .flags_internal   = FF_FMT_ALLOW_FLUSH,
     .priv_data_size = sizeof(HLSContext),
     .init           = hls_init,
     .write_header   = hls_write_header,
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index ba54f5f98e..c1a4425eb7 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -3512,7 +3512,11 @@ const FFOutputFormat ff_matroska_muxer = {
     .write_packet      = mkv_write_flush_packet,
     .write_trailer     = mkv_write_trailer,
     .p.flags           = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS |
+#if FF_API_ALLOW_FLUSH
                          AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH,
+#else
+                         AVFMT_TS_NONSTRICT,
+#endif
     .p.codec_tag       = (const AVCodecTag* const []){
          ff_codec_bmp_tags, ff_codec_wav_tags,
          additional_audio_tags, additional_subtitle_tags, 0
@@ -3521,6 +3525,7 @@ const FFOutputFormat ff_matroska_muxer = {
     .query_codec       = mkv_query_codec,
     .check_bitstream   = mkv_check_bitstream,
     .p.priv_class      = &matroska_webm_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
 
@@ -3551,8 +3556,13 @@ const FFOutputFormat ff_webm_muxer = {
     .query_codec       = webm_query_codec,
     .check_bitstream   = mkv_check_bitstream,
     .p.flags           = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS |
+#if FF_API_ALLOW_FLUSH
                          AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH,
+#else
+                         AVFMT_TS_NONSTRICT,
+#endif
     .p.priv_class      = &matroska_webm_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
 
@@ -3572,11 +3582,16 @@ const FFOutputFormat ff_matroska_audio_muxer = {
     .write_packet      = mkv_write_flush_packet,
     .write_trailer     = mkv_write_trailer,
     .check_bitstream   = mkv_check_bitstream,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_GLOBALHEADER | AVFMT_TS_NONSTRICT |
                          AVFMT_ALLOW_FLUSH,
+#else
+    .p.flags           = AVFMT_GLOBALHEADER | AVFMT_TS_NONSTRICT,
+#endif
     .p.codec_tag       = (const AVCodecTag* const []){
         ff_codec_wav_tags, additional_audio_tags, 0
     },
     .p.priv_class      = &matroska_webm_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 7e96e7435f..a394ff8ddf 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -7932,12 +7932,17 @@ const FFOutputFormat ff_mov_muxer = {
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
+#else
+    .p.flags           = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE,
+#endif
     .p.codec_tag       = (const AVCodecTag* const []){
         ff_codec_movvideo_tags, ff_codec_movaudio_tags, ff_codec_movsubtitle_tags, 0
     },
     .check_bitstream   = mov_check_bitstream,
     .p.priv_class      = &mov_isobmff_muxer_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
 #if CONFIG_TGP_MUXER
@@ -7953,10 +7958,15 @@ const FFOutputFormat ff_tgp_muxer = {
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
+#else
+    .p.flags           = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE,
+#endif
     .p.codec_tag       = codec_3gp_tags_list,
     .check_bitstream   = mov_check_bitstream,
     .p.priv_class      = &mov_isobmff_muxer_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
 #if CONFIG_MP4_MUXER
@@ -7974,10 +7984,15 @@ const FFOutputFormat ff_mp4_muxer = {
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
+#else
+    .p.flags           = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE,
+#endif
     .p.codec_tag       = mp4_codec_tags_list,
     .check_bitstream   = mov_check_bitstream,
     .p.priv_class      = &mov_isobmff_muxer_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
 #if CONFIG_PSP_MUXER
@@ -7994,10 +8009,15 @@ const FFOutputFormat ff_psp_muxer = {
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
+#else
+    .p.flags           = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE,
+#endif
     .p.codec_tag       = mp4_codec_tags_list,
     .check_bitstream   = mov_check_bitstream,
     .p.priv_class      = &mov_isobmff_muxer_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
 #if CONFIG_TG2_MUXER
@@ -8013,10 +8033,15 @@ const FFOutputFormat ff_tg2_muxer = {
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
+#else
+    .p.flags           = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE,
+#endif
     .p.codec_tag       = codec_3gp_tags_list,
     .check_bitstream   = mov_check_bitstream,
     .p.priv_class      = &mov_isobmff_muxer_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
 #if CONFIG_IPOD_MUXER
@@ -8033,10 +8058,15 @@ const FFOutputFormat ff_ipod_muxer = {
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
+#else
+    .p.flags           = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE,
+#endif
     .p.codec_tag       = (const AVCodecTag* const []){ codec_ipod_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
     .p.priv_class      = &mov_isobmff_muxer_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
 #if CONFIG_ISMV_MUXER
@@ -8053,11 +8083,16 @@ const FFOutputFormat ff_ismv_muxer = {
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
+#else
+    .p.flags           = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE,
+#endif
     .p.codec_tag       = (const AVCodecTag* const []){
         codec_mp4_tags, codec_ism_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
     .p.priv_class      = &mov_isobmff_muxer_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
 #if CONFIG_F4V_MUXER
@@ -8074,10 +8109,15 @@ const FFOutputFormat ff_f4v_muxer = {
     .write_packet      = mov_write_packet,
     .write_trailer     = mov_write_trailer,
     .deinit            = mov_free,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH,
+#else
+    .p.flags           = AVFMT_GLOBALHEADER,
+#endif
     .p.codec_tag       = (const AVCodecTag* const []){ codec_f4v_tags, 0 },
     .check_bitstream   = mov_check_bitstream,
     .p.priv_class      = &mov_isobmff_muxer_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
 #if CONFIG_AVIF_MUXER
@@ -8093,8 +8133,13 @@ const FFOutputFormat ff_avif_muxer = {
     .write_packet      = mov_write_packet,
     .write_trailer     = avif_write_trailer,
     .deinit            = mov_free,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH,
+#else
+    .p.flags           = AVFMT_GLOBALHEADER,
+#endif
     .p.codec_tag       = codec_avif_tags_list,
     .p.priv_class      = &mov_avif_muxer_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 46ed16985f..84edd418f0 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -2361,6 +2361,11 @@ const FFOutputFormat ff_mpegts_muxer = {
     .write_trailer  = mpegts_write_end,
     .deinit         = mpegts_deinit,
     .check_bitstream = mpegts_check_bitstream,
+#if FF_API_ALLOW_FLUSH
     .p.flags        = AVFMT_ALLOW_FLUSH | AVFMT_VARIABLE_FPS | AVFMT_NODIMENSIONS,
+#else
+    .p.flags         = AVFMT_VARIABLE_FPS | AVFMT_NODIMENSIONS,
+#endif
+    .flags_internal  = FF_FMT_ALLOW_FLUSH,
     .p.priv_class   = &mpegts_muxer_class,
 };
diff --git a/libavformat/mux.c b/libavformat/mux.c
index d3779202f0..5a1d6e41cb 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1206,7 +1206,13 @@ int av_write_frame(AVFormatContext *s, AVPacket *in)
     int ret;
 
     if (!in) {
+#if FF_API_ALLOW_FLUSH || LIBAVFORMAT_VERSION_MAJOR >= 61
+        // Hint: The pulse audio output device has this set,
+        // so we can't switch the check to FF_FMT_ALLOW_FLUSH immediately.
         if (s->oformat->flags & AVFMT_ALLOW_FLUSH) {
+#else
+        if (ffofmt(s->oformat)->flags_internal & FF_FMT_ALLOW_FLUSH) {
+#endif
             ret = ffofmt(s->oformat)->write_packet(s, NULL);
             flush_if_needed(s);
             if (ret >= 0 && s->pb && s->pb->error < 0)
diff --git a/libavformat/mux.h b/libavformat/mux.h
index 9de5c2852a..b9ec75641d 100644
--- a/libavformat/mux.h
+++ b/libavformat/mux.h
@@ -27,6 +27,8 @@
 
 struct AVDeviceInfoList;
 
+#define FF_FMT_ALLOW_FLUSH                    (1 << 1)
+
 typedef struct FFOutputFormat {
     /**
      * The public AVOutputFormat. See avformat.h for it.
@@ -38,13 +40,13 @@ typedef struct FFOutputFormat {
     int priv_data_size;
 
     /**
-     * Internal flags. See FF_FMT_FLAG_* in internal.h.
+     * Internal flags. See FF_FMT_* in internal.h and mux.h.
      */
     int flags_internal;
 
     int (*write_header)(AVFormatContext *);
     /**
-     * Write a packet. If AVFMT_ALLOW_FLUSH is set in flags,
+     * Write a packet. If FF_FMT_ALLOW_FLUSH is set in flags_internal,
      * pkt can be NULL in order to flush data buffered in the muxer.
      * When flushing, return 0 if there still is more data to flush,
      * or 1 if everything was flushed and there is no more buffered
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index c669aea25a..69a66f586d 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -771,8 +771,13 @@ const FFOutputFormat ff_ogg_muxer = {
     .write_packet      = ogg_write_packet,
     .write_trailer     = ogg_write_trailer,
     .deinit            = ogg_free,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_TS_NEGATIVE | AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH,
+#else
+    .p.flags           = AVFMT_TS_NEGATIVE | AVFMT_TS_NONSTRICT,
+#endif
     .p.priv_class      = &ogg_muxer_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
 
@@ -789,8 +794,13 @@ const FFOutputFormat ff_oga_muxer = {
     .write_packet      = ogg_write_packet,
     .write_trailer     = ogg_write_trailer,
     .deinit            = ogg_free,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_TS_NEGATIVE | AVFMT_ALLOW_FLUSH,
+#else
+    .p.flags           = AVFMT_TS_NEGATIVE,
+#endif
     .p.priv_class      = &ogg_muxer_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
 
@@ -810,8 +820,13 @@ const FFOutputFormat ff_ogv_muxer = {
     .write_packet      = ogg_write_packet,
     .write_trailer     = ogg_write_trailer,
     .deinit            = ogg_free,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_TS_NEGATIVE | AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH,
+#else
+    .p.flags           = AVFMT_TS_NEGATIVE | AVFMT_TS_NONSTRICT,
+#endif
     .p.priv_class      = &ogg_muxer_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
 
@@ -828,8 +843,13 @@ const FFOutputFormat ff_spx_muxer = {
     .write_packet      = ogg_write_packet,
     .write_trailer     = ogg_write_trailer,
     .deinit            = ogg_free,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_TS_NEGATIVE | AVFMT_ALLOW_FLUSH,
+#else
+    .p.flags           = AVFMT_TS_NEGATIVE,
+#endif
     .p.priv_class      = &ogg_muxer_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
 
@@ -846,7 +866,12 @@ const FFOutputFormat ff_opus_muxer = {
     .write_packet      = ogg_write_packet,
     .write_trailer     = ogg_write_trailer,
     .deinit            = ogg_free,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_TS_NEGATIVE | AVFMT_ALLOW_FLUSH,
+#else
+    .p.flags           = AVFMT_TS_NEGATIVE,
+#endif
     .p.priv_class      = &ogg_muxer_class,
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
 #endif
diff --git a/libavformat/tee.c b/libavformat/tee.c
index cb555f52fd..cfa8346bc9 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -614,5 +614,10 @@ const FFOutputFormat ff_tee_muxer = {
     .write_trailer     = tee_write_trailer,
     .write_packet      = tee_write_packet,
     .p.priv_class      = &tee_muxer_class,
+#if FF_API_ALLOW_FLUSH
     .p.flags           = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE,
+#else
+    .p.flags           = AVFMT_NOFILE | AVFMT_TS_NEGATIVE,
+#endif
+    .flags_internal    = FF_FMT_ALLOW_FLUSH,
 };
diff --git a/libavformat/version_major.h b/libavformat/version_major.h
index d1d6f95b15..ca9dccc94d 100644
--- a/libavformat/version_major.h
+++ b/libavformat/version_major.h
@@ -47,6 +47,7 @@
 #define FF_API_AVFORMAT_IO_CLOSE        (LIBAVFORMAT_VERSION_MAJOR < 61)
 #define FF_API_AVIO_WRITE_NONCONST      (LIBAVFORMAT_VERSION_MAJOR < 61)
 #define FF_API_LAVF_SHORTEST            (LIBAVFORMAT_VERSION_MAJOR < 61)
+#define FF_API_ALLOW_FLUSH              (LIBAVFORMAT_VERSION_MAJOR < 61)
 
 
 #define FF_API_R_FRAME_RATE            1
-- 
2.34.1



More information about the ffmpeg-devel mailing list