summaryrefslogtreecommitdiff
path: root/libavformat/mux.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2016-04-20 23:10:37 +0300
committerMartin Storsjö <martin@martin.st>2016-05-18 10:37:03 +0300
commite1eb0fc960163402bbb4e630185790488f7d28ed (patch)
tree6e27920fd573abb1428ccd0b6fa4e74ab9603165 /libavformat/mux.c
parentfd4957d9c67996e7d218fd36b4168c9cb85f9ea7 (diff)
movenc: Use packets in interleaving queues for the duration at the end of fragments
As long as caller only writes packets using av_interleaved_write_frame with no manual flushing, this should allow us to always have accurate durations at the end of fragments, since there should be at least one queued packet in each stream (except for the stream where the current packet is being written, but if the muxer itself does the cutting of fragments, it also has info about the next packet for that stream). Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r--libavformat/mux.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 49fe65cf98..c41c477ab4 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -614,6 +614,17 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
}
}
+const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream)
+{
+ AVPacketList *pktl = s->internal->packet_buffer;
+ while (pktl) {
+ if (pktl->pkt.stream_index == stream)
+ return &pktl->pkt;
+ pktl = pktl->next;
+ }
+ return NULL;
+}
+
/**
* Interleave an AVPacket correctly so it can be muxed.
* @param out the interleaved packet will be output here