movenc: Fix sample clustering for hybrid_fragmented+delay_moov

If samples were available when the moov was written, chunking
for those samples has been done already, which has to be reset
here.

This is the case when not using empty_moov, when the moov box
describes the first fragment - this case was accounted for already.
But if using the delay_moov flag, then those samples also were
available when writing the moov, so chunking for them has already
been done in this case as well.

Therefore, always reset chunking here (it should be harmless to
always do it), and update the comment to clarify the cases
involved here.
This commit is contained in:
Martin Storsjö
2025-10-14 13:47:03 +03:00
parent dc39a576ad
commit 27f5561885

View File

@@ -6390,8 +6390,10 @@ static int mov_finish_fragment(MOVMuxContext *mov, MOVTrack *track,
if (mov->flags & FF_MOV_FLAG_HYBRID_FRAGMENTED) {
for (i = 0; i < track->entry; i++)
track->cluster[i].pos += ref_pos + track->data_offset;
if (track->cluster_written == 0 && !(mov->flags & FF_MOV_FLAG_EMPTY_MOOV)) {
// First flush. If this was a case of not using empty moov, reset chunking.
if (track->cluster_written == 0) {
// First flush. Chunking for this fragment may already have been
// done, either if we didn't use empty_moov, or if we did use
// delay_moov. In either case, reset chunking here.
for (i = 0; i < track->entry; i++) {
track->cluster[i].chunkNum = 0;
track->cluster[i].samples_in_chunk = track->cluster[i].entries;