Wowza Community

Streaming a video from a specific cue point

I’d like viewers to be able to request just the portion of a video starting at a specific time or cue point. I’ve read that a Flash server can offer this, but don’t see any mention of how to do it.

Can anyone show me how to serve just part of a longer video?

Simplest code I could come up with:

import flash.media.Video;
var serverUrl:String = "rtmp://localhost/simplevideostreaming";
var nc:NetConnection;
var ns:NetStream;
var video:Video;
nc = new NetConnection();
video = new Video(320, 180);
stage.addChild(video);
function ncOnStatus(infoObject:NetStatusEvent)
{
	trace("ncOnStatus: "+infoObject.info.code);
	if (infoObject.info.code == "NetConnection.Connect.Success")
	{
		ns = new NetStream(nc);
		video.attachNetStream(ns);
		ns.bufferTime = 2;
		ns.play("Extremists", 10, -1);
	}
}
nc.addEventListener(NetStatusEvent.NET_STATUS, ncOnStatus);
nc.connect(serverUrl);

Charlie

You can do it with start and length parameters of netstream.play:

ns.play("somestream",10,20);

This will play “somestream” starting at 10 seconds from the start, and will play for 20 seconds.

Richard

I finally figured out how to do something simple. I’ll post what I did so the next poor guy in my situation doesn’t have to spend three days floundering. If you need to stream only slices of a longer video from a Wowza server, here’s the simple way to do it.

I used the JW Player, which you can get and install from http://www.longtailvideo.com/players/jw-flv-player/

I put its files in a folder called /flash

I have a server with wowza at http://afr-video (it’s on our intranet, so it won’t work for you).

I have a folder with the eiti.flv video file and an html file “afrex/test.htm” with just a few lines of code:

I’m playing just the part of eiti.flv starting at 839 seconds and continuing through 885 seconds.

This text will be replaced

If you want a simple, powerful and nice looking player then take a look at JW Player. The instructions are here:

http://www.wowza.com/community/t/-/33

If you want to learn how to program Flash with Wowza Pro yourself then I would take the time to dissect the SimpleVideoStream example player. It actually is not super complex.

Also, take a look at this tutorial. It covers the basics:

http://blog.martinlegris.com/?p=94

Charlie

Follow these instructions:

http://www.wowza.com/community/t/-/33

Charlie

Eric,

I suggest the working examples that ship with Wowza here:

[wowza-install-dir]/examples

Check out the simplevideostreaming example, open the FLA file with Flash, go to the layer 1 actionframe, and look for the NetStream and NetConnection, and how to connect and play videos. It’s all working already in these examples and you can modify them and use them.

Richard

The “ns” or “nsPlay” parts in the examples are both NetStream/s The could be any name. Look for this:

var ns:Netstream = new NetStream(nc);

nc is a NetConnection.

You are the right track. The play command you posted will play a slice of a video.

Richard

JW player handles “start” using seek after a video starts playing, instead of in the NetStream.play command.

Open com.jeroenwijering.models.RTMPModel.as. Look for this:

stream.play(url);

I changed it to:

var start:String = model.playlist[model.config['item']]['start'];
start = (start=="")?"0":start;
stream.play(url,start,-1);

The “start” time would come from a playlist. You could add a length arg the same way, and just add a length value in playlist.

In the function onData, comment out these lines:

//if(model.playlist[model.config['item']]['start'] > 0) {
//	seek(model.playlist[model.config['item']]['start']);
//}

Richard

You can do it with start and length parameters of netstream.play:

ns.play("somestream",10,20);

This will play “somestream” starting at 10 seconds from the start, and will play for 20 seconds.

Richard

Thanks! I know that what you wrote is ActionScript, and I’ve already done some simple edits (when directed) of ActionScript in Flash CS3 Prof, but I don’t know how to create code when my player (FLVPlayback) doesn’t include it. I don’t even know how to define a stream. Is that just my FLV file name?

