diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2013-09-11 16:02:06 +0400 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-09-16 23:11:08 +0400 |
commit | 596e5d4783ca951258a7c580951fd161f1785ec1 (patch) | |
tree | 9d046fe97f3869e5fb66991a39734948fb374a60 /libavformat/mux.c | |
parent | 0a9425d7cfdf0113c3d32096c9406823efe0cd0a (diff) |
lavf: Add a flag to enable/disable per-packet flushing
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>
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r-- | libavformat/mux.c | 8 |
1 files changed, 7 insertions, 1 deletions
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) |