Opened 4 weeks ago

Last modified 4 weeks ago

#7497 new defect

trun.version=1 negative composition time offset is mishandled causing non-monotonic packet DTS

Reported by: pkoshevoy Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: mov
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
demuxing http://tungsten.aaplimg.com/VOD/bipbop_adv_example_hevc/v16/main.mp4 produces packets with non-monotonically increasing DTS. The file plays fine in QuickTime? X player.

How to reproduce:

$ wget http://tungsten.aaplimg.com/VOD/bipbop_adv_example_hevc/v16/main.mp4

$ ffprobe -select_streams v:0 -show_packets main.mp4 | grep dts_time=10.000
ffprobe version N-92190-gb2adc31697 Copyright (c) 2007-2018 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.38)
  configuration: --prefix=/Users/pkoshevoy/x86_64 --disable-debug --enable-shared --disable-static --enable-swscale --enable-avfilter --enable-pthreads --enable-gpl --enable-version3 --enable-postproc --enable-x86asm --enable-runtime-cpudetect --extra-cflags='-I/usr/local/include -mmacosx-version-min=10.8' --extra-ldflags='-headerpad_max_install_names -L/usr/local/lib -mmacosx-version-min=10.8'
  libavutil      56. 19.101 / 56. 19.101
  libavcodec     58. 33.100 / 58. 33.100
  libavformat    58. 19.100 / 58. 19.100
  libavdevice    58.  4.105 / 58.  4.105
  libavfilter     7. 33.101 /  7. 33.101
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'main.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp41mp42isomhlsf
    creation_time   : 2017-06-06T02:40:19.000000Z
  Duration: 00:10:08.63, start: 10.016667, bitrate: 3233 kb/s
    Stream #0:0(eng): Video: hevc (Main 10) (hvc1 / 0x31637668), yuv420p10le(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 3229 kb/s, 60 fps, 60 tbr, 6k tbn, 6k tbc (default)
    Metadata:
      creation_time   : 2017-06-06T02:40:19.000000Z
      handler_name    : Core Media Video
    Stream #0:1(eng): Subtitle: eia_608 (c608 / 0x38303663), 0 kb/s (default)
    Metadata:
      creation_time   : 2017-06-06T02:40:19.000000Z
      handler_name    : Core Media Closed Caption
dts_time=10.000000
dts_time=10.000000
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ff90d000000] DTS 60000 < 62900 out of order
dts_time=10.000000
dts_time=10.000000

This may be related to the issue described in https://sourceforge.net/p/gpac/bugs/331/

I've had a quick look at libavformat/mov.c and I've noticed that mov_read_trun ignores version value, and ctts_duration is always unsigned.

Change History (3)

comment:1 Changed 4 weeks ago by cehoyos

  • Keywords mov added

comment:2 Changed 4 weeks ago by pkoshevoy

  • Keywords mov removed

from the 14496-12 2012 spec:

8.6.1.3.2 Syntax

aligned(8) class CompositionOffsetBox 
   extends FullBox(‘ctts’, version = 0, 0) {
   unsigned int(32) entry_count;
   int i;
   if (version == 0) {
      for (i = 0; i < entry_count; i++) {
         unsigned int(32)  sample_count;
         unsigned int(32)  sample_offset;
      }
   }
   else if (version == 1) {
      for (i = 0; i < entry_count; i++) {
         unsigned int(32)  sample_count;
         signed   int(32)  sample_offset;
      }
   }
}



8.8.8.2 Syntax

aligned(8) class TrackRunBox
extends FullBox(‘trun’, version, tr_flags) {
   unsigned int(32) sample_count;
   // the following are optional fields
   signed int(32) data_offset;
   unsigned int(32) first_sample_flags;
   // all fields in the following array are optional {
      unsigned int(32)  sample_duration;
      unsigned int(32)  sample_size;
      unsigned int(32)  sample_flags
      if (version == 0)
         { unsigned int(32) sample_composition_time_offset; }
      else
         { signed int(32) sample_composition_time_offset; }
   }[ sample_count ]
}

Last edited 4 weeks ago by pkoshevoy (previous) (diff)

comment:3 Changed 4 weeks ago by pkoshevoy

  • Keywords mov added
Note: See TracTickets for help on using tickets.