Wowza Community

change Storage directory for streams

Hi,

I am trying to streams my flvs’ from my “c” drive instead of default storage directory .

I have override Play() method in my custom module like this :

 public void play(IClient client, RequestFunction function, AMFDataList params)
	{
		
		if (params.get(PARAM1).getType() == AMFData.DATA_TYPE_STRING)
		{
			String streamName = params.getString(PARAM1);
			params.set(PARAM1, new AMFDataItem("c://mnt/sdt-platfs1/images/forums2/FR/0/0/videos/videos_8dcd5c3c-9dea-43d3-b8e8-2145ee0c37e0.flv"));
		}
		com.wowza.wms.module.ModuleCore.play(client, function, params);
	}

after making connection from client I get this errorr

  WARN server comment c://mnt/sdt-platfs1/images/forums2/FR/0/0/videos/videos_8dcd5c3c-9dea-43d3-b8e8-2145ee0c37e0.flv open: java.io.FileNotFoundException: C:\Program Files\Wowza Media Systems\Wowza Media Server 2\applications\videoeditor\streams\_definst_\c___mnt_sdt-platfs1_images_forums2_FR_0_0_videos_videos_8dcd5c3c-9dea-43d3-b8e8-2145ee0c37e0.flv (The system cannot find the file specified)

Please help how can I Achieve this?

Also do I need to change Application.xml for this module

Thanks in advance

Mayur

Change Application.xml /StorageDir to the location you want to use.

<StorageDir>c://mnt/sdt-platfs1/images/forums2/FR/0/0/videos</StorageDir>

Richard

You don’t want to do an application instance per connection. This is very inefficient. It would be better to change the relative path using the stream name.

You can use Streams/StorageDir setting in conf/[application]/Application.xml to change the root path to the storage location. You can rewrite the stream name if you override the play command. So for example if for each user you want to have his/her own storage location then you could create a directory structure like this:

/drive/mycontent

under which you have folders for each user:

/drive/mycontent/user1

/drive/mycontent/user2

You can set the Streams/StorageDir to /drive/mycontent. Then in the play command based on the parameters you send in you can rewrite the stream name to include the user id:

package com.wowza.wms.example.module;
import com.wowza.wms.amf.*;
import com.wowza.wms.client.*;
import com.wowza.wms.module.*;
import com.wowza.wms.request.*;
public class ModuleOverridePlayRemapStream extends ModuleBase {
	
	public void play(IClient client, RequestFunction function,
	        AMFDataList params) {
		getLogger().info("Overriding Play");
		
		String streamName = getParamString(params, PARAM1);
		
		params.set(PARAM1, userId+"/"+streamName);
		
		ModuleCore.play(client, function, params);
	}
}

I am not sure how you are passing around or discovering the userId but this is the most practical way to do it.

Charlie

You can change StorageDir dynamically through IApplicationInstance method, but I think that will change it for all clients. That’s not what you are trying to do, is it?

Richard

You can use subfolders, for example:

c:\content\userid

Richard

Sorry, it would be client-side in the NetStream.play command.

netstream.play("userid/example.flv");

Richard

Or more like:

netstream.play(“1234/example.flv”);

Where 1234 is a userid.

This is the dynamic method:

IApplicationInstance.setStreamStorageDir("c:\content\1234");

But I’m pretty sure it just changes it for everyone, per app instance. It would only work if your application is used by one client at a time… Unless each client connects to a different application instance:

rtmp://[wowza-address]/appName/1234

Richard

You can do it onConnect. First connect like this in the client:

netconnection.connect("rtmp://[wowza-address]/appName/1234","1234")

Then do this in onConnect:

static public void onConnect(IClient client, RequestFunction function,
		AMFDataList params) 
{
String userID = getParamString(params, PARAM1);
client.getAppInstance().setStreamStorageDir("c:/content/" + userID);
}

Richard

Charlie is also suggesting subfolders of the content location. He’s setting the location in play command server-side but essentially same as netstream.play(“1234/example.flv”)

I guess you are having problems with backslashes, or it just doesn’t work.

Subfolders per client is the way to do it.

Richard

Try forward slashes “/” or escaping with two backslashes “\”

Richard

Yes, you can point to another local drive, or a mounted drive in you network.

In some cases a mounted drive may need or benefit from using MediaCache addon

Richard

This is what I did to test if it works external directory for stream storage.

But , I want to change this directory dynamically depending on the input parameter sent from flex client.

Please let me know if there is any way to do this ?

right, thats not what we want to do, we have to have different storage directory for each client. it will be dependent on logged in user to application

did not understand this ?

where should i specify this subfolder

Yes it will be still inside /content of the wowza installation directory, and want it to be outside , may be on some server, or on s3

we are just trying from “c:” drive to test

where shall I write ?

IApplicationInstance.setStreamStorageDir(“c:\content\1234”); ??

I can not write this on “onConnect”, as at that point, my client would not have called a server method to set the value

it is giving me this error :

WARN server comment videos_8dcd5c3c-9dea-43d3-b8e8-2145ee0c37e0.flv open: java.io.FileNotFoundException: C:\Documents and Settings\p7105669\Documents\workspace\sampleflvcropper\C\mnt\sdt-platfs1\images\forums2\FR\0\0\videos\videos_8dcd5c3c-9dea-43d3-b8e8-2145ee0c37e0.flv (The system cannot find the path specified)

dont know from where its appending " C:\Documents and Settings\p7105669\Documents\workspace\sampleflvcropper"

Note : sampleflvcropper is the name of my project in workspace of wowzaIDE

@ Charlie,

I did the same thing as you have suggested in very first attempt. (overriding the play method)

but i am getting this error

 WARN server comment c://mnt/sdt-platfs1/images/forums2/FR/0/0/videos/videos_8dcd5c3c-9dea-43d3-b8e8-2145ee0c37e0.flv open: java.io.FileNotFoundException: C:\Program Files\Wowza Media Systems\Wowza Media Server 2\applications\videoeditor\streams\_definst_\c___mnt_sdt-platfs1_images_forums2_FR_0_0_videos_videos_8dcd5c3c-9dea-43d3-b8e8-2145ee0c37e0.flv (The system cannot find the file specified)

Please let me know , what i am doing worng

any clue??