Skip to content

[bug] HLS copy remux of MPEG-TS with AAC audio fails after the first segment #2840

Closed

Description

@Quick104

What happened

An HLS remux that copies both video and AAC audio from an MPEG-TS source fails after the first segment. MPEG-TS carries AAC in ADTS framing, and the fMP4 segments the HLS muxer writes can't hold ADTS. FFmpeg stops on the first audio packet:

[mp4 @ <redacted address>] Malformed AAC bitstream detected: use the audio bitstream filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg)
[aost#0:1/copy @ <redacted address>] Error submitting a packet to the muxer: Operation not permitted
[out#0/hls @ <redacted address>] Error muxing a packet

FFmpeg exits with status 255 after writing init.mp4 and a partial first segment.

#2698 fixes the same failure in the progressive fMP4 remux. The HLS copy path in internal/playback/transcode.go has the same problem and is not part of that PR.

Steps to reproduce

Not reproduced on a deployment. It was reproduced by running the arguments the server builds:

  1. Make an MPEG-TS file with H.264 video and AAC audio: ffmpeg -f lavfi -i testsrc2=size=160x90:rate=25 -f lavfi -i sine=frequency=440:sample_rate=48000 -t 8 -c:v libx264 -g 25 -c:a aac -ac 2 s.ts
  2. Build the HLS arguments with buildFFmpegArgs for TranscodeOpts{TargetCodecVideo: "copy", TargetCodecAudio: "copy", SourceVideoCodec: "h264", SegmentDuration: 2, AudioTrackIndex: -1} with that file as input.
  3. Run FFmpeg with those arguments. They select -hls_segment_type fmp4 because copyVideoUsesFMP4 is true. FFmpeg 6.1.1 fails with the error above.

The planner chooses this path for an HLS remux that keeps the source audio (plan_v3.go, HLS remux with TargetAudioCodec: "copy"). Jellycompat sessions with HLSRemuxMPEGTS set write MPEG-TS segments and are not affected.

Expected behavior

An HLS copy remux of an MPEG-TS file with AAC audio writes playable fMP4 segments, with -bsf:a aac_adtstoasc added for a copied AAC track.

Silo version / commit

main at a7594d8

Deployment

Not deployment-specific. Found by running FFmpeg locally with the arguments the server builds.

Clients affected

Any client the planner sends to an HLS remux with copied video and audio for an MPEG-TS source. Not checked per client.

Relevant logs

FFmpeg output above. No server logs available.

Technical notes

  • aac_adtstoasc rejects any codec other than AAC, so the filter has to depend on the copied track's codec and can't apply to every copy. In the HLS path, TargetCodecAudio is "copy" and doesn't say which codec is copied. fix(playback): play MPEG-TS files with AAC audio over the web remux #2698 adds a copied-audio-codec field (CopyAudioCodec, token claim cac) for the progressive remux. This fix should follow that PR and reuse the field so remote nodes get the codec too.
  • The filter passes AAC that is already raw (MKV, MP4) through unchanged.

AI harness

Claude Code in T3 Code

AI tool(s)

Claude Code

AI model(s)

claude-opus-5-5

AI involvement

Found and reproduced by an AI reviewer while reviewing #2698. A human has not verified it.

Independent or adversarial review

None for this issue.

Confirmations

  • I searched open and recently closed issues and pull requests, and this is not already reported
  • I reproduced this myself on a real deployment
  • Any logs provided are raw apart from marked redactions and are not AI-summarized; if none were available, I said so above

Source: found in review of #2698

Activity

  1. added
    bug
    on Oct 21, 2026
  2. added
    impact: playback
    priority: P1
    on Oct 21, 2026
  3. added a commit that references this issue on Nov 9, 2026
    13aa54f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugimpact: playbackpriority: P1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions