[FFmpeg-trac] #7828(undetermined:open): gapless playback doesn't work with AAC (remainder and Apple style)

FFmpeg trac at avcodec.org
Wed Jul 12 17:59:48 EEST 2023


#7828: gapless playback doesn't work with AAC (remainder and Apple style)
-------------------------------------+-------------------------------------
             Reporter:  Christoph    |                    Owner:  Elon Musk
  Anton Mitterer                     |
                 Type:  defect       |                   Status:  open
             Priority:  normal       |                Component:
                                     |  undetermined
              Version:  git-master   |               Resolution:
             Keywords:  aac gapless  |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
Comment (by John Regan):

 Replying to [comment:11 Christoph Anton Mitterer]:
 > Oh btw: your patch, does for which gapless playback "notation" does it
 fix it? As far as I understood there are different formats for AAC (one
 following MPEG standards... and some proprietary Apply system - see
 comments above).

 That listed patch is for the MPEG standard method - it relies on the
 `stts` box to find the last signaled sample duration. The Apple method
 relies on an MP4 tag that it parses.

 I'm not sure if that patch would handle fragmented MP4 files - they
 usually have an empty `stts` box, and instead rely on the Track Fragment
 Header Box (`tfhd`) or the Track Fragment Run Box (`trun`).

 Bug #10458 was closed as a duplicate of this one. The process outlined
 above to demonstrate the issue is complex (lots of downloading and
 concatenating files, etc). Thought it might be helpful to share my example
 for detecting an error with gapless decoding - just encode a file using
 some known number of samples, decode it back, and check that the number of
 decoded samples is different.

 {{{
 % ffmpeg -f lavfi -i anullsrc=r=48000:d=2 source.wav

 # verify the created audio file as exactly 96000 samples
 % soxi -s source.wav
 96000

 # encode to aac
 % ffmpeg -i source.wav -c:a aac encoded.m4a

 # decode back to wav
 % ffmpeg -i encoded.m4a destination.wav

 # observe the sample count != 96000
 % soxi -s destination.wav
 96256
 }}}

 You can replace the aac codec with any codec that can go in MP4, and
 relies on the MP4 file to signal the duration - so aac, mp3, opus all have
 the issue.

 Attaching sample files - one that relies on the stts box, one that relies
 on the tfhd, and one that relies on trun. When properly decoded they
 should all be exactly 2 seconds @ 48kHz (96000 samples).
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/7828#comment:12>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list