diff mbox series

[FFmpeg-devel] mov: fix seek to next root atom in fragmented mp4

Message ID 20200329203245.225679-1-jstebbins@jetheaddev.com
State Accepted
Commit 21a65d63109628276a8fa88f8e6a106696506dc9
Headers show
Series [FFmpeg-devel] mov: fix seek to next root atom in fragmented mp4 | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

John Stebbins March 29, 2020, 8:32 p.m. UTC
If some but not all moof's are referenced in an sidx, whole fragments
were being skipped.

Fixes tickets 7377, 7389, and 8502
May also fix 8070 but the sample links expired, so I can't test.
---
 libavformat/mov.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andreas Rheinhardt March 29, 2020, 8:38 p.m. UTC | #1
John Stebbins:
> If some but not all moof's are referenced in an sidx, whole fragments
> were being skipped.
> 
> Fixes tickets 7377, 7389, and 8502
> May also fix 8070 but the sample links expired, so I can't test.

Sample can be found here:
https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket8070/
(You may probably thank Carl-Eugen for this.)

- Andreas
John Stebbins March 29, 2020, 8:48 p.m. UTC | #2
On Sun, 2020-03-29 at 22:38 +0200, Andreas Rheinhardt wrote:
> John Stebbins:
> > If some but not all moof's are referenced in an sidx, whole
> > fragments
> > were being skipped.
> > 
> > Fixes tickets 7377, 7389, and 8502
> > May also fix 8070 but the sample links expired, so I can't test.
> 
> Sample can be found here:
> https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket8070/
> (You may probably thank Carl-Eugen for this.)
> 

Thanks.  So this patch *does not* fix 8070.  I'll investigate...
Carl Eugen Hoyos March 29, 2020, 9:07 p.m. UTC | #3
Am So., 29. März 2020 um 22:33 Uhr schrieb John Stebbins
<jstebbins@jetheaddev.com>:
>
> If some but not all moof's are referenced in an sidx, whole fragments
> were being skipped.
>
> Fixes tickets 7377, 7389, and 8502
> May also fix 8070 but the sample links expired, so I can't test.

Thank you for looking into this!

Carl Eugen
Michael Niedermayer April 10, 2020, 10:10 p.m. UTC | #4
On Sun, Mar 29, 2020 at 08:48:50PM +0000, John Stebbins wrote:
> On Sun, 2020-03-29 at 22:38 +0200, Andreas Rheinhardt wrote:
> > John Stebbins:
> > > If some but not all moof's are referenced in an sidx, whole
> > > fragments
> > > were being skipped.
> > > 
> > > Fixes tickets 7377, 7389, and 8502
> > > May also fix 8070 but the sample links expired, so I can't test.
> > 
> > Sample can be found here:
> > https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket8070/
> > (You may probably thank Carl-Eugen for this.)
> > 
> 
> Thanks.  So this patch *does not* fix 8070.  I'll investigate...

patch LGTM, ill apply it tomorrow without the reference to 8070

Thanks

[...]
diff mbox series

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f280f360b6..8ed8b7f6e9 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7724,7 +7724,8 @@  static int mov_switch_root(AVFormatContext *s, int64_t target, int index)
     mov->next_root_atom = 0;
     if (index < 0 || index >= mov->frag_index.nb_items)
         index = search_frag_moof_offset(&mov->frag_index, target);
-    if (index < mov->frag_index.nb_items) {
+    if (index < mov->frag_index.nb_items &&
+        mov->frag_index.item[index].moof_offset == target) {
         if (index + 1 < mov->frag_index.nb_items)
             mov->next_root_atom = mov->frag_index.item[index + 1].moof_offset;
         if (mov->frag_index.item[index].headers_read)