Skip to content

Query-wrapped MPEG-TS segment URLs are rejected before AE#268 can admit a finite HEVC HLS VOD #733

Closed

Description

@qoli

What happened?

AetherEngine 7.33.2 fails to open a valid finite HLS VOD when each segment is served through an outer endpoint whose path has no media extension and whose query contains the actual MPEG-TS path.

Example shape:

https://media.example/api/ts?url=https%3A%2F%2Forigin.example%2Fsegment-001.ts

The outer endpoint returns a valid MPEG-TS body containing HEVC video and AAC audio. The outer URL and query are required for authorization; directly requesting the nested URL is refused.

FFmpeg's HLS extension check evaluates the outer segment URL. Because /api/ts has no accepted transport extension, it rejects the segment with AVERROR_INVALIDDATA before AetherEngine can produce the typed HLS classification that normally reaches the AE#268 seekable TS-to-fMP4 ingest. The relevant FFmpeg gate is in test_segment:

https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/hls.c#L3513-L3534

RFC 8216 defines a media segment by its URI and body; it does not require the URI path to end in .ts:

https://www.rfc-editor.org/rfc/rfc8216.html#section-3

Steps to reproduce

Serve a finite direct-media playlist such as:

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.0,
https://media.example/api/ts?url=https%3A%2F%2Forigin.example%2Fsegment-001.ts
#EXT-X-ENDLIST

Have the outer endpoint return an MPEG-TS segment whose PMT identifies HEVC with stream type 0x24.

Then load the playlist using:

let options = LoadOptions(
    httpHeaders: requiredHeaders,
    isLive: false,
    nativeRemoteHLS: false,
    autoplay: false
)

try await engine.load(
    url: playlistURL,
    startPosition: nil,
    options: options
)

On unmodified 7.33.2, direct Aether playback fails during source open:

AVERROR_INVALIDDATA (-1094995529)
backend not established

Downstream diagnostic result

A narrow experimental admission path was added without changing the segment transport.

On a physical Apple TV it recorded:

queryWrappedOnly=true
segments=120
queryWrappedSegments=120
duration=1203.28s
carriage=hevc_in_mpegts
AE#268 event=taken

This proves that:

  • the playlist is finite and resolvable;
  • the URL shape is correctly recognized;
  • the first segment body is HEVC-in-MPEG-TS;
  • the existing AE#268 ingest can accept the source once the extension gate is bypassed safely.

A later segment-fetch failure is a separate transport issue and should not be folded into QueryWrapped admission.

Expected behavior

Before the generic FFmpeg URL opener rejects the source, AetherEngine should perform a narrow, bounded admission check for an explicit finite HLS playlist:

  • recognize an outer segment path without a known media extension when a query value contains a conventional MPEG-TS path;
  • confirm the actual body is MPEG-TS and its PMT carries HEVC;
  • preserve the complete outer URL, query, redirects, and HTTP headers;
  • route the source through the existing AE#268 seekable TS-to-fMP4 ingest;
  • never unwrap and directly request the nested URL;
  • avoid globally disabling FFmpeg's extension safety check.

The following sources must retain their current behavior:

  • ordinary .ts segment URLs;
  • query values naming non-transport media;
  • live/DVR playlists;
  • encrypted or fMP4 playlists;
  • H.264, audio-only, unreachable, or ambiguous sources.

This issue should not introduce a QueryWrapped-specific downloader, timeout, concurrency model, buffer, or HTTP-version policy. Those belong to the underlying HLS transport layer.

AetherEngine version or commit SHA

7.33.2 / e7afcfad3973426a6ffff31fc111f6b1e5078061

Host app

Custom integration using SyncnextHybrid's diagnostic smoke player.

Platform

tvOS, physical Apple TV 4K.

Playback path

Source open before backend selection; expected destination is the AE#268 seekable HLS VOD ingest.

Related issue

#268 implements the destination ingest path. This report covers an earlier admission gap that prevents query-wrapped segments from reaching it.

