[FFmpeg-trac] #9372(avformat:new): MP4 demuxer breaks for edit-list and fragments

FFmpeg trac at avcodec.org
Wed Aug 11 16:59:04 EEST 2021


#9372: MP4 demuxer breaks for edit-list and fragments
-------------------------------------+-------------------------------------
             Reporter:  Ulrik        |                     Type:  defect
  Mikaelsson                         |
               Status:  new          |                 Priority:  normal
            Component:  avformat     |                  Version:
                                     |  unspecified
             Keywords:  mp4          |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 Summary of the bug: When a fragmented mp4 contains an edit-list it is only
 applied to the first fragment. According to IEEE 14496-12, it should apply
 to "the movie and subsequent movie fragments".

 The net effect is that all fragments after the first, are wrongly stamped
 with PTS ignoring the edit-list. For AAC, where priming-samples are
 encoded as an edit-list, this means some frames get the same PTS, and the
 second is dropped by the decoder, causing audible glitch. Furthermore, the
 subsequent fragments are all broken in A/V-sync.

 How to reproduce:
 {{{
 # Boring sine-waves as input, but it audibly exposes the glitch in the
 first
 #   segment change
 % ffmpeg -f lavfi -i \
 "aevalsrc='(sin(sin(t)*8000)+sin(sin(t/1.4)*4000)+sin(sin(t/3)*8000))/3.1':s=48000:d=20"
 \
   -c:a aac flat.mp4

 # Shaka packager produces fragmented MP4 with Edit-list to signal priming
 samples
 % packager --fragment_duration=4 --segment_duration=4 \
   input=flat.mp4,stream=audio,format=mp4,out=frag.mp4

 # Listen to "glitch" after 4 seconds
 % ffplay frag.mp4

 % ffprobe frag.mp4 -show_packets | grep pts
 > ....
 > pts=188416
 > pts=189440
 > pts=190464
 > pts=191488
 > pts=191488   # pts_time=3.989333
 > pts=192512
 > pts=193536
 > pts=194560
 > ...
 }}}

 For built-in AAC encoder, a single frame of priming samples will be time-
 duplicated and dropped. For libfdk_aac, two frames are duplicated and
 dropped. Consecutive fragments are then offset by one or two frames in
 PTS.
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/9372>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list