This is enabled by default and can be disabled with "-fflags -flush_packets". Inspired by a patch from Nicolas George <nicolas.george@normalesup.org>. Signed-off-by: Martin Storsjö <martin@martin.st>tags/n2.1
| @@ -894,6 +894,7 @@ typedef struct AVFormatContext { | |||||
| #define AVFMT_FLAG_NOBUFFER 0x0040 ///< Do not buffer frames when possible | #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_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_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. | * decoding: size of data to probe; encoding: unused. | ||||
| @@ -404,6 +404,7 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt) | |||||
| static int write_packet(AVFormatContext *s, AVPacket *pkt) | static int write_packet(AVFormatContext *s, AVPacket *pkt) | ||||
| { | { | ||||
| int ret; | |||||
| if (!(s->oformat->flags & (AVFMT_TS_NEGATIVE | AVFMT_NOTIMESTAMPS))) { | if (!(s->oformat->flags & (AVFMT_TS_NEGATIVE | AVFMT_NOTIMESTAMPS))) { | ||||
| AVRational time_base = s->streams[pkt->stream_index]->time_base; | AVRational time_base = s->streams[pkt->stream_index]->time_base; | ||||
| int64_t offset = 0; | int64_t offset = 0; | ||||
| @@ -420,7 +421,12 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) | |||||
| if (pkt->pts != AV_NOPTS_VALUE) | if (pkt->pts != AV_NOPTS_VALUE) | ||||
| pkt->pts += offset; | 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) | int av_write_frame(AVFormatContext *s, AVPacket *pkt) | ||||
| @@ -33,7 +33,8 @@ | |||||
| static const AVOption avformat_options[] = { | static const AVOption avformat_options[] = { | ||||
| {"probesize", "set probing size", OFFSET(probesize), AV_OPT_TYPE_INT, {.i64 = 5000000 }, 32, INT_MAX, D}, | {"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}, | {"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"}, | {"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"}, | {"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"}, | {"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"}, | ||||
| @@ -30,7 +30,7 @@ | |||||
| #include "libavutil/avutil.h" | #include "libavutil/avutil.h" | ||||
| #define LIBAVFORMAT_VERSION_MAJOR 55 | #define LIBAVFORMAT_VERSION_MAJOR 55 | ||||
| #define LIBAVFORMAT_VERSION_MINOR 3 | |||||
| #define LIBAVFORMAT_VERSION_MINOR 4 | |||||
| #define LIBAVFORMAT_VERSION_MICRO 0 | #define LIBAVFORMAT_VERSION_MICRO 0 | ||||
| #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ | ||||