Skip to content

HEVC progressive MP4 (VOD): loopback fMP4 remux emits an init that AVPlayer rejects — -12848, tracks count=0 #187

Closed

Description

@kskchaitanya1993

What happened?

A plain HEVC-in-MP4 progressive file (VOD) dispatched to the native/loopback path is demuxed and re-muxed to fMP4 by HLSVideoEngine, but the resulting loopback stream fails in AVPlayer with zero tracks built and a terminal open error:

asset.load(tracks) ok  count=0
item.status=failed  err=AVFoundationErrorDomain/-11829 'Cannot Open'
item.error.underlying=CoreMediaErrorDomain/-12848
item.presentationSize=(0.0, 0.0)   errorLog: 0 events   accessLog: 0 events

Crucially this is HEVC-specific to the progressive→fMP4 (VOD) remux:

So AVPlayer decodes HEVC-in-fMP4 happily; only the HLSVideoEngine VOD muxer's HEVC init/hvcC produces something it can't open. Both 8-bit (Main) and 10-bit (Main10/HDR10) fail identically.

Steps to reproduce

Generate the exact files (ffmpeg with libx265):

# 8-bit HEVC Main
ffmpeg -f lavfi -i testsrc=size=1280x720:rate=30 \
       -f lavfi -i sine=frequency=660:sample_rate=48000 -t 12 \
       -c:v libx265 -tag:v hvc1 -pix_fmt yuv420p \
       -c:a aac -movflags +faststart hevc.mp4

# 10-bit HEVC Main10 / HDR10 (fails identically)
ffmpeg -f lavfi -i testsrc=size=1280x720:rate=30 \
       -f lavfi -i sine=frequency=660:sample_rate=48000 -t 12 \
       -pix_fmt yuv420p10le -color_primaries bt2020 -color_trc smpte2084 -colorspace bt2020nc \
       -c:v libx265 -tag:v hvc1 \
       -x265-params "hdr10=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc" \
       -c:a aac -movflags +faststart hevc_hdr.mp4

Serve over plain HTTP (any static server with Range + HEAD) and load the .mp4 URL through AetherEngine on a device with nativeRemoteHLS:false (i.e. let it demux+remux). AVPlayer fails to open the loopback with -12848 / tracks=0.

AetherEngine version or commit SHA

5.17.0

Host app

Sodalite

Platform

tvOS

OS version

tvOS 26.5

Device / chip

Apple TV 4K (3rd gen, AppleTV14,1)

Playback path

Native AVPlayer

Source media (for playback bugs)

No response

Error codes / log lines

[AetherEngine] load url=…/vod-mp4-hevc.mp4 source-format=sdr effective-format=sdr rate=30.000
[VTProbe] canHardwareDecode codec=173 1280x720 -> true (status=0)
[AetherEngine] dispatch: codec=173 → native
[HLSVideoEngine] video codecpar: codec=173 1280x720 profile=1 level=93 fieldOrder=1 extradata=2433B head=0101600000009000
[HLSVideoEngine] audio: codec=aac → stream-copy as `mp4a.40.2`
[HLSVideoEngine] prepared: codec=hvc1.2.4.L93,mp4a.40.2 resolution=1280x720 fps=30.000 range=SDR DV=none segments=3 duration=12.0s
[HLSSegmentProducer] init.mp4 captured (3686 B)
[HLSSegmentProducer] pump finished: reason=eof packetsRead=924 packetsWritten=360 lastError=0 cacheCount=3
[NativeAVPlayerHost] #1 load url=http://127.0.0.1:60098/media.m3u8
[NativeAVPlayerHost] #1 asset.load(tracks) ok count=0
[NativeAVPlayerHost] #1 item.status=failed err=AVFoundationErrorDomain/-11829 'Cannot Open'
[NativeAVPlayerHost] #1 item.error.underlying=CoreMediaErrorDomain/-12848


(For the 10-bit file the only differences are `profile=2 … extradata=2557B head=0102200000009000` and `range=PQ`; same `count=0` / `-11829` / `-12848` outcome.)

Anything else

Expected

The HEVC progressive MP4 plays on the loopback path, exactly as the H.264 progressive MP4 and the TS→fMP4 HEVC (live) cases do.

Notes / hypothesis

  • The source hvcC extradata looks well-formed (head=0101600000009000 = configurationVersion 1, profile_idc Main). The failure appears to be in how the VOD fMP4 init segment carries the HEVC sample entry / hvcC (the HLSLiveIngestReader path writes a working one from the same codec, so the two muxers diverge).
  • -12848 with tracks=0 and empty error/access logs = AVPlayer rejected the init before fetching media — consistent with a malformed/hvcC-less HEVC sample description in init.mp4.
  • Reproduced deterministically via a public test-bed that plays every codec/container through the ladder; happy to share the generator + server if useful.

