Proposal to Change Online Sources URLExtract Logic
While I agree that the pre generation of metadata for local files is appropriate, because why have the file if you do not intend to play it, so make the playback as efficient and fast as possible, I do not agree that it is appropriate for online media.
The goal of the online media plugins is to offer a set of streams to the users, the majority of which will never be played, and so it is inappropriate to waste resources predetermining the stream urls and generating the metadata for all of them, particularly when the stream may go ofline between the point of predetermination and actual playback. All that is really required is to present the user with a list of possible stream items, and then to extract the links and obtain the meta data at playback time.
Currently Serviio uses the extracturl method at every refresh time to:
1. Use the code to determine the stream url.
2. use the code to determine the cache_key.
3. if the cache_key is not in the cache, use ffmpeg to get the metadata for the url and store it in the cache.
and it seems that on playback the logic sequence is:
4. get the metadata from the cache
5. use it to determine if the file needs to be transcoded
6. if stream expires immediately, run extracturl and determine the stream url per step 1 above, but skip step 2 & 3.
7. transcode the (new) stream url based on the original metadata.
This results in the first set of metadata being used at playback time, regardless of whether the metadata (other than the stream url itself) has been changed prior to playback as would have been indicated by a new cache_key.
It seems it would be a simple change at refresh time to skip steps 1 thu 3 and at playback time to execute steps 1 to 3 followed by steps 4, 5 and 7. In that way, the cycles to required to determine online stream metadata would only used at playback time and determined for the currently available url.
The advantage of this change is that it would eliminate the time consuming extract of all the urls on each refresh when the vast majority of that information will never be used, defer it to playback time and eliminate the major disadvantage of Serviio when accessing online sources.
Proof of concept is already available in the beeg groovy where all the urls have common metadata and so following every refresh urls are is generated using a single url and cache_key rather than extracted, and a generated flag is set along with expires immediately. Then when a file is played, it is extracted again because of the expires immediately, and the generated flag is used to cause the real url to be extracted and played utilizing the common metadata. Unfortunately due to Serviio using the existing metadata and not updating it when when the extract url forced by expires immediately is executed at playback time, it was not possible to also get the actual metadata for the file as is suggested above.
The result of is change has been to eliminate the 22 minutes required to extract the 400 beeg urls with every refresh and simply generate them in less than one second, in exchange for less than 10 seconds to extract the true currrent url and access its metadata each time one of the beeg videos is actually played.
Given the lack of value in preextracting the online streams and what appears to be a transparent and simple logic order change, I hope this proposal can be given serious consideration.