Write a packet to an output media file ensuring correct interleaving.
This function will buffer the packets internally as needed to make sure the
packets in the output file are properly interleaved in the order of
increasing dts. Callers doing their own interleaving should call
av_write_frame() instead of this function.
@param s media file handle
@param pkt The packet containing the data to be written.
<br>
If the packet is reference-counted, this function will take
ownership of this reference and unreference it later when it sees
fit.
The caller must not access the data through this reference after
this function returns. If the packet is not reference-counted,
libavformat will make a copy.
<br>
This parameter can be NULL (at any time, not just at the end), to
flush the interleaving queues.
<br>
Packet's @ref AVPacket.stream_index "stream_index" field must be
set to the index of the corresponding stream in @ref
AVFormatContext.streams "s->streams".
<br>
The timestamps (@ref AVPacket.pts "pts", @ref AVPacket.dts "dts")
must be set to correct values in the stream's timebase (unless the
output format is flagged with the AVFMT_NOTIMESTAMPS flag, then
they can be set to AV_NOPTS_VALUE).
The dts for subsequent packets in one stream must be strictly
increasing (unless the output format is flagged with the
AVFMT_TS_NONSTRICT, then they merely have to be nondecreasing).
@ref AVPacket.duration "duration") should also be set if known.
@return 0 on success, a negative AVERROR on error. Libavformat will always
take care of freeing the packet, even if this function fails.
Write a packet to an output media file ensuring correct interleaving.
This function will buffer the packets internally as needed to make sure the packets in the output file are properly interleaved in the order of increasing dts. Callers doing their own interleaving should call av_write_frame() instead of this function.
@param s media file handle @param pkt The packet containing the data to be written. <br> If the packet is reference-counted, this function will take ownership of this reference and unreference it later when it sees fit. The caller must not access the data through this reference after this function returns. If the packet is not reference-counted, libavformat will make a copy. <br> This parameter can be NULL (at any time, not just at the end), to flush the interleaving queues. <br> Packet's @ref AVPacket.stream_index "stream_index" field must be set to the index of the corresponding stream in @ref AVFormatContext.streams "s->streams". <br> The timestamps (@ref AVPacket.pts "pts", @ref AVPacket.dts "dts") must be set to correct values in the stream's timebase (unless the output format is flagged with the AVFMT_NOTIMESTAMPS flag, then they can be set to AV_NOPTS_VALUE). The dts for subsequent packets in one stream must be strictly increasing (unless the output format is flagged with the AVFMT_TS_NONSTRICT, then they merely have to be nondecreasing). @ref AVPacket.duration "duration") should also be set if known.
@return 0 on success, a negative AVERROR on error. Libavformat will always take care of freeing the packet, even if this function fails.
@see av_write_frame(), AVFormatContext.max_interleave_delta