Repository navigation
Description
Thanks for AetherEngine — the FrameExtractor scrub-preview work is excellent for local/SMB/Jellyfin sources. This is a feature request for the one source class where trickplay stills currently can't work: single-connection HTTP links (debrid resolves and torrent-cache streams).
Summary
FrameExtractor extracts stills by opening a second, fully independent FFmpeg demuxer against the source URL. For sources that only grant one connection (debrid direct links, torrent-cache tokens, expiring/one-shot URLs), that second open is refused or hands back a dead/expiring link, so thumbnail(at:) returns nil forever — even though playback is perfectly fine on the single held connection.
Net user impact: scrub-preview thumbnails are permanently blank for debrid/torrent playback, the single most common way host apps stream.
Where it happens
For a plain URL source (engine.load(url:)), makeFrameExtractor() takes the guard let url = loadedURL branch (AetherEngine+FrameExtractor.swift:64-66) and builds a FrameDecodeContext(url:httpHeaders:). Its openInternal() opens a second demuxer against the same URL:
demuxer.open(url:extraHeaders:profile:.stillExtraction) // FrameDecodeContext.swift:105-111
The extractor is documented as "fully isolated from playback (no contact with the HLS loopback server or shared engine state)" (FrameExtractor.swift:4-8) — by design it targets reusable, multi-connection sources (local files, SMB via a second cursor on one connection, Jellyfin/Emby). That assumption doesn't hold for debrid/torrent tokens, which allow exactly one live connection.
Two failure modes, same root cause
- Second connection refused —
[FrameExtractor] open failed(fromensureOpen/openInternalthrowing atdemuxer.open(url:), logged aroundFrameExtractor.swift:143) →image=nil. - Second connection opens but serves garbage —
[FrameExtractor] miss … image=nil(FrameExtractor.swift:155-161): open succeeds, but the source hands back a truncated / one-shot / expiring body over the second connection, so no frame decodes.
Both trace to the same thing: reaching for a connection the source won't grant.
The irony: the bytes are usually already on disk
For H.264/HEVC sources — i.e. most debrid/torrent releases — the engine already defaults to the native path (AetherEngine.swift:1409-1421, useSoftwarePath=false), which remuxes through HLSSegmentProducer → SegmentCache over the single playback connection. So the exact bytes for a still near the playhead have already been fetched and validated. FrameExtractor just declines to read them for VOD and instead opens a connection the source will reject.
There's already a working precedent for cache-backed stills
The live path proves cache-backed stills need no second connection. AetherEngine.liveScrubThumbnail(atSessionSeconds:maxWidth:) (AetherEngine+Live.swift:7-37) decodes a preview still entirely from already-produced DVR bytes:
HLSVideoEngine.liveScrubThumbnailSource(atSeconds:)(HLSVideoEngine.swift:1344-1353)- reads
provider.liveThumbnailSegment(atSeconds:)(VideoSegmentProvider.swift:267-277) +peekInitSegment()(VideoSegmentProvider.swift:280-282) - concatenates
initData + segData - hands raw bytes to
FrameExtractor(reader: DataIOReader(data:), formatHint: "mp4")(AetherEngine+Live.swift:29)
No URL is ever reopened — the still comes from SegmentCache files on disk via cache.peekURL(index:), with a 2-entry LRU keyed by segmentIndex and guarded by loadGeneration against zap/stop.
There is no VOD equivalent today, purely because the entry points are live-gated: liveScrubThumbnailSource hard-guards isLiveSession (HLSVideoEngine.swift:1348) and liveThumbnailSegment hard-guards isLive (VideoSegmentProvider.swift:268). Yet every primitive underneath already works for VOD:
- VOD native sessions build the same
providerwith a populatedsegmentstable. segmentIndex(forPlaylistTime:)has a working non-live branch (VideoSegmentProvider.swift:548-555).SegmentCache.peekURL/peek/fetch/fetchInitare path-agnostic.- VOD sessions get a byte-budgeted retention budget (
HLSVideoEngine.swift:763-766→vodRetentionBudgetBytes, 2 GiB / quarter-of-free) specifically so produced segments survive back-seeks.
So the producer already retains fetched bytes for VOD — a still could be decoded from them with zero second connection.
Proposed fix (a VOD twin of the live path)
-
HLSVideoEngine.vodScrubThumbnailSource(atSeconds:) -> (data: Data, segmentIndex: Int)?— mirrorliveScrubThumbnailSource(HLSVideoEngine.swift:1344) for the non-live session. Resolve the index via the existing VODprovider.segmentIndex(forPlaylistTime:)(VideoSegmentProvider.swift:548), or add a pure, non-side-effectingvodThumbnailSegment(atSeconds:)twin ofliveThumbnailSegment(VideoSegmentProvider.swift:267) that does a plaincache.peekURL(index:)lookup with nohandleTargetChange/restart (unlikemediaSegmentURL(at:)at:301, which triggers restarts). Readcache.peekURL(index:)+peekInitSegment(), concatinit + seg, returnnilon a cache miss (segment not yet produced, or evicted past the 2 GiB budget). -
AetherEngine.vodScrubThumbnail(atSeconds:maxWidth:)— mirrorliveScrubThumbnail(AetherEngine+Live.swift:7). Gate on a native VOD session, call the source fn on a detached queue, reuse theliveThumbnailExtractorsLRU pattern (AetherEngine.swift:307) feedingFrameExtractor(reader: DataIOReader(data:), formatHint: "mp4"),loadGeneration-guarded. -
Best: one unified
scrubThumbnail(atSeconds:maxWidth:)that transparently serves fromSegmentCachewhen a native session (live or VOD) has the segment resident, and only falls back to a second-connectionFrameExtractorfor non-cache-backed sources (software path / forward-only / cache miss). Host apps then call a single API and get cache-backed stills for free on debrid.
Engine types this reads, all existing: HLSVideoEngine (nativeVideoSession), VideoSegmentProvider (segments, segmentIndex(forPlaylistTime:), peekInitSegment), SegmentCache (peekURL(index:)), DataIOReader, FrameExtractor(reader:formatHint:).
Why this fixes both failure modes
The cache-backed path never opens a second connection at all — it decodes init + seg bytes already produced over the single playback link via DataIOReader. So there's nothing to reject (fixes mode 1), and the bytes are known-good muxed fMP4 the producer already validated (fixes mode 2). The only residual is a genuine cache miss (segment evicted past the 2 GiB budget, or not yet produced far ahead of the playhead) — which returns nil cleanly and is the correct "not available yet," easily handled host-side with a visible degrade.
Fallback ask (if the full VOD path isn't feasible soon)
At minimum, surface an open-failure signal so hosts can degrade deterministically. Today the host only sees thumbnail(at:) return nil and can't distinguish "second connection refused" from "not ready yet" from "decode miss" — so it can't decide between "retry," "hide the preview permanently," or "show a placeholder." An error/reason on the failure (or a supportsScrubThumbnails-style capability probe for the current source) would let hosts hide the scrub-preview affordance up front on single-connection sources instead of showing a blank frame.
Repro
- Load a debrid/torrent direct HTTP link as a plain URL source (
engine.load(url:)) — a single-connection token, e.g. a Real-Debrid/AllDebrid resolve or a torrent-cache stream. H.264/HEVC so it takes the native path. - Start playback (succeeds — engine holds the one allowed connection).
- Call
thumbnail(at:)/ the scrub-preview API for any position. - Observe it return
nilfor every position while playback continues fine.
I can attach an on-device log stream --predicate 'eventMessage CONTAINS "FrameExtractor"' capture showing [FrameExtractor] open failed (mode 1) or [FrameExtractor] … miss … image=nil (mode 2). Enabling FrameExtractor's verbose software-playback logs on the device will confirm which line fires, though no part of the proposed fix depends on knowing — the cache-backed path removes the second connection either way. I'm also happy to put together an aetherctl repro if that's the most useful form.
Thanks for considering this — the live path already demonstrates the whole mechanism, so a VOD twin feels close at hand, and it would make trickplay work for the majority of real-world streaming sources.
Activity
refactor(scrub): VOD-capable thumbnail segment lookup (#106)
refactor(scrub): generalize live thumbnail source + extractor LRU for…
feat(scrub): cache-backed VOD scrub stills for single-connection sour…
superuser404notfound commentedon Jul 6, 2026
Fixed on
main(9612657), and pinned into Sodalite. Thank you for the writeup, it was genuinely a pleasure to work from. Pointing at the live DVR path as the working precedent, with the exact file:line trail frommakeFrameExtractor()down throughliveScrubThumbnailSource->liveThumbnailSegment->cache.peekURL, meant the diagnosis was already done. The VOD twin fell out almost exactly as you sketched.What shipped
A unified, cache-backed API that decodes stills from already-produced
SegmentCachebytes over the single playback connection, never opening a second demuxer:AetherEngine.scrubThumbnail(atSeconds:maxWidth:) async -> CGImage?— serves the active native session, live or VOD, straight from cache.secondsis the session-timeline axis for live and playlist/output seconds for VOD. Returnsnilon a cache miss (segment not yet produced far ahead of the playhead, or evicted past the retention budget), which is the correct "not available yet."AetherEngine.vodScrubThumbnail(atSeconds:maxWidth:)— the VOD arm, exposed for symmetry.AetherEngine.supportsCacheBackedStills: Bool— the capability probe you asked for in the fallback section. True when a native session (live or VOD) is active, false on the software path or before load. Gate the scrub-preview affordance on it: single-connection source plustruemeans callscrubThumbnail;falsemeans hide the affordance rather than paint a blank frame.Under the hood the two live-gated helpers were generalized (their
isLive/isLiveSessionguards dropped and the extractor LRU renamed) so one path serves both session types.Two design calls worth flagging
1. I did not wire an automatic second-connection fallback inside the engine (your option 3's "falls back to FrameExtractor"). The existing
makeFrameExtractor(url:)takes a host-chosen URL on purpose: stills often come from the original file while playback runs a different representation (a transcode), and the engine cannot derive that URL from the loaded one. So a zero-arg unified call can never fully subsume it. Instead,scrubThumbnailis a pure cache-backed path (nilon miss, no hidden second connection), and the second-connectionFrameExtractorpath is left completely untouched for multi-connection sources and the divergent-preview-URL case. The host picks between them withsupportsCacheBackedStillsplus its own knowledge of whether the source is single-connection.2. The VOD decode seeks to 0, not to an absolute time. In
.thumbnailmode the extractor returns the first frame after the seek (thepts < targetskip is snapshot-only), sosecondscontrols onlyDemuxer.seek. We hand the extractor exactly one segment (the one containing the scrub position) and seek to 0. Becauseavformat_seek_file(ts=0, min_ts=Int64.min, ...)resolves to the segment's first keyframe whether that segment's fMP4tfdtis absolute or zero-based (the latter can happen after a back-seek restart), the decode is axis-independent and cannot miss on a seek-past-EOF. The tradeoff is per-segment granularity (segments are a few seconds, comparable to server BIF intervals), which is the right resolution for a scrub preview. This also means no device-side tuning was needed to get the timeline right.What to expect on device
On a debrid/torrent H.264/HEVC direct link (native path):
nilcleanly and show time-only. On a single connection those bytes cannot exist without stealing the playback link, so this is the physical limit, not a bug.[FrameExtractor] open failedand no second-connection traffic at all, so both failure modes are gone by construction.If you can load such a source, play, and scrub within the buffered window, a confirmation that stills now render (and that the log is quiet of the FrameExtractor open/miss lines) would close this out. An
aetherctlrepro is welcome if it is easy, but nothing about the verify depends on it.Thanks again for the exceptional report.
dlev02 commentedon Jul 6, 2026
Just tested it on Macbook Pro and it works perfectly. Thumbnails render across the whole buffered window now, and the open-failed lines are gone from the log. Anything past the buffer falls back to the timestamp, exactly like you described.
Honestly kind of blown away by the turnaround. Filed this a few hours ago and it's already done and building cleanly on my end. Really appreciate you taking it on and doing it so thoroughly. Thank you! Also, I'm glad it was able to help on your end with Sodalite, nice to see it added.
superuser404notfound commentedon Jul 6, 2026
Thank you really much! Of course claude is doing much of the heavy lifting but i appreciate your part of reporting these bugs and help making aetherengine even better!
chore(release): prepare 5.0.0