PR #26052 opened by Baptiste Coudurier (bcoudurier)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26052
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26052.patch

The initialization segment precedes the final packet, so its edit list cannot 
trim end padding. Use the presentation duration for the padded packet in a DASH 
fragment so trun describes the same end time as sidx.

Verified with three seconds of 44.1 kHz AAC. The last trun now signals 204 
ticks for its final sample. Its 43 samples sum to the 43,212 ticks in sidx.



>From 5f744573c8466a061c8ea90c085178f30d5b4433 Mon Sep 17 00:00:00 2001
From: Baptiste Coudurier <[email protected]>
Date: Fri, 13 Nov 2026 21:15:18 -0800
Subject: [PATCH] avformat/movenc: trim trailing audio padding in DASH sample
 durations

The initialization segment precedes the final packet, so its edit list cannot 
trim end padding. Use the presentation duration for the padded packet in a DASH 
fragment so trun describes the same end time as sidx.
---
 libavformat/movenc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index c3fa66d816c..5e8ab88b330 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -7540,6 +7540,9 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
                                  trk->st->time_base);
         if (duration < 0)
             return AVERROR_INVALIDDATA;
+        /* The DASH initialization segment cannot trim the final fragment. */
+        if (mov->flags & FF_MOV_FLAG_DASH && AV_RL32(sd->data + 4))
+            pkt->duration = duration;
     } else
         duration = pkt->duration;
 
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to