Wowza Community

Converting media cache files into source files

Hi,

I have an application where I need to sometimes convert a media cached file into a permanent source file. I think there are two ways to do in

A) Query wowza to find out which time periods of a source are cached, and restream those cached portions of the source to a RTP-Live-Record session to get an mp4

B) Somehow read and convert the media cache file directly.

I would prefer to do option B however option A is ok too.

Are either these options possible?

For option A I would need to query wowza somehow to understand the current state of the cache - Can someone point me in the right direction here?

For option B I woul dneed to convert the media cache files to MP4s. I am comfortable doing that, but would need to knwo the basic format of the files first.

The reason for this need is that the transmission link between the source and cache server is cellular, and I would like to permanently save the video watched so that there isnt a need to duplicate transmission at a later date.

Hi,

Both options that you are suggesting appear to be overly complicated and I wouldn’t even want to begin to think how to accomplish either of them efficiently.

One of the issues I can foresee is that if you have partial content, you will need some way of loading that back into the Media Cache later if someone requests it. That would actually be a lot more difficult than saving it.

I assume that the purpose is to keep the items in the Media Cache indefinitely (or at least for a long period of time). Perhaps one of the following might be a better or easier to implement options, assuming that the Media Cache stores are large enough to accommodate the content.

As a minimum, set onStartReloadCache to true in the main Media Cache properties so that the cache isn’t purged during a server restart. There is also a related setting, onStartReloadCacheVerifySource which verifies that any content in the cache is still valid and the source hasn’t changed. It’s best to have this set to true however, you can set it to false if you know the source content isn’t changing or you don’t want the startup delay that may occur if there is a lot of entries to check.

  • Set the Maximum Time To Live for the source to a high value so that the content is not purged too quickly. The Minimum Time To Live setting should be relatively low so that if the cache does fill up, there is a chance that at least some content can be purged. Flush content manually if needed using the Media Cache API methods.

    String mediaName = "[prefix]/sample.mp4";
    MediaCache mediaCache = MediaCacheImpl.getMediaCache();
    boolean flushed = mediaCache.flushItemFromCache(mediaName);
    
    
  • Use normal TTL values and set up a timer that touches each of the Media Cache Items before it times out so that it remains valid. This would allow you to have some content that is long lived and some that purges at a faster rate. The timer should run at a rate higher than the minimum ttl but lower than the maximum ttl. If it runs more often than the minimum ttl then items won’t be purged if the cache fills up.

    public void run()
    {
    	long now = System.currentTimeMillis();
    	MediaCache mediaCache = MediaCacheImpl.getMediacache();
    	List<String> names = mediacache.cacheItemNames();
    	for (String name : names)
    	{
    		IMediaCacheItem item = mediaCache.getCacheItem(name);
    		if(item != null)
    			item.setLastRelease(now);
    	}
    }