Skip to content

Direct URL playback unreliable — pipeline too fragile for CDN-hosted files #25

Closed

Description

@ohjey

What happened?

When I stream a video on Apple TV, I usually use VLC. I give it a direct URL to a video file — something like https://cdn.example.com/video.mkv — and it just plays. One connection, reads the data, shows the picture. If the connection hiccups, it picks back up. Simple.

I wanted to use AetherEngine instead because it handles HDR, Dolby Vision, Atmos — all the things VLC on tvOS can't do properly. Same direct URL, same video file. But AetherEngine doesn't play it directly.

Instead, AetherEngine does this:

  • It opens the URL and reads through the whole file via Range requests to figure out the structure
  • It re-packages everything into Apple's HLS-fMP4 streaming format
  • It starts a local HTTP server on 127.0.0.1 to serve the repackaged video
  • AVPlayer connects to the local server and plays from there

So instead of one connection from the player to the source, it's:
source → Range requests → demuxer → re-muxer → local server → AVPlayer

That means every frame gets read, rewritten, and served through an extra hop. It also means the source URL gets hit with many small Range requests instead of one big sequential read. And if any of those requests drops or the demuxer hits an unexpected EOF, the whole pipeline stops with no recovery.

I know this is by design — AetherEngine needs to wrap unsupported containers (MKV) into something AVPlayer can eat. That's fair. But for direct URLs, the current approach is fragile compared to VLC's "open once, read sequentially, reconnect on drop" model.

What I'd love to see:

  • A resilient AVIO reader that reconnects when a connection drops instead of treating it as terminal
  • Or a simpler "direct" mode for containers AVPlayer already supports natively (MP4, etc.)
  • At minimum: if the segment producer fails mid-stream, don't just let AVPlayer starve — retry or signal the host so we can reload

Right now I get about 21 seconds of playback before the pipeline gives up. VLC plays the same URL start to finish.

Steps to reproduce

Steps to reproduce:

  1. Create an AetherEngine instance
  2. Call load(url:) with a direct HTTP(S) URL to a large MKV file (~26GB, 2160p HEVC, hosted on a CDN)
  3. Call play()
  4. Observe: playback starts briefly, then stalls after ~20-30 seconds
  5. Check logs: segment producer finishes after 2 segments, File ended prematurely from matroska demuxer, CoreMediaError -15628 from AVPlayer
  6. Same URL in VLC: plays start to finish without issue

AetherEngine version or commit SHA

Version: 07ef617 (main branch, AetherEngine 2.0.0+)

Host app

Custom / my own integration

Platform

tvOS

OS version

tvOS 26.5

Device / chip

Apple TV 4K 3rd Gen (2022)

Playback path

Native AVPlayer

Source media (for playback bugs)

  • Container: MKV (video/x-matroska)
    • Video: HEVC 2160p, HDR10+
    • Audio: TrueHD 7.1 Atmos
    • Subtitles: PGS (multiple tracks)
    • Size: ~28.7 GB
    • Source: direct HTTPS URL (CDN-hosted)

Error codes / log lines

[AetherEngine] memprobe t=150s rss=100MB vmInt=25MB vmExt=37MB vmCmp=0MB vmIOS=0MB physFP=24MB mallocBlocks=249064 mallocMB=48 avioFetchedMB=117 cacheCount=7 cacheMB=90 packetsWritten=594 audioFifo=1264 abFifoKB=29 abSwrKB=0 abTotKB=29 muxBytesMB=0 muxCuts=0 srvConns=0 srvBytesMB=90 srvSfMB=89 pktAlive=0 pktTotal=58805 subCues=0 audioTracks=2 subTracks=36 subActive=false avBufAhead=0.1s avBufBehind=24.7s

Anything else

No response

