Repository navigation
Description
What should the engine do?
Provide a public API to record the currently playing live stream to a file chosen by the host, fed from the connection the session already has open, so the host does not need to open a second connection to the origin. Something along the lines of startRecording(to: URL) / stopRecording(), plus a published recording state (idle / recording / failed with a reason such as disk full or source reset).
Motivating media or use case
IPTV live channels (MPEG-TS over HTTP and live HLS), loaded with LoadOptions(isLive: true), with and without dvrWindowSeconds.
Users expect a Record button on live TV. Today a host can only do this by opening its own second connection to the stream and muxing it separately. On IPTV that is a real problem: most provider plans cap an account at 1 to 3 simultaneous connections, so a second connection for recording either fails outright or knocks the viewer off the channel they are watching. The engine already holds the one permitted connection and already demuxes every packet, so it is the only place a recording can be taken without paying for a second one.
The existing DVR timeshift does not cover this. It is a sliding window that evicts (SegmentCache under aether-segments/, sized by LiveWindowSizing), so it lets the viewer rewind but nothing survives the session, and there is no public way to keep or export what is in it.
What would make it useful in practice:
- Stream copy of the source packets (no re-encode), taken before any audio bridging, so the file keeps the original video and audio codecs. Output as MPEG-TS or fragmented MP4; either is fine, as long as a file that was cut short by a crash or a kill is still playable.
- Recording continues while the viewer pauses or scrubs inside the DVR window, because it follows the source rather than the playhead.
- A defined behaviour when liveSourceReset fires or the host reloads the same URL: either the recording carries on into the same file, or it ends cleanly and reports that it ended, so the host can start a new part.
- Errors reported through the API rather than silently (disk full, write failure, source ended).
- Nice to have, not required: "record from the start of what is buffered", i.e. include what is already in the DVR window when recording starts, so a viewer who presses Record a minute late does not lose the beginning.
Area
Public API surface
Host app / integration context
No response
Would you be willing to open a PR?
Maybe, with guidance
Activity
superuser404notfound commentedon Sep 20, 2026
Implemented in #570, and thank you for the report: the connection-limit argument is what made this an engine problem rather than a host one, and it is quoted almost verbatim in the API docs.
What it does
Stream copy of the source packets into MPEG-TS, taken before any audio bridging, so a TrueHD or DTS channel records its original audio while playback is listening to the bridged FLAC rendition. MPEG-TS rather than fragmented MP4 for exactly the reason you gave: measured here, a file
SIGKILLed mid-write still reads as validmpegtsand decodes to the cut with no errors.Recording follows the source rather than the playhead, so pausing or scrubbing back inside the DVR window does not interrupt it. On
liveSourceResetor a host reload the file is closed cleanly and$recordingStatepublishes.ended(.sourceReset), so you can start a new part: the recording does not carry on into the same file, because a reset can bring back different codecs or a different program and writing that past the seam produces a file that is unplayable or silently wrong.Errors are reported, never silent, and the two channels are disjoint: what you can act on before anything is written is thrown out of
startRecording(to:)(.notLive,.unsupportedRoute,.alreadyRecording,.cannotCreateFile), and what can only be discovered while writing arrives through$recordingStateas.failed(.diskFull,.writeFailed,.writeTooSlow).Two limitations worth knowing before it lands
It cannot record on the remote-HLS bypass. With
LoadOptions.nativeRemoteHLS, AVFoundation holds the source connection and the engine never sees a byte, so there is nothing to tap without opening the second connection the feature exists to avoid.startRecordingthrows.unsupportedRoute(.remoteBypass)rather than recording nothing. The escape is a reload withnativeRemoteHLS: false, which moves the session onto the ingest reader; the engine deliberately does not take that route by itself, because pressing Record would then visibly interrupt the picture. Worth checking which route your IPTV masters actually take ($videoRoute), since real HLS masters often land on the bypass.The "record from the start of what is buffered" nice-to-have is not in this version, and I would rather say so than half-deliver it. On the native route the DVR window holds remuxed fMP4 with bridged audio rather than source packets, so prepending it would produce one file whose audio codec changes in the middle, which is the opposite of what you asked for. The software route's packet ring does hold real source packets, so it would work there, and shipping it on one route and not the other under one API seemed worse than not shipping it. It needs source packets spooled on the native path too, which is a second retention budget and its own disk-pressure interaction. If it matters in practice, say so and it can be its own issue.
Where it is not yet proven
It is verified against a synthetic H.264 + AAC MPEG-TS source and by unit tests. Three arms need real media and are not covered yet: a bridged TrueHD or DTS channel, an MPEG-2 channel on the software decode path, and a live HLS master carrying a packed AAC audio rendition. If any of those are in reach on your side, a report from a real provider would be more useful than anything reproducible here.
feat(recording): record a live stream from the session's existing con…
superuser404notfound commentedon Sep 20, 2026
Released in 7.8.0 (
b44385c): https://github.com/superuser404notfound/AetherEngine/releases/tag/7.8.0This needs your media to be properly verified, and that is not a formality. What is covered here is unit tests plus a synthetic H.264 + AAC MPEG-TS source, and three things that decide whether this is actually useful on IPTV cannot be reproduced on synthetic fixtures. If you can run each of these against a real channel on your provider, that is worth more than anything I can build locally:
ffprobe -v error -show_streams -select_streams a <file>on the recording must not sayflac. If it does, the tap is on the wrong side of the bridge and I want to know immediately.Also worth checking early, because it decides whether you can use this at all on a given channel: read
engine.videoRouteon a live session. If it is.remoteBypass, recording throws.unsupportedRouteby design, since AVFoundation holds the source connection there and the engine has no packets to copy. Reload withnativeRemoteHLS: falseto move that channel onto the ingest reader. I would expect a fair number of real HLS masters to land on the bypass, so this may be the first thing you hit.Two more that only a real stream exercises:
.failed(.writeTooSlow)on hardware where playback itself is fine, the ceiling is wrong and the numbers in that error (bytesWritten,queuedBytesDropped) are what I need..ended(.sourceReset)and a complete, playable part one.The two limitations from my previous comment are unchanged and are documented rather than open: no recording on
.remoteBypass, and no "record from the start of what is buffered". Leaving this open for your retest.UnknownCoder807 commentedon Sep 20, 2026
I have added the latest code to my app and I can confirm this feature works as expected. Many thanks!
superuser404notfound commentedon Sep 20, 2026
Thanks for confirming it against real channels, that is exactly the part that could not be proven here, and the connection-limit argument from the original report is what made this an engine feature in the first place.
Marking this as delivered in 7.8.0.
Two things stay documented rather than open: no recording on
.remoteBypass, and no "record from the start of what is buffered". If either one turns out to matter in daily use, a separate issue is the fastest way to get it picked up.One number is still only an estimate: the write queue's 16 MiB ceiling was sized against an assumed 32 Mbit/s rather than measured on a real high-bitrate channel. If a long recording ever ends with
.failed(.writeTooSlow)on hardware where playback itself is fine, that is the ceiling being wrong, and thebytesWritten/queuedBytesDroppedvalues carried in that error are all it takes to fix it.Merge pull request #577 from superuser404notfound/fix/recording-origi…
superuser404notfound commentedon Sep 20, 2026
One improvement to the recordings this feature writes, landed after the release you tested.
A recording carried the broadcast's own clock: a channel that had been up since morning produced a file whose first presentation timestamp sat at, say, 24549.835 s rather than at zero. That is legal, and this engine copes with it on playback, but a player that treats the first timestamp as the origin reads such a file as hours of nothing before the picture, and a duration probe reports the offset rather than the length.
Recordings now start at zero. The origin is the lowest timestamp across every stream, so the audio that a TS interleaves ahead of its picture keeps its lead and the A/V relationship is untouched. Nothing is decoded and nothing is re-encoded, only the numbering changes.
Found and first fixed by @tschuegy in #574, refined in #577. It is on main and not in a release yet.
fix(recording): the recording's zero is the lowest timestamp, not the…