diff options
-rw-r--r-- | libavformat/avformat.h | 1 | ||||
-rw-r--r-- | libavformat/mux.c | 8 | ||||
-rw-r--r-- | libavformat/options_table.h | 3 | ||||
-rw-r--r-- | libavformat/version.h | 2 |
4 files changed, 11 insertions, 3 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 12462c8291..ce7a2f89e1 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -894,6 +894,7 @@ typedef struct AVFormatContext { #define AVFMT_FLAG_NOBUFFER 0x0040 ///< Do not buffer frames when possible #define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it. #define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted +#define AVFMT_FLAG_FLUSH_PACKETS 0x0200 ///< Flush the AVIOContext every packet. /** * decoding: size of data to probe; encoding: unused. diff --git a/libavformat/mux.c b/libavformat/mux.c index 5a08dd6c72..505ed2e6f8 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -404,6 +404,7 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt) static int write_packet(AVFormatContext *s, AVPacket *pkt) { + int ret; if (!(s->oformat->flags & (AVFMT_TS_NEGATIVE | AVFMT_NOTIMESTAMPS))) { AVRational time_base = s->streams[pkt->stream_index]->time_base; int64_t offset = 0; @@ -420,7 +421,12 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) if (pkt->pts != AV_NOPTS_VALUE) pkt->pts += offset; } - return s->oformat->write_packet(s, pkt); + ret = s->oformat->write_packet(s, pkt); + + if (s->pb && ret >= 0 && s->flags & AVFMT_FLAG_FLUSH_PACKETS) + avio_flush(s->pb); + + return ret; } int av_write_frame(AVFormatContext *s, AVPacket *pkt) diff --git a/libavformat/options_table.h b/libavformat/options_table.h index 273c589d12..54bf25fc27 100644 --- a/libavformat/options_table.h +++ b/libavformat/options_table.h @@ -33,7 +33,8 @@ static const AVOption avformat_options[] = { {"probesize", "set probing size", OFFSET(probesize), AV_OPT_TYPE_INT, {.i64 = 5000000 }, 32, INT_MAX, D}, {"packetsize", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, E}, -{"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT }, INT_MIN, INT_MAX, D|E, "fflags"}, +{"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = AVFMT_FLAG_FLUSH_PACKETS }, INT_MIN, INT_MAX, D|E, "fflags"}, +{"flush_packets", "reduce the latency by flushing out packets immediately", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_FLUSH_PACKETS }, INT_MIN, INT_MAX, D, "fflags"}, {"ignidx", "ignore index", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_IGNIDX }, INT_MIN, INT_MAX, D, "fflags"}, {"genpts", "generate pts", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_GENPTS }, INT_MIN, INT_MAX, D, "fflags"}, {"nofillin", "do not fill in missing values that can be exactly calculated", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_NOFILLIN }, INT_MIN, INT_MAX, D, "fflags"}, diff --git a/libavformat/version.h b/libavformat/version.h index ac675ce953..38c959ff97 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -30,7 +30,7 @@ #include "libavutil/avutil.h" #define LIBAVFORMAT_VERSION_MAJOR 55 -#define LIBAVFORMAT_VERSION_MINOR 3 +#define LIBAVFORMAT_VERSION_MINOR 4 #define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |