This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit dac8b3f367077cf2a7f366dd68dd402cf32f93bf
Author:     James Almer <[email protected]>
AuthorDate: Fri Jun 26 10:21:56 2026 -0300
Commit:     James Almer <[email protected]>
CommitDate: Mon Jun 29 12:38:12 2026 -0300

    avformat/movenc: read packet duration at the time it's needed
    
    Reading it at the beginning of ff_mov_write_packet() means that any changes 
to it
    that happen afterwards will not be taken into account for the remainer 
calculation.
    
    Signed-off-by: James Almer <[email protected]>
---
 libavformat/movenc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index c14f05ecc8..6012b16d67 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6935,7 +6935,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
     AVCodecParameters *par;
     AVProducerReferenceTime *prft;
     unsigned int samples_in_chunk = 0;
-    int64_t duration = pkt->duration;
+    int64_t duration;
     int size = pkt->size, ret = 0, offset = 0;
     size_t prft_size;
     uint8_t *reformatted_data = NULL;
@@ -7309,12 +7309,13 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
     sd = av_packet_side_data_get(pkt->side_data, pkt->side_data_elems, 
AV_PKT_DATA_SKIP_SAMPLES);
     if (sd && sd->size >= 10 && trk->par->frame_size) {
         duration = FFMAX(av_rescale_q(trk->par->frame_size, (AVRational){ 1, 
trk->par->sample_rate },
-                                      trk->st->time_base), duration);
+                                      trk->st->time_base), pkt->duration);
         duration -= av_rescale_q(AV_RL32(sd->data + 4), (AVRational){ 1, 
trk->par->sample_rate },
                                  trk->st->time_base);
         if (duration < 0)
             return AVERROR_INVALIDDATA;
-    }
+    } else
+        duration = pkt->duration;
 
     trk->track_duration = pkt->dts - trk->start_dts + pkt->duration;
     trk->last_sample_is_subtitle_end = 0;

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

Reply via email to