Server side stream on request for "loop until live"

I’ve looked into this “loop until live” feature but its terribly over complicated, static and unsuitable. My way of thinking is somehow create a server side stream on request when a live stream isn’t published. so a HLS request has a VOD stream to play without returning a 404 if requesting the live stream name. And then on publish switch to the live stream in the playlist. No smil, no stream on startup.

Is this possible ? So on a HLS request, setup the Stream if it doesn’t exist. stream = Stream.createInstance(appInstance, streamName); Then when publishing switch to the live stream, with a key name of a postfix “-offline”.

Is it possible to do this in a stream resolving section so it doesn’t also return a 404 for HLS ?

I was able to come up with a way to startup a server stream on an initial HLS request. But switching streams HLS hangs. will make another follow up post.