On Tue, 17 May 2016, Anton Khirnov wrote:

Quoting Martin Storsjö (2016-05-17 11:16:56)
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).

---

This approach was earlier ok'd by Anton.
---
 libavformat/avformat.h |  4 ++++
 libavformat/internal.h | 10 ++++++++++
 libavformat/movenc.c   | 22 ++++++++++++++++++++++
 libavformat/movenc.h   |  1 +
 libavformat/mux.c      | 11 +++++++++++
 libavformat/version.h  |  2 +-
 6 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 7d026b6..fbdfba4 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1720,6 +1720,10 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt);
  * increasing dts. Callers doing their own interleaving should call
  * av_write_frame() instead of this function.
  *
+ * Using this function instead of av_write_frame() can give muxers advance
+ * knowledge of future packets, improving e.g. the behaviour of the mp4
+ * muxer for VFR content in fragmenting mode.
+ *
  * @param s media file handle
  * @param pkt The packet containing the data to be written.
  *            <br>
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 4760ba8..b2a7362 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -441,4 +441,14 @@ static inline int ff_rename(const char *oldpath, const 
char *newpath)
  */
 void ff_format_io_close(AVFormatContext *s, AVIOContext **pb);

+/**
+ * Find the next packet in the interleaving queue for the given stream.
+ * The packet is not removed from the interleaving queue, but only
+ * a pointer to it is returned.
+ *
+ * @return a pointer to the next packet, or NULL if no packet is queued
+ *         for this stream.
+ */
+AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream);

Maybe make the return value const to make it clear that the caller is
not supposed to mess with it?

Done locally, thanks

// Martin
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to