With Real’s Helix Server, I’d just add parameters to the end of the URL for a video file, eg. rtsp://afr-video/speech.rm?start=2:35&end=4:55

Surely it can’t be as difficult to do this in Flash as it seems. Designers wouldn’t make something so basic so difficult.

You can do it with start and length parameters of netstream.play:

ns.play("somestream",10,20);

This will play “somestream” starting at 10 seconds from the start, and will play for 20 seconds.

Richard

Sorry, but really have no idea what to do with that piece of code. If I have a video and a player, what do I do? I really know nothing about how to assign code to an object, or whatever it is one needs to do. I don’t know what a “netstream”. I spent two hours on the Adobe actionscript tutorial and it never described how to make a video play from a specified point. I just want to play a part of a longer Flash video.

Eric,

I suggest the working examples that ship with Wowza here:

[wowza-install-dir]/examples

Check out the simplevideostreaming example, open the FLA file with Flash, go to the layer 1 actionframe, and look for the NetStream and NetConnection, and how to connect and play videos. It’s all working already in these examples and you can modify them and use them.

Richard

Thanks.

I had already gotten the simplevideostreaming example to work. I was able to select the Layer 1 in the simplestreamingvideo.fla file, and to open the Actions Window. There I was able to find some entries that used NetStream, but none that looked anything like this:

ns.play(“somestream”,10,20);

Did the author mean “nsplay”?

The following looked a bit like it might be related, since the comment above it indicated it’s about playing a video. I don’t see how this relates to the suggestion above, though.

nsPlay.seek(timecode);

I think the problem I have is that this simplevideostreaming example is actually quite complex. I appreciate that the market for Wowza in the past has been for technical professionals, but I don’t want to become a Flash guru, I just want to play clips from our vast collection of long-tail Knowledge Management videos. Could I beg someone to create a REALLY, REALLY, REALLY simple (“hello world” level) example of playing a video from a defined time?

Thanks!!

If you want a simple, powerful and nice looking player then take a look at JW Player. The instructions are here:

http://www.wowza.com/community/t/-/33

If you want to learn how to program Flash with Wowza Pro yourself then I would take the time to dissect the SimpleVideoStream example player. It actually is not super complex.

Also, take a look at this tutorial. It covers the basics:

http://blog.martinlegris.com/?p=94

Charlie

Thanks!

I looked at the JW Player article, but I don’t see anything there indicating play start/stop times.

I tried the code in the blog (I had to rename one of the video variables, since Flash told me there was a conflict), and got my video to play, but the blog doesn’t seem to be using the Wowza server, just http, so I can’t play just one clip from a long video.

I really don’t want to invest the time to learn how to program Flash, since I have no need to do so. Really, all I want is to play defined clips from long videos, using just the simplest possible player. That’s it.

I feel like a guy trying to explain to General Motors why it would be a good idea to offer a radio as an option in their cars. I keep getting steered towards “how-to” magazines.

If I EVER get this working, I promise to create a documented “hello world” example. It could become famous.

The “ns” or “nsPlay” parts in the examples are both NetStream/s The could be any name. Look for this:

var ns:Netstream = new NetStream(nc);

nc is a NetConnection.

You are the right track. The play command you posted will play a slice of a video.

Richard

Really? GREAT!

How would I modify this line to play one slice, perhaps starting at 10 seconds and ending at 30?

nsPlay.seek(timecode);

In its present form, it looks like it’s just a seek method for nsPlay to move the play head to the time of “timecode” (I hope I got the Flash lingo correct).

I discovered that the JW Player works great and does exactly what I need! I just use their player and the code below. Because my videos are all very long and bandwidth to the World Bank’s country offices iin Africa is expensive, I’d prefer to stream just what they need using Wowza. Can this fabulous JW Player work with Wowza as simply as it does with http? Using rtmp to try to get video from Wowza instead of http doesn’t seem to work.

This text will be replaced