how to get video duration in Play command

Hi,

I am working on video mixing with rtmp video streaming. in which i want a video duration which is send by client side script to the wowza streaming server.

after getting the time duration of movie i shall make a break point in which we have to add ads in each interval(means breakpoint).

My Code is:

public void play(IClient client, RequestFunction function,
			AMFDataList params){
		
		File folder = new File("C:/Program Files/Wowza Media Systems/Wowza Media Server Pro 1.7.2/content/ads");
		File[] listOfFiles = folder.listFiles();
		int cont = listOfFiles.length;
		Random r = new Random();
		int randint = r.nextInt(cont);
		
		String adname = listOfFiles[randint].getName();
		String adsurl = "ads/"+adname;
		String videoname1 = getParamString(params, PARAM1);
		String start1 = getParamString(params, PARAM2);
		
		String length1 = getParamString(params, PARAM3);

		[B]System.out.println("Movie length: "+length1);[/B]  // is not working 

		/*DateFormat dateFormat = new SimpleDateFormat("mm:ss");
		Date date = new Date();
		String t = dateFormat.format(date);*/
		
		AMFDataList customDataList = new AMFDataList();
        customDataList.add("play");
        customDataList.add(0.0);
        customDataList.add("null");
        customDataList.add(adsurl);
     /* customDataList.add("Extremists.flv"); */
        customDataList.add(new AMFDataItem(0));
        customDataList.add(new AMFDataItem(-1)); // 10,000 milliseconds (10 seconds)
        customDataList.add(new AMFDataItem(true));

        ModuleCore.play(client, function, customDataList);
        

        
        customDataList.set(PARAM1, new AMFDataItem(videoname1));
        customDataList.set(PARAM2, new AMFDataItem(0));
        customDataList.set(PARAM3, new AMFDataItem(-1));
        customDataList.set(PARAM4, new AMFDataItem(false));

        this.invokePrevious(client, function, customDataList);
        ModuleCore.play(client, function, customDataList);
}
	

The value of length1 is comming “null” on console.

if i print the value of videoname1, the it prints.

please suggest me a right way to do that.

thanks

Make sure the client-side play command includes duration. If you don’t it will be null in the server-side play command:

netstream.play(“somevideo.flv”,0,50);

Richard

If you do not provide the optional arguments of the play command, such as length, it will be null on the server-side. You can use whatever value you want in the server-side command, but if you want to get it from the client-side play command you have to send it.

Richard

You need to do this in the actionscript. Edit the FLA.

Richard

It is probably called player.fla and is probably in the same location as player.swf.

You need Flash CS3 or CS4 to edit FLA files. You can buy it directly from Adobe or look for a reseller. Adobe also has a 30 day trial you can use.

Richard

Asheesh,

Those two server-side lines are getting the 2nd and 3rd optional arguments of the client-side NetStream.play command, which happens in the Actionscript of JW Player. If these optional arguments are omitted in the Actionscript, the values will be null on the server.

netstream.play(“Extremists.flv”); // this is a simple play command.

netstream.play(“Extremists.flv”, 10,20); // this includes start (10) and length (20).

You have to download the JW Player source code, which includes player.fla and all the actionscript files that make up JW Player. The HTML code of player.html is just the container for the Flash application (JW Player). Working on Wowza server-side modules without having a handle on the client-side Actionscript of the player is like trying to drive a car while sitting in the trunk.

Richard

Is there any other way

for example when print the video name like

System.out.println(videoname1);

then it is displaying the video name but when i print the length of video, it does not.

please give me the solution on play command which you have provided to me in java.

Please give me the solution which is in Play command of java or html code, from where flv file is mentioned.

last time you give me same code.

But i am not understanding that where and in which file i have to edit it.

could i not get time duration of video from

String length1 = getParamString(params, PARAM3);

Thanks:)

yes i am sending it by html code, but it is not display on console

when i print from

System.out.println(length1);

[HTML]

[/HTML]

:slight_smile:

Thanks

which one FLA file? and where it could be store?

By the way i was try to edit examples\ServerSideModules\client\MyFirstModule.fla but i couldn’t open.

Two more question i have? That

  1. How the player get the total time duration of video if i am not giving the video time duration. and how the wowza server knows time duration of video if i am not give the time.

  2. How the time duration is loged in log file with the name of the video and many more details are also loged.

Thanks:)

Hi Richard,

there is no any player.fla file. when i download the flv player then i have these files below.

  1. player-viral.swf

  2. preview.jpg

  3. readme.html

  4. swfobject.js

  5. video.flv

  6. yt.swf

that’s it.

and please give me the answer of these question also.

Two more question i have? That

  1. How the player get the total time duration of video if i am not giving the video time duration. and how the wowza server knows time duration of video if i am not give the time.

  2. How the time duration is loged in log file with the name of the video and many more details are also loged.

Thanks :slight_smile:

Hi Richard, good morning please tell me for what purpose these two

bold variables are in play function:-

As you given me before few day’s,

public void play(IClient client, RequestFunction function,
			AMFDataList params) {
		
	String videoname = getParamString(params, PARAM1);
    [B]String start = getParamString(params, PARAM2);[/B]
    [B]String length = getParamString(params, PARAM3);[/B]
		
	AMFDataList customDataList = new AMFDataList();
        customDataList.add("play");
        customDataList.add(0.0);
        customDataList.add("null");
        customDataList.add("Extremists.flv");
        customDataList.add(new AMFDataItem(0));
        customDataList.add(new AMFDataItem(10000)); // 10,000 milliseconds (10 seconds)
        customDataList.add(new AMFDataItem(true));
        ModuleCore.play(client, function, customDataList);
        
        getLogger().info("second play");
        customDataList.set(PARAM1, new AMFDataItem("videoname"));
        customDataList.set(PARAM2, new AMFDataItem(0));
        customDataList.set(PARAM3, new AMFDataItem(-1));
        customDataList.set(PARAM4, new AMFDataItem(false));
        ModuleCore.play(client, function, customDataList);
        getLogger().info("third play");
        customDataList.set(PARAM1, new AMFDataItem("Extremists.flv")); 
        customDataList.set(PARAM2, new AMFDataItem(10000));
        customDataList.set(PARAM3, new AMFDataItem(-1));
        customDataList.set(PARAM4, new AMFDataItem(false));
        
        ModuleCore.play(client, function, customDataList);
	}

Thanks…