Activity

  1. qoli commented on Oct 10, 2026

    @qoli
    ContributorAuthor

    Companion issue #732 tracks the persistent HTTP/1.1 HLS transport policy. This issue is intentionally limited to QueryWrapped recognition and admission into the existing AE#268 ingest.

  2. superuser404notfound commented on Oct 11, 2026

    @superuser404notfound
    Owner

    Thanks for the detailed report. I tried to reproduce this on both the reported tag and current main, and on this engine a query-wrapped segment URL reaches the AE#268 ingest without any extra admission step. So the failure you saw must come from somewhere other than the segment URL shape, and I'd like to find where before changing anything.

    Why FFmpeg's test_segment gate should not be on this path

    FFmpegBuild is built with --disable-network, so libavformat's HLS demuxer never fetches a playlist or a segment in AetherEngine. A URL load goes like this:

    1. AVIOReader opens the URL, sees an #EXTM3U body (by content, not by extension) and throws the typed hlsPlaylistOnVODPath.
    2. load() catches that and calls HLSVODIngestReader.makeIfHEVCMPEGTS, which parses the playlist itself, resolves the first segment URI as written (outer URL, query and headers intact), and classifies that segment's PMT.
    3. On hevcInMPEGTS it reloads on the ingest. Nothing in that chain looks at the segment path's extension.

    What I ran

    A local origin serving the 120-segment long-GOP HEVC fixture (10 s segments, one IRAP per segment) only through /api/ts?url=https%3A%2F%2Forigin.example%2Fseg000.ts, with every other path answering 403, so a direct request for the nested URL would show up in the log. Then aetherctl play --seek-every 12 --seek-count 1 --seek-pattern 600:

    build playlist URL result
    7.33.2 (e7afcfad) /media.m3u8 AE#268: finite HEVC-in-MPEG-TS HLS, segments=120 duration=1200.04s, seek to segment 57, VERDICT: OK
    7.33.2 /api/playlist?id=42 (no extension) same
    main (60f5cc9e) /media.m3u8 same

    The nested URL was never requested directly (0 denied requests).

    One variant does behave differently: when the outer endpoint refuses the probe's Range: bytes=0-… request with 403, the log shows [HLSVODIngest] carriage probe inconclusive: playlistUnreachable(403) and the load falls back to the AE#154 native bypass. That is still not AVERROR_INVALIDDATA, but it is the kind of shape I'd look at next.

    What would pin it down

    • The complete engine log for one failing load, from the load() call to the error. The [AVIOReader], [AetherEngine] AE#154 / AE#268 and [HLSVODIngest] lines say which step stopped.
    • Whether the load really goes through engine.load(url:), or through a .custom source / reader built in SyncnextHybrid. A custom source cannot be rerouted (there is no playlist URL to ingest from), and that is exactly where an m3u8 body ends in AVERROR_INVALIDDATA.
    • The status line, headers and first few bytes of the playlist response, and whether the outer /api/ts endpoint answers a Range request (200, 206, or a refusal).
    • The diff of your experimental admission path, so I can see which check it actually bypassed.

    "backend not established" is not an engine string, so I assume it comes from the host; the line just before it in the engine log will be the useful one.

    I'll keep this open until the log shows where it fails.

  3. qoli commented on Oct 11, 2026

    @qoli
    ContributorAuthor

    Thanks for checking this on both 7.33.2 and main. I went back through the original device run, host log, and downstream diff. There are two corrections to my original report, followed by the production behavior that still needs explaining.

    Corrections to the original report

    You are right about the upstream call chain and --disable-network. I confirmed that our pinned FFmpegBuild also has --disable-network. The historical evidence does not establish that FFmpeg test_segment saw the outer segment URL, so the issue body states that causal attribution too strongly. The downstream result proves that an early content-backed check can admit this source into AE#268; it does not by itself prove which upstream check was bypassed.

    Also, the failing build was based on tag 7.33.2 / e7afcfad, but it was not a completely pristine checkout: it carried our pre-existing downstream patches 0001, 0002, and 0004, while the QueryWrapped patch 0005 was absent. I should not have called that “unmodified 7.33.2”. None of those earlier patches implements QueryWrapped admission, but this distinction matters for reproduction.

    What the failing run actually did

    This was not a .custom source. The physical-device smoke host constructs LoadOptions(httpHeaders: ..., autoplay: false) and calls engine.load(url:options:) directly:

    https://github.com/qoli/SyncnextHybrid/blob/2b029f9/Examples/HybridSmokePlayer/Sources/SmokeViewModel.swift#L331-L364

    Immediately before launching the same source identity with the same required header, a preflight against the playlist URL returned:

    Range request: bytes=0-0
    HTTP 200
    Content-Type: application/x-mpegURL
    Body size: 41,218 bytes
    First bytes: #EXTM3U
    

    In other words, this playlist endpoint ignored the range and returned the complete valid playlist. A fresh outer segment endpoint from that playlist separately answered a bounded range correctly:

    HTTP/1.1 206 Partial Content
    Content-Range: bytes 0-65535/6808608
    Cache-Control: no-store
    

    The direct Aether run then produced this on a physical Apple TV (tvOS 26.6):

    2026-10-10T11:31:34Z run_started
    mode=aetherEngine
    header_names=User-Agent
    
    2026-10-10T11:31:42Z run_failed
    aether_backend=none
    aether_current_avplayer=absent
    error_code=aether_source_load_failed
    message="AetherEngine source load failed: HLSVideoEngine: open failed
             (Demuxer: open failed
             (Invalid data found when processing input (-1094995529)))"
    

    backend not established in the original issue is indeed host wording, not an engine log line.

    The historical devicectl --console capture unfortunately contains only the two smoke events above; it did not retain the [AVIOReader], AE#154 / AE#268, or [HLSVODIngest] lines you asked for. I therefore cannot honestly present that historical capture as the complete engine log.

    What the downstream experiment changed

    The relevant part of the downstream diff is here:

    https://github.com/qoli/SyncnextHybrid/blob/2b029f9/Patches/AetherEngine/0005-query-wrapped-hls-segment-ingest.patch#L1-L61

    It calls the bounded HLSVODIngestReader classification before the normal probe/open path, but only for an explicit finite .m3u8 / .m3u URL whose segments have the QueryWrapped shape and positive HEVC-in-MPEG-TS evidence. On the real source it recorded:

    queryWrappedOnly=true
    segments=120
    queryWrappedSegments=120
    duration=1203.28s
    carriage=hevc_in_mpegts
    AE#268 event=taken
    

    This narrows the unexplained difference to the path before that early check. Given your reproduction and the source code, the better question is now:

    Why did this physical-tvOS URL load fail to surface hlsPlaylistOnVODPath for a valid #EXTM3U response, while a direct bounded playlist/segment check on the same source succeeded?

    Your local-origin fixture establishes that QueryWrapped segment URLs alone are not sufficient to cause the failure. It does not reproduce the production origin / physical-tvOS response behavior above. The later HTTP/1.1 connection-affinity failure occurs only after admission and remains separate under #732; I am not asking #733 to absorb that transport policy.

    I will treat the test_segment explanation as withdrawn unless a new pristine-tag run proves it. The next useful artifact is exactly what you requested: a fresh run on pristine 7.33.2 with the full engine log from load(url:) through the terminal error, including [AVIOReader], AE#154 / AE#268, [HLSVODIngest], response status, and the playlist prefix. That will distinguish an AVIOReader classification/open problem from an ingest probe or host integration problem without guessing from the final AVERROR_INVALIDDATA.

  4. superuser404notfound commented on Oct 13, 2026

    @superuser404notfound
    Owner

    Thanks for the corrections and the preflight, that last detail was the missing piece. I can now reproduce your exact error on current main, and it has nothing to do with the segment URL shape.

    What reproduces it

    A playlist response that is a 200 without a known length (chunked, or no Content-Length at all). Same local origin as before (/api/playlist?id=42, segments only via /api/ts?url=...), only the playlist framing varied:

    playlist response before
    200, Content-Length set, Range ignored routes through AE#268, VERDICT: OK
    206 honouring Range same
    200, Content-Encoding: gzip same
    200, Transfer-Encoding: chunked LOAD FAILED: HLSVideoEngine: open failed (Demuxer: open failed (Invalid data found when processing input (-1094995529)))
    200, no length header, connection-close same failure

    So a 200 that ignores Range is fine on its own. The engine asks bytes=0-33554431, and a complete 41 KB body with a length is a valid answer to that. The length is what matters.

    Why

    Without a length, the ranged open's 200 cannot be told apart from an origin that ignores ranges, so the DMX-101 guard hangs up at the head and the open continues forward-only on one unranged GET. The AE#154 #EXTM3U check only looked at the persistent window, which that path leaves empty. FFmpeg then got the playlist as container bytes, hence AVERROR_INVALIDDATA. Your 0005 patch avoided this because it classified the playlist before the reader ever opened, which is why it looked like a QueryWrapped admission problem.

    Fix

    398fc5b0 on fix/ae733-playlist-on-forward-only-open runs the same classification on the first bytes of the forward-only stream. With it, the chunked and length-less variants log HLS playlist body on the forward-only open (AE#733), route through AE#268 (segments=120), and seek to segment 57 with VERDICT: OK. The other variants are unchanged. There is a regression test, and the full suite is green.

    To confirm this is your origin's shape: does the playlist response carry a Content-Length header (curl -sD - -o /dev/null -H 'Range: bytes=0-33554431' <playlist url>)? If it is chunked or has no length, this is the fix, and pristine main plus 398fc5b0 should play the source without patch 0005.

  5. qoli commented on Oct 16, 2026

    @qoli
    ContributorAuthor

    Verified fixed on the original ONE reproduction on 2026-10-16, using a physical Apple TV 4K (AppleTV6,2), tvOS 26.6, and HybridSmokePlayer in direct aetherEngine mode.

    Candidate and source

    • AetherEngine 7.36.0, c6365cc3c8850bdb670654ca26dcd21f73670875, with FFmpegBuild 3.7.1.
    • Downstream patch 0005 was absent, including both its early admission and persistent-HTTP/1.1 changes. Our existing patches 0002/0004 were retained to compile the hybrid smoke host, so this was not a completely pristine engine tree. AVIOReader and the relevant ingest/probe/transport files were byte-identical to official 7.36.0.
    • The current ONE plugin configuration and scripts were fetched again, and its actual Player() supplied the URL and required headers. The original outer segment URLs were preserved. Local verification first obtained HTTP 200 for the playlist and complete first segment and decoded both video and audio.
    • The playlist still has no Content-Length: 120 finite query-wrapped MPEG-TS segments, HEVC 3840x2160 + AAC, duration 1203.284 s.
    • The Query-wrapped MPEG-TS segment URLs are rejected before AE#268 can admit a finite HEVC HLS VOD #733 control kept heldSourceConnection at its default false. The explicit HLS VOD needs an explicit persistent HTTP/1.1 transport policy with cross-segment connection reuse #732 policy was tested separately.

    The physical-device log now shows the forward-only HLS playlist body ... (AE#733) classification, followed by AE#268 and segments=120 duration=1203.28s.

    Control result: PASS

    Run 52b937b0-5dcf-4060-97a9-b38fe2c03048:

    Check Result
    Backend / video native / 3840x2160
    Startup progress 2.000 s
    Seek target / landing 10.000 / 9.880 s
    Landing error 0.120 s
    Strict post-seek progress 2.020 s
    Progress after seek at terminal PASS 12.120 s
    Native video Different actual scenes at 58 s and 68 s, still playing

    One earlier attempt reached the corrected classification/ingest path but then hit NSURLError -1001 during source reading. A diagnostic replay and then the same original signed binary, with the same URL/headers and no transport or timeout changes, passed. The precise transient-timeout cause remains unproven; I am not attributing it to the playlist classification or HTTP/2.

    The original #733 reproduction is resolved without patch 0005. Closing as completed. The separate #732 protocol/reuse acceptance is reported there. Signed URLs and header values remain private.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions