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>
This commit is contained in:
Martin Storsjö
2016-04-20 23:10:37 +03:00
parent fd4957d9c6
commit e1eb0fc960
6 changed files with 49 additions and 1 deletions

View File

@@ -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