Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

AAC from HLS TS causes clicks when decoded to PCM per segment

I'm working on a custom HLS audio player for iOS.

Each .ts segment contains AAC audio. I extract AAC from each TS file, decode it to PCM (using FFmpegKit), and schedule it using AVAudioEngine.

❗ Problem:

Even though the segments belong to the same track, I hear click/pop sounds at the boundaries between segments.

I've tried:

  • Trimming the first 2112 samples (AAC encoder delay)
  • Using cross-correlation to align segment transitions
  • Comparing waveforms: when I merge the TS files first and decode, the PCM waveform is smooth. But when decoding each TS independently, the result is discontinuous and causes audible artifacts.

✅ What worked:

  • CMSampleBuffer + AVSampleBufferAudioRenderer plays the segments perfectly without artifacts.
  • ❌ But this path doesn’t allow me to modify the PCM data, which I need.

❌ Tried and failed:

  • Tried attaching MTAudioProcessingTap to AVPlayer, but when loading from an M3U8 playlist, AVAsset does not expose audio tracks, so I can't attach the tap.

❓ Question:

Is using AudioFileStream + AudioConverter the only way to preserve AAC stream continuity across segments and allow PCM-level processing?

If so, are there any working open source projects or sample implementations of this approach?

Any help or pointers would be greatly appreciated.

Answer*

Draft saved
Draft discarded
Cancel

default

AltStyle によって変換されたページ (->オリジナル) /