[FFmpeg-devel] [PATCH v2 03/10] avformat/tee: Support flushing by writing NULL pkt
sebechlebskyjan at gmail.com
sebechlebskyjan at gmail.com
Tue Jul 12 00:27:51 EEST 2016
From: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
This will add support for flushing by writing NULL
packet to the tee muxer, which propagates the action
to slave muxers as expected.
Signed-off-by: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
---
Unfortunately, I've realized that I've forgotten to set AVFMT_ALLOW_FLUSH
flag to the tee muxer to make it flushable. I've also changed commit
message, because crash without AVFMT_ALLOW_FLUSH would not happen
if write_packet is not called directly with NULL argument.
This version should be allright.
libavformat/tee.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/libavformat/tee.c b/libavformat/tee.c
index c276a37..e750752 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -520,6 +520,17 @@ static int tee_write_packet(AVFormatContext *avf, AVPacket *pkt)
if (!(avf2 = tee->slaves[i].avf))
continue;
+ /* Flush slave if pkt is NULL*/
+ if (!pkt) {
+ ret = av_interleaved_write_frame(avf2, NULL);
+ if (ret < 0) {
+ ret = tee_process_slave_failure(avf, i, ret);
+ if (!ret_all && ret < 0)
+ ret_all = ret;
+ }
+ continue;
+ }
+
s = pkt->stream_index;
s2 = tee->slaves[i].stream_map[s];
if (s2 < 0)
@@ -557,5 +568,5 @@ AVOutputFormat ff_tee_muxer = {
.write_trailer = tee_write_trailer,
.write_packet = tee_write_packet,
.priv_class = &tee_muxer_class,
- .flags = AVFMT_NOFILE,
+ .flags = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH,
};
--
1.9.1
More information about the ffmpeg-devel
mailing list