Activity

  1. added
    bug
    on Jul 21, 2026
  2. DrHurt commented on Jul 21, 2026

    @DrHurt
    Contributor

    I think this is related to the issue I've run into here:
    superuser404notfound/AetherPlayer#2

    It's a regression in the engine that happened a little over 2 weeks ago.

  3. added a commit that references this issue on Jul 22, 2026
  4. superuser404notfound commented on Jul 22, 2026

    @superuser404notfound
    Owner

    Fixed in 5.18.3.

    Root cause: libx265 embeds a large user-data SEI_PREFIX (NAL type 39) array in the hvcC config record. The VOD/loopback muxer copied the source codec parameters verbatim, so that array reached the init.mp4 sample description. Apple TV builds the HEVC format description straight from the hvcC parameter-set arrays and rejects a record carrying a non-parameter-set array, which is the tracks count=0 / -11829 / -12848 open failure. macOS and the tvOS Simulator both tolerate it (they build the track and reach readyToPlay), so it only reproduces on the actual hardware decoder. That is also why H.264 (avcC never carries SEI arrays), the TS -> fMP4 live remux, and direct fMP4-HLS were all fine: only the VOD path forwarded the source hvcC as-is, and only Apple's hardware path validates it strictly.

    The fix canonicalizes the HEVC config record before write_header, keeping only the VPS/SPS/PPS arrays and dropping the SEI (and any other) NAL arrays, so the VOD init now matches the canonical form the live and direct paths already produce. HDR10 static metadata and Dolby Vision signaling live outside the hvcC and are untouched. Verified end-to-end that the emitted init.mp4 hvcC drops to VPS/SPS/PPS only (8-bit Main 2433 B -> 112 B; 10-bit HDR10 2554 B -> 115 B with the colr PQ/BT2020 box preserved) and both remain independently decodable.

    One caveat worth flagging: since the rejection could not be reproduced off-device (both macOS and the tvOS 26.5 Simulator accept the SEI-laden init), a retest on the Apple TV 4K against 5.18.3 through the exact same nativeRemoteHLS:false ladder would be very welcome to confirm the hardware now accepts the canonical init. Thanks for the precise report and the deterministic test-bed.

  5. superuser404notfound commented on Jul 22, 2026

    @superuser404notfound
    Owner

    Reopening: 5.18.3 ships the fix, but this stays open for the on-device retest (the rejection only reproduces on Apple TV hardware, not macOS or the tvOS Simulator). Will close once verified on an Apple TV 4K.

  6. kskchaitanya1993 commented on Jul 22, 2026

    @kskchaitanya1993
    Author

    On-device retest, Apple TV 4K (3rd gen), tvOS 26.5, vendored 5.18.3, through the exact nativeRemoteHLS:false loopback ladder.

    Result: the canonicalization runs and matches your off-device verification exactly — but the hardware still rejects the init.

    [AetherEngine] dispatch: codec=173 → native
    [HLSVideoEngine] video codecpar: codec=173 1280x720 profile=1 level=93 fieldOrder=1 extradata=2433B head=0101600000009000
    [HLSVideoEngine] canonicalized hvcC (stripped non-parameter-set NAL arrays): 2433 B → 112 B (AE#187)
    [HLSVideoEngine] prepared: codec=hvc1.2.4.L93,mp4a.40.2 resolution=1280x720 fps=30.000 range=SDR DV=none segments=3
    [NativeAVPlayerHost] asset.load(tracks) ok url=http://127.0.0.1:PORT/media.m3u8 count=0
    [NativeAVPlayerHost] item.status=failed err=AVFoundationErrorDomain/-11829 'Cannot Open'
    [NativeAVPlayerHost] item.error.underlying=CoreMediaErrorDomain/-12848
    [NativeAVPlayerHost] item.loadedTimeRanges.count=0
    ladder: aether rung failed (engine_error) → VLC
    

    So the fix produces exactly the canonical record you verified (2433 → 112 B, VPS/SPS/PPS only), but the Apple TV hardware still rejects the resulting init.mp4 with the same -11829/-12848 / count=0. On this hardware the SEI_PREFIX array was not the (complete) cause — something else in the emitted init is being rejected.

    Source characteristics (deterministic test-bed asset):

    • HEVC, 8-bit Main, L3.1, yuv420p, 1280×720, 30 fps, SDR, progressive (fieldOrder=1 = AV_FIELD_PROGRESSIVE).
    • Source hvcC arrays before canonicalize: numOfArrays=4 → VPS(32), SPS(33), PPS(34), SEI_PREFIX(39) — i.e. exactly the target case. After canonicalize: VPS/SPS/PPS only (112 B).

    The count=0 at asset.load(tracks) on the canonical init suggests the hardware rejects the fMP4 sample entry / init structure itself, not the parameter-set arrays (those are now identical to what the fMP4-HLS path — which works — produces). Happy to share the exact deterministic .mp4 for a clean repro, or dump the emitted init.mp4 (hvcC bytes + the hvc1 sample-entry / stsd and any colr/taps/edit-list boxes) if that helps isolate what the hardware objects to. It reproduces every time on this ATV.

  7. superuser404notfound commented on Jul 22, 2026

    @superuser404notfound
    Owner

    Thanks, this is a decisive retest. It rules the SEI array out as the complete cause: 5.18.3 does exactly what it claims (the hvcC drops to 112 B, VPS/SPS/PPS only, the canonical record), and the hardware still rejects the init. So the fix was necessary but not sufficient, and your read is right: the rejection is in the init sample entry, not the parameter-set arrays.

    Here is where I have got to, and what would let me close it.

    The VOD remux path copies the source hvcC header verbatim (bytes 0..21: profile/tier/level, chroma_format, bit depths, min_spatial_segmentation_idc, parallelismType, avgFrameRate, and the reserved-bit fields), then rewrites only the trailing NAL-array section. The two paths you confirmed working never do this: the MPEG-TS live remux and the direct fMP4-HLS path both get an hvcC that FFmpeg (or the origin server) rebuilds from the parameter sets, so their header is always in FFmpeg's canonical form.

    That header turns out to be muxer-dependent in practice. Muxing the same HEVC bitstream with FFmpeg versus MP4Box already yields different config-record header bytes (for example parallelismType 0 vs 3). So if your source file was written by a muxer that sets one of those header fields to a value Apple TV's format reader rejects, the VOD path is the only path that forwards it unchanged: macOS and the Simulator tolerate it, the device does not. That matches every observation you reported (H.264 fine, since avcC has a much smaller header with no equivalent fields; HEVC-in-TS and direct fMP4-HLS fine, since their hvcC is rebuilt; HEVC VOD only; device only).

    I could not reproduce it locally because my libx265 test asset is FFmpeg-muxed, so its header is already canonical and both macOS and the Simulator accept it. To confirm or rule this out I need your exact bytes. Two things would nail it:

    1. The exact deterministic .mp4 you offered (a link is perfect). With it I can run it through the loopback path, dump the emitted init, and diff its config-record header against a rebuilt one.
    2. If you would rather not share the file: the 23-byte source config-record header plus which muxer produced the file. For example:
      python3 -c "d=open('SOURCE.mp4','rb').read(); i=d.find(b'hvcC'); sz=int.from_bytes(d[i-4:i],'big'); print(d[i+4:i-4+sz][:23].hex())"
      
      Your log shows the first 8 bytes (0101600000009000); it is bytes 8..21 I cannot see, and those are exactly the muxer-written header fields.

    The init dump you offered is still very welcome as a second data point: the emitted init.mp4 hvcC plus the full hvc1 sample entry (stsd, and any colr/fiel/pasp/btrt boxes) as the device receives it.

    If this pans out, the fix is to stop copying the source header verbatim on the VOD path and rebuild a canonical config record from the parameter sets, the same shape the live and direct paths already emit.

  8. kskchaitanya1993 commented on Jul 22, 2026

    @kskchaitanya1993
    Author

    Here are the exact bytes — and a twist: the source is FFmpeg-muxed with a fully canonical header, so a non-canonical muxer header doesn't explain this file. I think that narrows it toward the emitted init / device path.

    23-byte source config-record header (hvcC bytes 0..22):

    0101600000009000000000005df000fcfdf8f800000f04
    

    Parsed:

    • configurationVersion=1, profile_space=0, tier=0, profile_idc=1 (Main), level_idc=93 (L3.1)
    • general_profile_compatibility_flags=0x60000000, general_constraint_indicator=0x900000000000
    • min_spatial_segmentation_idc=0, parallelismType=0, chromaFormat=1 (4:2:0), bitDepth 8/8
    • avgFrameRate=0, constantFrameRate=0, numTemporalLayers=1, temporalIdNested=1, lengthSizeMinusOne=3
    • numOfArrays=4 → VPS(32)/SPS(33)/PPS(34)/SEI_PREFIX(39) (the array 5.18.3 strips)

    Muxer / encoder: FFmpeg — Lavf62.12.102 container, Lavc62.28.102 libx265 video. So bytes 8..21 you couldn't see (00 00 00 00 5d f0 00 fc fd f8 f8 00 00 0f) are the standard FFmpeg values: parallelismType=0, chromaFormat=1, bitDepth 8/8. This is exactly the canonical header you described — and yet the device rejects the emitted init after the SEI is stripped.

    Two implications from that:

    1. Since our source header is already canonical FFmpeg, the "source muxer wrote a bad header field" cause doesn't fit this file. The rejection is more likely in what the VOD loopback emits — the hvc1 sample entry / stsd / init box layout — rather than the header it copies.
    2. Worth a quick check on your side: your own FFmpeg-muxed asset was confirmed only on macOS + the Simulator, which tolerate it. If you have an Apple TV 4K, running that same asset on the device is the fastest test — if it also -12848s, this is purely device + emitted-init, independent of the source file.

    Exact reproduction of the byte-identical asset (test-bed generator; repeat-headers=1 is what puts the SEI_PREFIX in the hvcC):

    ffmpeg -f lavfi -i testsrc2=size=1280x720:rate=30 -f lavfi -i sine=frequency=440 -t 12 \
      -c:v libx265 -tag:v hvc1 -x265-params keyint=48:min-keyint=48:repeat-headers=1 \
      -pix_fmt yuv420p -b:v 1200k -c:a aac -shortest vod-mp4-hevc.mp4
    

    I'll also work on dumping the emitted init.mp4 off the device (the loopback binds 127.0.0.1, so it needs a small capture hook) and post the hvcC + full hvc1 sample entry + stsd/colr/fiel/pasp/btrt as the device actually receives it. Glad to share the real .mp4 via a link too if that's easier than regenerating. Thanks for digging into this so thoroughly.

  9. superuser404notfound commented on Jul 22, 2026

    @superuser404notfound
    Owner

    Decisive retest, thank you. I reproduced your test-bed asset byte for byte (the repeat-headers=1 is what puts the SEI_PREFIX in the hvcC; the source config-record header comes out exactly as you posted, 0101600000009000...5df000fcfdf8f800000f04), ran it through the loopback, and dumped the emitted init. Your read was right on both counts: the emitted hvcC is a clean canonical record (VPS/SPS/PPS only, header byte-identical to what ffmpeg/GPAC write), and the rejection is not in the parameter-set arrays. So 5.18.3 was necessary but not sufficient, and since your file is already fully canonical FFmpeg, the source-header theory doesn't fit it.

    What it actually is turned out to be in the routing, not the muxer:

    1. SDR HEVC was routed media-direct (a bare media.m3u8, no master). Media playlists carry no CODECS attribute, so on that path the device gets no HEVC codec signaling at all. Apple TV HW happily builds an H.264 track from a bare media playlist plus init, but for HEVC it needs the codec advertised in a master's EXT-X-STREAM-INF CODECS; without it the item fails with tracks count=0 / -11829 / -12848 before any media fetch. macOS and the Simulator build the HEVC track straight from the init hvcC on the media-direct path, which is exactly why neither reproduces it. This lines up with everything you saw: H.264 through the same media-direct path is fine (its track builds without a declared codec), while the HEVC paths that worked (live TS remux, direct fMP4-HLS) do not take this SDR media-direct route.

    2. Separately, the plain-HEVC CODECS string was hardcoded to hvc1.2.4.L<level> (Main10) for every non-DV HEVC, so an 8-bit Main source was mis-declared as Main10. Once HEVC is signaled through a master, a strict device would reject that Main10 claim against the Main hvcC in the init. It now derives the RFC 6381 string from the actual hvcC profile_tier_level, so your asset advertises hvc1.1.6.L93.90 (matching MP4Box/ffmpeg) instead of hvc1.2.4.L93.

    The fix routes tvOS HEVC through a master with the correct CODECS (iOS and macOS keep media-direct, which already works for them). It is on branch fix/ae187-hevc-master-codec-signaling, commit 3d75cf6. I could not reproduce the failure or confirm the fix off-device (macOS and the Simulator accept the media-direct init either way), so an on-device retest against that commit through the same nativeRemoteHLS:false ladder would be the decisive check: does the Apple TV now build the track and play, instead of dropping to VLC? Full suite is 953/953 and the tvOS-sim build is green.

    Thanks again for the byte-level data and the deterministic repro. It made this findable.

  10. kskchaitanya1993 commented on Jul 22, 2026

    @kskchaitanya1993
    Author

    Retested on-device against 3d75cf6 (branch fix/ae187-hevc-master-codec-signaling), Apple TV 4K (3rd gen), tvOS 26.5, through the nativeRemoteHLS:false ladder. Prebuilt + linked that exact commit.

    The fix is applied and correct — but the device still rejects it. It does not build the track / play; it still drops to VLC.

    The routing change works exactly as designed — it now serves a master with the correct CODECS:

    [HLSVideoEngine] prepared: codec=hvc1.1.6.L93.90,mp4a.40.2 ...     <- correct RFC 6381 (was hvc1.2.4.L93 Main10)
    [HLSVideoEngine] serving on http://127.0.0.1:PORT/master.m3u8
    [HLSLocalServer] master.m3u8 body:
      #EXT-X-STREAM-INF:BANDWIDTH=5000000,CODECS="hvc1.1.6.L93.90,mp4a.40.2",RESOLUTION=1280x720,FRAME-RATE=30.000,VIDEO-RANGE=SDR,...
      media.m3u8
    

    And AVPlayer does progress further than the media-direct path did — it fetches the full chain:

    GET /master.m3u8  →  GET /media.m3u8  →  GET /init.mp4  →  GET /seg0.mp4
    

    But it still fails:

    item.status=failed AVFoundationErrorDomain/-11829 'Cannot Open'
    item.error.underlying=CoreMediaErrorDomain/-12848
    item.tracks count=1
      item.tracks[0] mediaType=soun fourCC=<no fdesc> enabled=false
    loadedTimeRanges.count=0  →  ladder: aether rung failed → VLC
    

    So the decisive detail: with the master + correct CODECS, the device now enumerates one track — but it's the audio placeholder (mediaType=soun, fourCC=<no fdesc>, enabled=false), and no HEVC video track is built at all. The item opens no further and errors with the same -11829/-12848.

    That means the master-CODECS signaling, while correct and worth keeping, was not the device cause either. The Apple TV hardware rejects the emitted HEVC fMP4 init itself — the same init you dumped off-device and confirmed is a clean canonical record. So this is a device-specific rejection of a canonical init that macOS + the Simulator accept, deeper than both the hvcC arrays and the CODECS signaling.

    Where that leaves it: H.264 fMP4 fine, HEVC-in-TS live remux fine, direct fMP4-HLS fine — all confirmed. HEVC VOD via the loopback fMP4 init is the only failing path, device-only. Since your off-device init dump is byte-identical to what the device receives (same engine muxer), the difference has to be something the device's HEVC format reader validates in the hvc1 sample entry / init that macOS doesn't. If it would help, I'm happy to add a capture hook and pull the exact init.mp4 the device fetched (hvc1/stsd + colr/fiel/pasp/btrt) so you can diff it against a known-good device-played HEVC fMP4 (e.g. the direct fMP4-HLS init that works). Thanks for chasing this so hard — genuinely appreciate it.

  11. superuser404notfound commented on Jul 22, 2026

    @superuser404notfound
    Owner

    Thank you for the decisive on-device retest of 3d75cf6. It nailed down exactly what the master signaling did and did not fix, and it pointed straight at the last piece.

    What your retest proved: the master + correct CODECS was necessary but not sufficient. Media-direct gave count=0 and did not fetch the chain (Apple TV will not build an HEVC track from a bare media playlist with no CODECS; WWDC 2017 session 504 puts it plainly: HEVC must be marked with the CODECS attribute in the master playlist). With the master, the device fetched the full chain and built the audio track, but the HEVC video track still did not build. So the rejection was never the parameter-set arrays or the codec string; it is the emitted init itself, exactly as you called it.

    Root cause: the emitted HEVC init has no edit list

    I reproduced your asset byte for byte (the source config-record header comes out 0101600000009000...5df000fcfdf8f800000f04 as you posted), ran it through the loopback, and diffed the emitted init.mp4 against an FFmpeg fMP4-HLS init of the same content, which is the "direct fMP4-HLS" shape you confirmed plays on the device. After eliminating everything else, one semantic difference remains:

    • SEI_PREFIX in the hvcC: ruled out by your own A/B. Pre-5.18.3 (SEI present) failed; 5.18.3 (SEI stripped) failed; and the device-known-good FFmpeg init actually keeps a 2316 B SEI_PREFIX and plays. Not it.
    • btrt box and media timescale: present/identical in the device-known-good FFmpeg init too. Not it.
    • Edit list (edts/elst): FFmpeg's init carries a codec-delay edit list on the video track (an empty edit of the reorder delay, then media_time = the delay in media timescale). Our engine init has none.

    Our VOD muxer runs use_editlist=0 on purpose (so the init's moov stays restart-invariant and each fragment carries its position in tfdt, rather than AVPlayer replaying a stale EXT-X-MAP elst after a mid-stream producer restart, which caused lipsync drift in earlier fixes). The side effect: no edts is emitted at all. macOS and the Simulator build the HEVC track from the sample entry regardless; the device's HEVC track builder needs the presentation timeline that the edit list establishes for reordered (B-frame) content, and without it builds no video track.

    Fix

    Commit d12e2ee on branch fix/ae187-hevc-master-codec-signaling (on top of the master/CODECS commit, so both are in the build). It splices a canonical codec-delay edit list into the video track after muxing, reproducing FFmpeg's two-entry shape, without touching any muxer flag. The moov stays restart-invariant because the delay is a codec property (the first video packet's pts - dts), not a session position. Non-HEVC and non-positive-delay inits are forwarded unchanged.

    Verified locally: the emitted HEVC init now carries an elst whose media_time matches FFmpeg's device-known-good value byte for byte; the init plus segments still decode in isolation (segverify 3/3); the H.264 init is untouched (no edts); full suite 960/960. But since macOS and the Simulator accept the init either way, the decisive check is on-device.

    Would you be able to retest against d12e2ee through the same nativeRemoteHLS:false ladder? The question is whether the Apple TV now builds the HEVC video track and plays, instead of the audio-only count=1 / -11829 drop to VLC. If it still fails, your offered capture of the exact init.mp4 the device fetched (hvc1/stsd plus colr/fiel/pasp/btrt) would be the perfect next data point to diff against the FFmpeg init that plays. Thanks again for the byte-level rigor on this one.

  12. kskchaitanya1993 commented on Jul 22, 2026

    @kskchaitanya1993
    Author

    Retested d12e2ee on-device — still fails (audio-only count=1, mediaType=soun fourCC=<no fdesc>, -11829/-12848 → VLC). So I added a debug hook that grabs the exact loopback artifacts the device fetched (the loopback binds 127.0.0.1, so this is the only way to see them) and diffed the init against an FFmpeg fMP4-HLS init of the byte-identical source. I found the one remaining difference.

    First, all three of your fixes ARE present in the device-fetched init — confirmed byte-for-byte:

    • Canonical hvcC: …00000f03 (numOfArrays=3, VPS/SPS/PPS only, SEI stripped).
    • Master + CODECS: CODECS="hvc1.1.6.L93.90".
    • Edit list: elst [(seg=66, mt=-1), (seg=0, mt=1024)] — identical to FFmpeg's (I generated an FFmpeg fMP4-HLS init of the same source; the elst, hvcC[0:22], pasp, btrt, tkhd, mdhd, trex all match byte-for-byte). The edit list was correct.

    The full box diff turns up exactly one structural difference:

    The engine init emits an empty sdtp box in the video stbl; FFmpeg omits it.

    Engine video stbl:  stsd, stts, sdtp, stsc, stsz, stco
    FFmpeg video stbl:  stsd, stts,       stsc, stsz, stco
    

    The engine's box is 0000000c 73647470 00000000 — a 12-byte sdtp with 0 sample entries. But this is a fragmented init: the video stsz/stco/stts are all entry_count=0 (samples live in the moofs). An sdtp (per-sample dependency flags) describing zero samples in the moov is anomalous.

    Working theory that fits every observation: Apple TV's HEVC track builder validates sdtp against the (empty) sample table and rejects the init; macOS + the Simulator ignore the stray box. It's HEVC-only in practice because the H.264 init doesn't carry this sdtp, and it's device-only because only the hardware format reader is strict about it. That lines up with H.264-fine / HEVC-in-TS-fine / direct-fMP4-HLS-fine (none emit this sdtp in a fragmented init) / HEVC-VOD-only.

    Likely fix: don't write sdtp into the fragmented init's moov (it belongs per-fragment in the traf/sbgp for fragmented content, if at all).

    I have the exact device-fetched init.mp4 (1413 B), master.m3u8, media.m3u8, and seg0.mp4 — happy to attach any of them. And if a control would help, I can serve my FFmpeg init through the same loopback ladder on the device to confirm it plays where the engine init doesn't. Thanks for sticking with this — the sdtp was hiding in plain sight.

  13. superuser404notfound commented on Jul 22, 2026

    @superuser404notfound
    Owner

    Great catch on the sdtp, and thank you for building the capture hook. That kind of byte-level diff off the loopback is exactly what made this findable.

    Before wiring a strip I reproduced against it, and the result is worth flagging because it points somewhere unexpected.

    I served the byte-identical repro asset (libx265 -tag:v hvc1 ... repeat-headers=1) through the real engine loopback (HLSVideoEngine to HLSSegmentProducer to MP4SegmentMuxer), against the pinned FFmpegBuild 2.2.0, and byte-inspected the exact /init.mp4 the endpoint serves. There is no sdtp box in it (a raw search for 73647470 comes back empty). The video stbl is stsd, stts, stsc, stsz, stco, matching the FFmpeg init.

    The reason is structural in movenc (n8.1.2, which 2.2.0 ships). Our init is a fragmented empty_moov init, and mov_write_trak_tag explicitly zeroes track->entry before writing the stbl when empty_moov is set (the "pretend that no samples have been written yet" path). mov_write_sdtp_tag is only emitted when track->has_disposable && track->entry, so with entry forced to 0 the box cannot be written. Separately, the repro asset carries no disposable-flagged frames at all, so has_disposable is never set either. Two independent reasons the box should not exist.

    So the sdtp you captured on device cannot come out of a clean d12e2ee build linked against FFmpegBuild 2.2.0. The most likely explanation is a stale transitive dependency in the build env: Xcode caching an older FFmpegBuild in DerivedData/SourcePackages and not re-resolving it after the AetherEngine commit bump. That would leave the Swift-side fixes (canonical hvcC, master CODECS, edit list, all confirmed present in your capture) intact while the muxer itself is a different FFmpeg.

    Two things would settle it:

    1. The exact device-fetched init.mp4 (1413 B) you offered. With your bytes next to mine I can diff the full box tree, not just the one box, and see everything that differs.
    2. Your resolved FFmpegBuild revision from Package.resolved (it should read 2.2.0 / e832f22). If it is older, a clean re-resolve (delete SourcePackages under DerivedData, resolve again) may make the sdtp disappear on its own.

    Independent of where the box originates, I will add a version-independent guard in the init normalization that strips any zero-sample sdtp from the video stbl after capture. It operates on the emitted init bytes, so it neutralizes the box regardless of which FFmpeg wrote it and reproduces the known-good FFmpeg layout exactly. Your init.mp4 lets me confirm it targets your precise structure. It will land on fix/ae187-hevc-master-codec-signaling.

    And yes, please do run your FFmpeg init through the same loopback ladder on the device. If it plays where the engine init does not, that isolates it to the init bytes and is a perfect control.

  14. kskchaitanya1993 commented on Jul 22, 2026

    @kskchaitanya1993
    Author

    You were right to push on the build env, and the byte-level ask paid off — but the culprit is one layer over from where we both looked. My app never links FFmpegBuild at all. It's linking AetherEngine's FFmpeg against a different, older FFmpeg entirely.

    What I verified (twice, on the exact artifacts that shipped to the device):

    • The vendored AetherEngine.xcframework I build via the SwiftPM prebuild is code-only: its libAetherEngine-dev.a has 0 movenc symbols (nm | grep mov_write_ = 0). FFmpeg is not baked in — the symbols are undefined, resolved at app link time.
    • The only FFmpeg in the app's link is a leftover FFmpegBridge.xcframework from a mediabridge experiment I removed — and it's FFmpeg 7.1.5 (FFmpeg version 7.1.5, libavformat 61), carrying all 74 mov_write_* symbols including mov_write_stbl_tag.
    • There is no FFmpegBuild reference in the app project at all (0 hits in project.pbxproj). The Package.resolved pin of ffmpegbuild 2.1.3 I'd have quoted you is vestigial — a relic of an old SPM-based integration that the vendored-binary setup no longer uses. So quoting it would have sent you down the wrong 2.1.3-vs-2.2.0 path.

    So the init on my device is written by FFmpeg 7.1.5's movenc, not 2.2.0's n8.1.2. That lines up exactly with your empty_moov analysis: the newer n8.1.2 path zeroes track->entry and drops the sdtp; 7.1.5 still emits it. Your control (byte-identical repro through the real loopback on 2.2.0 → no sdtp) and my capture (same structure, + sdtp, on 7.1.5) converge on the FFmpeg version as the sole variable.

    The captured init (1413 B, md5 a279dbf378bb73d1e6ea1753b567365e) — full box tree is ftyp / moov[mvhd, trak(video)[tkhd, edts/elst, mdia…stbl[stsd, stts, **sdtp(12B, 0 entries)**, stsc, stsz, stco]], trak(audio)[… stbl with NO sdtp], mvex[trex,trex], udta]. base64 below so you can diff the full tree against yours:

    init.mp4 base64 (decode: `base64 -D`)
    AAAAHGZ0eXBpc281AAACAGlzbzVpc282bXA0MQAABWltb292AAAAbG12aGQAAAAAAAAAAAAAAAAAAAPoAAAAAAABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAACjXRyYWsAAABcdGtoZAAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAFAAAAAtAAAAAAADBlZHRzAAAAKGVsc3QAAAAAAAAAAgAAAEL/////AAEAAAAAAAAAAAQAAAEAAAAAAfltZGlhAAAAIG1kaGQAAAAAAAAAAAAAAAAAADwAAAAAAFXEAAAAAAAtaGRscgAAAAAAAAAAdmlkZQAAAAAAAAAAAAAAAFZpZGVvSGFuZGxlcgAAAAGkbWluZgAAABR2bWhkAAAAAQAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAABZHN0YmwAAAEMc3RzZAAAAAAAAAABAAAA/Gh2YzEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAFAALQAEgAAABIAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY//8AAAB4aHZjQwEBYAAAAJAAAAAAAF3wAPz9+PgAAA8DoAABABhAAQwB//8BYAAAAwCQAAADAAADAF2VmAmhAAEAK0IBAQFgAAADAJAAAAMAAAMAXaACgIAtFllZpJMrwFoCAAADAAIAAAMAPBCiAAEAB0QBwXK0YkAAAAAKZmllbAEAAAAAEHBhc3AAAAABAAAAAQAAABRidHJ0AAAAAAAIu6YACLumAAAAEHN0dHMAAAAAAAAAAAAAAAxzZHRwAAAAAAAAABBzdHNjAAAAAAAAAAAAAAAUc3RzegAAAAAAAAAAAAAAAAAAABBzdGNvAAAAAAAAAAAAAAG/dHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAABW21kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAu4AAAAAAVcQAAAAAAC1oZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU291bmRIYW5kbGVyAAAAAQZtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAMpzdGJsAAAAfnN0c2QAAAAAAAAAAQAAAG5tcDRhAAAAAAAAAAEAAAAAAAAAAAABABAAAAAAu4AAAAAAADZlc2RzAAAAAAOAgIAlAAIABICAgBdAFQAAAAAB8wYAAfMGBYCAgAURiFblAAaAgIABAgAAABRidHJ0AAAAAAAB8wYAAfMGAAAAEHN0dHMAAAAAAAAAAAAAABBzdHNjAAAAAAAAAAAAAAAUc3RzegAAAAAAAAAAAAAAAAAAABBzdGNvAAAAAAAAAAAAAABIbXZleAAAACB0cmV4AAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAIHRyZXgAAAAAAAAAAgAAAAEAAAAAAAAAAAAAAAAAAABhdWR0YQAAAFltZXRhAAAAAAAAACFoZGxyAAAAAAAAAABtZGlyYXBwbAAAAAAAAAAAAAAAACxpbHN0AAAAJKl0b28AAAAcZGF0YQAAAAEAAAAATGF2ZjYxLjcuMTAz
    

    My fix: link AetherEngine against the FFmpegBuild 2.2.0 (n8.1.2) it's actually built for, and drop the stale mediabridge 7.1.5 lib. I'm doing that now and will re-capture on device to confirm the sdtp disappears — I'll post the before/after. Your version-independent strip guard is still worth landing as defense-in-depth (it'd have neutralized this regardless of my mislink), but on my end this was self-inflicted by a leftover framework, not anything in d12e2ee. Sorry for the detour toward the SPM pin — glad the sdtp capture was still the thread that unravelled it.

  15. superuser404notfound commented on Jul 22, 2026

    @superuser404notfound
    Owner

    That is a definitive root cause, thank you for running it all the way down (and for the nm on the vendored archive, which is what actually settled it). A leftover FFmpegBridge.xcframework at 7.1.5 resolving the mov_write_* symbols is a clean, complete explanation.

    I decoded your base64 and diffed it against my loopback init. They are byte-for-byte identical except for two things: the sdtp (your 12 B / zero-entry box between stts and stsc, absent in mine) and the writer tag (Lavf61.7.103 vs Lavf62.12.102). So the FFmpeg version really is the sole variable. The guard that suppresses a zero-sample sdtp in a fragmented empty_moov init (mov_write_stbl_tag only emits it when track->has_disposable && track->entry, and track->entry is forced to 0 for the init) is present in the 8.1.2 movenc that FFmpegBuild 2.2.0 ships and not in your 7.1.5, which is exactly why your init carried the box and mine does not.

    The version-independent strip has landed as defense-in-depth, on fix/ae187-hevc-master-codec-signaling (72e48d1): it removes any zero-sample video sdtp from the captured init, so a stray box from a mislink like this can never reach the device again. On a correct 2.2.0 link there is no box to strip, so it is a no-op.

    Once you drop the 7.1.5 lib and link the FFmpegBuild the engine is built against, the sdtp is gone. Combined with the master-CODECS signaling (which is spec-mandated for HEVC regardless of this, WWDC 2017 session 504), the item should build the video track and play instead of dropping to audio-only. Really looking forward to your before/after on the corrected link, and thanks again for the byte-level rigor start to finish.

  16. kskchaitanya1993 commented on Jul 22, 2026

    @kskchaitanya1993
    Author

    Confirmed and fixed on my side — and it was exactly the stale-FFmpeg mislink, not your code.

    What I removed: the leftover FFmpegBridge.xcframework (FFmpeg 7.1.5) was -force_loaded into the app's OTHER_LDFLAGS (a relic of a removed in-app FFmpeg experiment). -force_load pulls in all of its symbols, so 7.1.5's movenc flat-shadowed the vendored FFmpegBuild 2.2.0 that AetherEngine is built against. Dropped it entirely.

    Verified after the fix (on the Apple TV 4K):

    • ooooo.debug.dylib now links @rpath/Libavformat.framework current version 62.12.102 (FFmpegBuild 2.2.0 / FFmpeg 8.x) — no more 7.1.5.
    • The HEVC-in-MP4 VOD that used to reject now plays on AetherEngine's loopback: AETHER PLAYING backend=native, 0 × -11829/-12848, 0 VLC fallback (it was -11829 → VLC before). With 2.2.0's movenc the init carries no sdtp, so the device accepts it.

    On your 72e48d1b sdtp strip: I bumped my vendored engine to it and it builds clean. Since 2.2.0 no longer writes the zero-sample sdtp, your strip has nothing to remove in my setup now — but it's the right belt-and-suspenders for any integrator who links an older FFmpeg the way I accidentally was, so it's a good defensive addition regardless. Thanks again for the movenc empty_moov/entry walkthrough — your byte-identical 2.2.0 control is what made it obvious the FFmpeg version was the only variable, which pointed me straight at my own link.

    Net: #187 reproduces only against pre-8.x FFmpeg; on the intended 2.2.0 it's clean. Really appreciate your patience through the wrong turns.


    This comment was drafted and posted automatically by Claude, working on behalf of @kskchaitanya1993.

  17. superuser404notfound commented on Jul 22, 2026

    @superuser404notfound
    Owner

    Shipped in AetherEngine 5.18.7, and thank you again for running this all the way to the linker. The device-verified AETHER PLAYING backend=native with zero -11829/-12848 is exactly the outcome to close on.

    The release keeps the two parts that earned their place:

    • the master-playlist HEVC signaling with a CODECS string derived from the actual hvcC (so the manifest and the init always agree), and
    • the zero-sample sdtp strip, as defense-in-depth for precisely the mislink you hit: an integrator who -force_loads an older FFmpeg over the vendored build gets its init neutralized rather than rejected.

    One change from the 72e48d1 tip you vendored: I dropped the codec-delay edit-list injection I'd spliced in mid-investigation. That was chasing the wrong hypothesis (a missing edts), the on-device retest of it was red, and the real remaining difference was the sdtp from the shadowing FFmpeg. The shipping init has no edts (the same shape every prior release used), so the released engine is simpler than the branch you tested, with the same relevant fixes. If you re-pin to 5.18.7 you should see the identical clean playback.

    Consumers are on 5.18.7. Appreciate the byte-level rigor start to finish.

  18. rrgomes commented on Jul 22, 2026

    @rrgomes
    Contributor

    Apple TV 4K verification of the 5.18.7 routing change, plus one correction to the root cause.

    You flagged the #187 work as device-only and unverified on Apple TV, so here is a hardware pass on 5.18.7 from a four-box tvOS fleet. The routing code below is unchanged as of 5.19.1, so these observations are current rather than stale.

    The forced-master path works. Two SDR HEVC sources on Apple TV 4K 3rd gen, both now served through a master, both playing normally:

    prepared: codec=hvc1.2.2.H153.90,fLaC resolution=3840x2160 fps=23.976 range=SDR DV=none
    serving on http://127.0.0.1:57056/master.m3u8 (... useMaster=true videoRange=sdr dvVariant=none)
    item.videoTrack codec='hvc1' enabled=true dim=3840x2160 primaries=ITU_R_709_2 (readyToPlay)
    

    (4K HEVC Main10 SDR bt709, 23.976 fps, FLAC, MKV, 5033 s; and a 1440x1080 HEVC Main10 SDR with AC-3 and two SRT tracks, 1518 s, same shape.)

    The CODECS derivation is a bigger correctness win than the commit claims. The 4K source above is High tier. The old hardcode would have declared hvc1.2.4.L153; the derived string is hvc1.2.2.H153.90. That is wrong in three places at once rather than just the profile: compatibility flags (4 against 2), tier (L against H), and the absent constraint byte. The tier error seems worth calling out separately, since a High-tier stream declared as Main tier is exactly the kind of mismatch a strict decoder could reject.

    But the stated root cause does not generalize. On this same 5.18.7 build, HEVC still routes media-direct wherever the routing judges a master unsafe, and Apple TV builds the video track from the bare media playlist without complaint:

    serving on .../media.m3u8 (... panelIsHDR=false ... useMaster=false videoRange=pq dvVariant=none)
    item.videoTrack codec='hvc1' enabled=true dim=3840x2160 transfer=SMPTE_ST_2084_PQ (readyToPlay)
    

    That is 4K HEVC Main10 PQ on an Apple TV 4K 3rd gen with the panel not yet in HDR mode. The same holds for 4K HEVC DV Profile 7 and DV Profile 8.1 on an Apple TV 4K 2021 driving an SDR panel, both useMaster=false, both readyToPlay, all three playing normally.

    So on at least two Apple TV 4K generations, HEVC does build a track from a bare media playlist plus init. The general claim in the commit message and changelog, that Apple TV needs the codec advertised in a master's CODECS for HEVC, is not what this hardware shows.

    A better-fitting explanation is already in the same release. 5.18.7 also strips the zero-sample sdtp, and the reporter was -force_loading FFmpeg 7.1.5 over the vendored build, whose movenc writes that box into the empty_moov init. An init Apple TV rejects yields tracks count=0 / -12848 before any media fetch, which is the reported symptom, and it would do so from a master or a media playlist alike. The issue title itself points at the init rather than the manifest.

    Worth asking the reporter whether the sdtp strip alone resolves it with media-direct routing restored. If so, the forced master could be narrowed. The blast radius on our side is admittedly small, since the forcing only moves SDR HEVC (HDR HEVC on a ready panel already routed master, and on an unready panel routing safety still keeps it media-direct), and we have now verified that path on device. But it is a routing change for every tvOS consumer resting on a premise our fleet contradicts.

  19. kskchaitanya1993 commented on Jul 22, 2026

    @kskchaitanya1993
    Author

    Reporter here — glad to confirm the init reading, since it matches what I traced end to end.

    On my Apple TV 4K the blocker was precisely the zero-sample sdtp in the fragmented HEVC init, and the cause on my side was self-inflicted: a stray -force_load of an older FFmpeg (7.1.5), left over from a component I'd since removed, was shadowing the vendored FFmpegBuild 2.2.0 at link time — and 7.1.5's movenc writes that sdtp into the empty_moov init. Re-aligning the link so the muxer is actually 2.2.0 (which omits the box) restored HEVC playback on device: AETHER PLAYING backend=native, zero -11829/-12848, no manifest change involved. So @rrgomes's reading tracks my evidence — it was the init Apple TV was rejecting, not the master CODECS.

    Two honest caveats so I don't overstate it:

    • I hit this on the reroute/loopback fMP4 init specifically. Separately, the CODECS-derived-from-hvcC change is a real correctness win on its own — a High-tier stream advertised as Main-tier is a genuine mismatch — so narrowing the forced master wouldn't affect that part.
    • I can't cleanly A/B "sdtp strip alone + media-direct" against "forced master," because whether the loopback serves a master or a bare media playlist (useMaster) is decided inside the engine, not something I can toggle from the host side. So I can confirm "remove the sdtp → HEVC plays," but not independently prove media-direct-plus-strip is sufficient without an engine-side way to pin that path. If there's a knob to force useMaster=false for a test, I'm happy to run it on device and report back.

    Thanks to you both — that's a really thorough multi-box verification.


    Auto-generated by Claude.

  20. rrgomes commented on Jul 22, 2026

    @rrgomes
    Contributor

    Correction to my previous comment, and the media-direct A/B that @kskchaitanya1993 could not run.

    First, I overstated my evidence. The two SDR HEVC sources I cited as demonstrating the forced-master path were both on an Apple TV 4K 3rd gen driving a Dolby Vision panel, and on that device the forcing is a no-op: sourceIsHDR = videoRange != .sdr || effectiveDvMode, so a DV-capable panel sets effectiveDvMode=true and inflates sourceIsHDR even for SDR content, after which the pre-existing sourceIsHDR && panelReadyForHDR already returns true. Those items would have served a master on any recent version. I checked rather than assumed this time: pinning 5.18.6 and replaying the same title on that box still gives useMaster=true, with the old hardcoded hvc1.2.4.L153 in the same line confirming the version. My apologies for the noise.

    The forcing does change routing on a non-DV device, and there it verifies cleanly. On an Apple TV 4K 2021 driving an SDR panel every other input is false, so useMaster=true can only come from videoCodecNeedsMasterSignaling. Same 4K HEVC Main10 SDR source, same box, only the engine version differing:

    5.18.6:  serving on .../media.m3u8  (dvModeAvailable=false effectiveDvMode=false panelIsHDR=false
                                         displaySupportsHDR=true sourceIsHDR=false useMaster=false videoRange=sdr)
             prepared: codec=hvc1.2.4.L153,fLaC
             item.videoTrack codec='hvc1' enabled=true dim=3840x2160 primaries=ITU_R_709_2 (readyToPlay)
             GET /seg0.mp4 ... /seg7.mp4, playing normally, seeks fine
    
    5.19.1:  serving on .../master.m3u8 (same inputs, useMaster=true)
             prepared: codec=hvc1.2.2.H153.90,fLaC
             item.videoTrack codec='hvc1' enabled=true (readyToPlay)
    

    Both play. So media-direct HEVC does build a video track on Apple TV 4K hardware, provided the init is correct, which on our side it always is: we link FFmpegBuild 2.2.0 alone with no vendored FFmpeg, so the sdtp box is never written and 5.18.6 lacking the strip does not matter. Combined with @kskchaitanya1993 confirming that realigning his link fixed his device with no manifest change, the master CODECS signaling does not look like what resolved #187.

    @kskchaitanya1993, on the knob: you do not need one. Pinning 5.18.6, the release immediately before this change, gives the media-direct arm with identical host code, which is how the run above was produced.

    One more honest data point about the CODECS string. On the DV-panel box, 5.18.6 served a master advertising the old hardcoded hvc1.2.4.L153 for a stream that is actually High tier, and Apple TV played it without complaint. So while deriving the string from the hvcC is plainly more correct, and I still think the tier error is the most interesting part of it, I have no device evidence that the mis-declaration alone causes a rejection. That weakens the second half of the original diagnosis too.

    Net suggestion, offered with the caveat that you have far more consumers than our fleet: the forcing appears to buy nothing on DV-panel devices, where the master was already in use, and on non-DV devices the media-direct path works. Narrowing or reverting it looks safe on this evidence, while keeping the sdtp strip and the derived CODECS string.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions