[FFmpeg-cvslog] avformat/movenc: sidx earliest_presentation_time is applied after editlist

Zhao Zhili git at videolan.org
Fri Apr 29 12:23:11 EEST 2022


ffmpeg | branch: master | Zhao Zhili <quinkblack at foxmail.com> | Tue Mar 29 12:50:53 2022 +0800| [301141b57636c4430e7440e8ff4956daf9cb0fb3] | committer: Zhao Zhili

avformat/movenc: sidx earliest_presentation_time is applied after editlist

Fix #8334

Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=301141b57636c4430e7440e8ff4956daf9cb0fb3
---

 libavformat/movenc.c  |  6 +++++-
 tests/ref/fate/movenc | 10 +++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index b9956e699c..d2cd5bc6f4 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4781,7 +4781,8 @@ static int mov_write_sidx_tag(AVIOContext *pb,
 
     if (track->entry) {
         entries = 1;
-        presentation_time = track->cluster[0].dts + track->cluster[0].cts;
+        presentation_time = track->cluster[0].dts + track->cluster[0].cts -
+                            track->start_dts - track->start_cts;
         duration = track->end_pts -
                    (track->cluster[0].dts + track->cluster[0].cts);
         starts_with_SAP = track->cluster[0].flags & MOV_SYNC_SAMPLE;
@@ -4796,6 +4797,9 @@ static int mov_write_sidx_tag(AVIOContext *pb,
         if (entries <= 0)
             return 0;
         presentation_time = track->frag_info[0].time;
+        /* presentation_time <= 0 is handled by mov_add_tfra_entries() */
+        if (presentation_time > 0)
+            presentation_time -= track->start_dts + track->start_cts;
     }
 
     avio_wb32(pb, 0); /* size */
diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc
index 19e4e291b8..968a3d27f2 100644
--- a/tests/ref/fate/movenc
+++ b/tests/ref/fate/movenc
@@ -101,28 +101,28 @@ write_data len 1223, time nopts, type header atom ftyp
 041ac8efc35a0d023c26d05eedb20403 1223 delay-moov-elst-signal-init
 write_data len 1004, time -33333, type sync atom sidx
 write_data len 996, time 966667, type sync atom sidx
-5a583d89318827d2569eecbeaa18c238 996 delay-moov-elst-signal-second-frag
+69c9025ffb10302c7b5c2ed9fde86c44 996 delay-moov-elst-signal-second-frag
 write_data len 148, time nopts, type trailer atom -
 write_data len 1223, time nopts, type header atom ftyp
 041ac8efc35a0d023c26d05eedb20403 1223 delay-moov-elst-signal-init-discont
 write_data len 996, time 966667, type sync atom sidx
-5a583d89318827d2569eecbeaa18c238 996 delay-moov-elst-signal-second-frag-discont
+69c9025ffb10302c7b5c2ed9fde86c44 996 delay-moov-elst-signal-second-frag-discont
 write_data len 110, time nopts, type trailer atom -
 write_data len 1247, time nopts, type header atom ftyp
 80511a51d1ac9cde62337eed7176ae03 1247 delay-moov-elst-signal-init-discont-largets
 write_data len 996, time 279621233333, type sync atom sidx
-dc695d65e8a0cdafee28acd8a5ccf81a 996 delay-moov-elst-signal-second-frag-discont-largets
+471fc64644a6bf4065c489fe4e04be7d 996 delay-moov-elst-signal-second-frag-discont-largets
 write_data len 110, time nopts, type trailer atom -
 write_data len 1223, time nopts, type header atom ftyp
 write_data len 2572, time -333333, type sync atom sidx
 write_data len 996, time 5166667, type sync atom sidx
 write_data len 148, time nopts, type trailer atom -
-d37a7eda807912b9ed05ccfe003a9e4f 4939 vfr
+5c873f6e37d5af09e3c6329cf94cd6ca 4939 vfr
 write_data len 1223, time nopts, type header atom ftyp
 write_data len 2572, time -333333, type sync atom sidx
 write_data len 996, time 5166667, type sync atom sidx
 write_data len 148, time nopts, type trailer atom -
-d37a7eda807912b9ed05ccfe003a9e4f 4939 vfr-noduration
+5c873f6e37d5af09e3c6329cf94cd6ca 4939 vfr-noduration
 write_data len 1231, time nopts, type header atom ftyp
 write_data len 1500, time -333333, type sync atom moof
 write_data len 1500, time nopts, type unknown atom -



More information about the ffmpeg-cvslog mailing list