Activity

  1. added
    bug
    on Jun 5, 2026
  2. DrHurt commented on Jun 5, 2026

    @DrHurt
    Contributor

    I’ve been helping Vincent optimise Sodalite for slow & fragile CDNs and it’s now blisteringly fast.

    superuser404notfound/Sodalite#12

    It’s literally the fastest Jellyfin client I’ve used, even faster than the official web client now.

    Aether Engine was gonna be my next target for slow CDN resilience but I wanted to give Vincent a little break from my posts :)

    I think you hit the nail on the head though.

    I think AVIO & segment producer could use some hardening & be more patient & persistent with slow CDNs and connection stutters.

  3. ohjey commented on Jun 5, 2026

    @ohjey
    Author

    Understood and glad it's a known issue. Whenever you guys can get around to fixing that that'll be great. Aether Engine seems to be perfect outside of that and for my use case it's almost pertinent to have it

  4. superuser404notfound commented on Jun 5, 2026

    @superuser404notfound
    Owner

    Thanks for the detailed report and logs, and DrHurt for pointing at the AVIO and segment producer as the place to harden.

    You diagnosed this exactly right: for a direct URL, AetherEngine was reading the source in discrete Range chunks, and any fetch failure (a dropped connection, a socket stall, or a CDN rate-limit) was collapsing into an end-of-file signal. The demuxer could not tell that apart from a real EOF, so the segment producer finalized and stopped, and playback starved a few segments later. The chunked request pattern also generated a lot of small Range requests, which is what was getting you rate-limited, worst of all while seeking.

    I reworked the playback read path to behave like VLC's "open once, read forward, reconnect on drop" model:

    • A single long-lived connection streams the file forward. During steady-state playback there are no extra requests at all; a new request is issued only on a real seek that lands outside the buffered window.
    • A dropped connection, a socket stall, or an early close now reconnects at the last byte delivered instead of ending playback. Only reaching the actual end of the file reports EOF.
    • 429 / 503 responses honour Retry-After and back off instead of giving up, and an expired signed URL re-resolves against the source.
    • There is a progress-aware cap so a genuinely dead or pathologically flapping origin stops rather than hammering the CDN forever, but a flaky-but-alive link keeps recovering for the whole playback.

    This is on main as of 2f2828a. Since you are on a custom integration, could you pull that and retry the same 28GB CDN-hosted MKV, including scrubbing/seeking around mid-file? The earlier "stops after ~2 segments / File ended prematurely" should be gone. If anything still stalls, the engine now logs [AVIOReader] Persistent ... lines on reconnect, so a console grab around the stall would tell us exactly where it gave up.

  5. ohjey commented on Jun 6, 2026

    @ohjey
    Author

    I tried it out and it seems to work well. However, the streaming process for mp4 files doesn't quite work for me. I wasn't able to get a log at the moment because I was in a rush, but I think it had something to do with how mp4 files worked versus MKV when it came to extracting the metadata for the video player, Such as time codes, etc., but if I come across it again I will drop a full log.

    But MKV worked perfectly so I guess that technically fixed the bug I was aiming to solve, thanks for such a quick turnaround time, and god bless Claude Code!

  6. DrHurt commented on Jun 6, 2026

    @DrHurt
    Contributor

    Really looking forward to trying this tomorrow! I suspect this will also improve video loading speed on my CDN (URL load to first frame on screen).

    Ps. I’ve never had any issues with any mp4 files! Try with other mp4 files (from other sources). If it’s a reproducible problem, might be worth opening a separate issue for it.

  7. ohjey commented on Jun 6, 2026

    @ohjey
    Author

    I’ve included the update in the app that I’m working on and I can confirm this has changed the game with how the CDN works with the Aether Engine! If I happen to have any issues with MP4‘s and can get a log I will definitely make a new ticket as for this one I would consider it fixed and done. Seems to work well.

  8. superuser404notfound commented on Jun 6, 2026

    @superuser404notfound
    Owner

    Glad it is working now! Thanks again for both of you testing and making this engine better and better!

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