diff mbox

[FFmpeg-devel,V1] lavf/mov: fix fMP4 tfdt box lead to dts reset issue

Message ID 1565692140-5928-1-git-send-email-mypopydev@gmail.com
State New
Headers show

Commit Message

Jun Zhao Aug. 13, 2019, 10:29 a.m. UTC
From: Jun Zhao <barryjzhao@tencent.com>

In fMP4 format, traf maybe have zero or more trun box, in this case,
we just used tfdt as dts once. The sample layout like this:

[moof] size=8+1392
  [mfhd] size=12+4
    sequence number = 29
  [traf] size=8+1368
    [tfhd] size=12+16, flags=20038
      track ID = 1
      default sample duration = 512
      default sample size = 40720
      default sample flags = 0
    [tfdt] size=12+8, version=1
      base media decode time = 1873920
    [trun] size=12+452, version=1, flags=e01
      sample count = 37
      data offset = 1408
    [trun] size=12+452, version=1, flags=e01
      sample count = 37
      data offset = 292973
    [trun] size=12+380, version=1, flags=e01
      sample count = 31
      data offset = 586457

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavformat/mov.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Comments

Carl Eugen Hoyos Aug. 13, 2019, 11:08 a.m. UTC | #1
Am Di., 13. Aug. 2019 um 12:36 Uhr schrieb Jun Zhao <mypopydev@gmail.com>:
>
> From: Jun Zhao <barryjzhao@tencent.com>
>
> In fMP4 format, traf maybe have zero or more trun box, in this case,
> we just used tfdt as dts once. The sample layout like this:
>
> [moof] size=8+1392
>   [mfhd] size=12+4
>     sequence number = 29
>   [traf] size=8+1368
>     [tfhd] size=12+16, flags=20038
>       track ID = 1
>       default sample duration = 512
>       default sample size = 40720
>       default sample flags = 0
>     [tfdt] size=12+8, version=1
>       base media decode time = 1873920
>     [trun] size=12+452, version=1, flags=e01
>       sample count = 37
>       data offset = 1408
>     [trun] size=12+452, version=1, flags=e01
>       sample count = 37
>       data offset = 292973
>     [trun] size=12+380, version=1, flags=e01
>       sample count = 31
>       data offset = 586457

If this is meant to fix ticket #8070, please mention it in the commit message.

But more important: How did you test this patch / what does this patch
change with the sample from ticket #8070?

Carl Eugen
Jun Zhao Aug. 13, 2019, 11:34 a.m. UTC | #2
On Tue, Aug 13, 2019 at 7:08 PM Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>
> Am Di., 13. Aug. 2019 um 12:36 Uhr schrieb Jun Zhao <mypopydev@gmail.com>:
> >
> > From: Jun Zhao <barryjzhao@tencent.com>
> >
> > In fMP4 format, traf maybe have zero or more trun box, in this case,
> > we just used tfdt as dts once. The sample layout like this:
> >
> > [moof] size=8+1392
> >   [mfhd] size=12+4
> >     sequence number = 29
> >   [traf] size=8+1368
> >     [tfhd] size=12+16, flags=20038
> >       track ID = 1
> >       default sample duration = 512
> >       default sample size = 40720
> >       default sample flags = 0
> >     [tfdt] size=12+8, version=1
> >       base media decode time = 1873920
> >     [trun] size=12+452, version=1, flags=e01
> >       sample count = 37
> >       data offset = 1408
> >     [trun] size=12+452, version=1, flags=e01
> >       sample count = 37
> >       data offset = 292973
> >     [trun] size=12+380, version=1, flags=e01
> >       sample count = 31
> >       data offset = 586457
>
> If this is meant to fix ticket #8070, please mention it in the commit message.
>
> But more important: How did you test this patch / what does this patch
> change with the sample from ticket #8070?
>
I got a copyrighted sample for this issue, maybe I need to add FATE
test case with no copyright sample for this issue, I think. After I
submitted the patch, I found #8070 in trac, by the way, I think this
patch didn't fix #8070 after verified the #8070 test sample vd.mp4. I
will try to fix #8070. Thanks.
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 24de542..d47d491 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4762,6 +4762,7 @@  static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
             dts = frag_stream_info->tfdt_dts - sc->time_offset;
             av_log(c->fc, AV_LOG_DEBUG, "found tfdt time %"PRId64
                     ", using it for dts\n", dts);
+            frag_stream_info->tfdt_dts = AV_NOPTS_VALUE;
         } else {
             dts = sc->track_end - sc->time_offset;
             av_log(c->fc, AV_LOG_DEBUG, "found track end time %"PRId64