Skip to content

Fix HLS audio codec declared for FLAC and unknown codecs - #7852

Merged
Chocobozzz merged 2 commits into
Chocobozzz:developfrom
BgameB:fix-7784-hls-audio-codec
Nov 4, 2026
Merged

Chocobozzz merged 2 commits into
Chocobozzz:developfrom
BgameB:fix-7784-hls-audio-codec

Conversation

@baptiste-bcn

Copy link
Copy Markdown
Contributor

Fixes #7784

When the audio rendition isn't one of the four codecs PeerTube knows about, the master playlist currently claims it's AAC (mp4a.40.2). hls.js then sets up an AAC buffer, the real segments don't fit, and playback dies with bufferAppendError.

Two changes in getAudioStreamCodec():

  • FLAC, AC-3 and E-AC-3 now map to their proper codec strings (fLaC, ac-3, ec-3)
  • an unrecognised codec returns an empty string instead of a fake AAC one. CODECS is optional in HLS and hls.ts already filters empty values out, so the player gets to detect the codec itself rather than being told something wrong

Stock PeerTube only produces AAC, so this mainly matters for transcoding plugins that copy the source audio, which is how the issue was found.

I added a small unit test (server-helpers/ffmpeg-codecs.ts) covering the known mappings, an unknown codec and a file without audio. It fails on the current develop and passes with the fix.

If you'd rather keep AAC as the fallback, I can drop the second change and keep only the new mappings.

@Chocobozzz

Copy link
Copy Markdown
Owner

Thank you

@Chocobozzz
Chocobozzz merged commit 4b859fe into Chocobozzz:develop Nov 4, 2026
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HLS manifest declares mp4a.40.2 for any unrecognised audio codec, making the stream unplayable

2 participants