streaming a video file while recording

Hi All,

We need to do below 2 actions at the same time:

  1. Publish a live stream from a camera on Wowza (3.0.3) for some clients to connect and watch the live stream.

  2. Record the same published stream on Wowza for some clients to connect and watch the recorded video for past periods.

So it is like trying to stream a video file via Wowza while it is still being recorded to by Wowza.

What would be the recommended way of doing this?

I have searched the forum and came across nDVR module and also LiveStreamRecord Module.

Which one is better for the above requirements?

Regards,

Bora.

Hi

LiveStreamRecord Module is what I would recommend but to be sure you could get the Wowza 3 trail (30 days full functionality) and test both see which you would prefer to use, I’m sure you are aware they work in different ways and the choice comes down to your personal preference.

LiveStreamRecord Module means you would have to have finished recording before you could watch, so depending on how long the content will be and how soon behind the live stream you want your clients to view would factor into whether you would use this option.

Using nDVR allows you to watch the stream while recording and rewind etc, you can only record the amount of time set in the buffer and any time over that writes over the start of the recording, so if you set a 5 hour buffer and you recorded 5hours and 10 mins you would loose the first 10 mins from when you pressed record.

Depending on how much content you wish to record you may need a large amount of disk space for both options.

Jason

The log snip shows a RTPMediaCaster.streamTimeout, which probably has nothing to do with dvr vs live application.

Richard

MediaCaster timeout could be a network problem. I would not expect it to work in either application at the same time when such a timeout occurs in one if they are on the same Wowza instance.

Richard

You can stream a portion of a video in Flash with actionscript:

netstream.play("mp4:sample.mp4", 50,50);

Or server-side (but also limited to Flash clients):

https://www.wowza.com/docs/how-to-insert-a-pre-roll-or-mid-roll-for-video-on-demand-playback-in-flash-rtmp-client

And now for http streaming types (Cupertino, San Jose, Smooth):

https://www.wowza.com/docs/how-to-specify-a-play-start-time-and-duration-for-http-streaming

Richard

Hi

LiveStreamRecord Module is what I would recommend but to be sure you could get the Wowza 3 trail (30 days full functionality) and test both see which you would prefer to use, I’m sure you are aware they work in different ways and the choice comes down to your personal preference.

LiveStreamRecord Module means you would have to have finished recording before you could watch, so depending on how long the content will be and how soon behind the live stream you want your clients to view would factor into whether you would use this option.

Using nDVR allows you to watch the stream while recording and rewind etc, you can only record the amount of time set in the buffer and any time over that writes over the start of the recording, so if you set a 5 hour buffer and you recorded 5hours and 10 mins you would loose the first 10 mins from when you pressed record.

Depending on how much content you wish to record you may need a large amount of disk space for both options.

Jason

Small clarification, you can set the nDVR buffer to unlimited as well.

Hi Jason,

Thanks for the response.

Actually, clients need to be able to watch the recorded file while the stream is still being recorded.

For example, if the buffer is 5 hours, clients should be able to go back and watch 2 hours before now but the stream would continue to be recorded on the same video file.

And some other clients would connect to watch the live stream as well at the same time.

Hence just to confirm, according to your comments, nDVR is the only way to go, right?

Regards.

Live + live stream record: clients can watch video while it is being recorded but only at the live point. No seeking back and forward in time. Have a VOD recording when finished.

Live + nDVR: clients can watch video while recorded and can seek.

Live + nDVR + live stream record. Same as above except once the stream is finished, live stream record creates a single VOD file that can be played back. nDVR creates a recording too that can be played back but its not a single file recording.

I would start with the dvr example that ships with the product and make sure that example works first.

I think we could debug this better if you sent your conf/ and log/ files to support@wowza.com. Please describe the problem and reference this thread.

Scott

After the forceInterleaved property is added, problem is gone and I can run the nDVR application.

And it works quite well too.

I have another question here in order to get some pointers about a requirement.

nDVR solves the requirement of clients going back and forth between the recorded stream and the live stream pretty well.

However, what if I need to extract a portion of the recorded stream for example a 1-hour portion from the day before and deliver it to the client in a format that is playable?

What would be the recommended way of doing this? Or is it even possible to extract portions of the nDVR files and save them in a playable format?

Thanks in advance.

You can extract protions of the nDVR for playback using the playlist API: Use Wowza nDVR Playlist request with the Wowza Streami

However, this ‘extraction’ is a function of streaming. You are telling Wowza what portion of the stream to play.

It does not extract a single A/V file that you can then use.

We currently do not have a way to do that.

If you mean extract portions

OK what I mean by “extracting a portion of the recorded stream” is that the extracted portion can be downloaded by a client to be played back on his/her computer, for example in mp4 format.

I understand there’s no way of doing this as of now, right?

Thanks.

That’s correct.

There is currently no way to take the DVR structure and turn it into a single mp4.

Hopefully this is my last question about this topic.

You mentioned that LiveStreamRecord module will create a single VOD file “”“when the stream is finished”“”.

Can we control this LiveStreamRecord module so that it creates a VOD file whenever we want while nDVR continues to do streaming+recording?

For example if I don’t want to stop the stream but just want to get the recorded video until now…

Somewhat like start-recording and stop-recording functionality of LiveStreamRecord module.

I checked it’s source code and it looks like it is supported but I would like have this confirmed.

Also when LiveStreamRecord is added as a module on top of the dvr application to achieve the above goal; is LiveStreamRecord module going to connect to the stream source (i.e. the camera) to do the recording or is it going to simply use the stream served by the nDVR application? This is to make sure that the upload bandwidth of the camera is not utilized twice.

Thanks.

“When the stream is finished” was inaccurate. The live stream record module can start and stop the recording of the live stream multiple times on the same incoming live stream. So you could send a live stream in and record from t0 to t1 as “showOne.mp4”, t1 to t2 as “showTwo.mp4”, etc.

So the answer is yes. You can create VOD files while also doing other things like DVR with the live stream. (You need to start recording at the point in time when you want the saved recording to start.)

There is only a single live stream coming from your camera into Wowza. Wowza takes care of ‘splitting’ the stream to send it to live stream record, live streaming, DVR, transcoder, etc per your configuration.

Hopefully this is my last question about this topic.

You mentioned that LiveStreamRecord module will create a single VOD file “”“when the stream is finished”“”.

Can we control this LiveStreamRecord module so that it creates a VOD file whenever we want while nDVR continues to do streaming+recording?

For example if I don’t want to stop the stream but just want to get the recorded video until now…

Somewhat like start-recording and stop-recording functionality of LiveStreamRecord module.

I checked it’s source code and it looks like it is supported but I would like have this confirmed.

Also when LiveStreamRecord is added as a module on top of the dvr application to achieve the above goal; is LiveStreamRecord module going to connect to the stream source (i.e. the camera) to do the recording or is it going to simply use the stream served by the nDVR application? This is to make sure that the upload bandwidth of the camera is not utilized twice.

Thanks.

One more bit of info.

There is a full Java API underneath the HTTP Provider that can be utilized if need be.

So for example, I think the provided HTTP Provider would not allow your recordings to overlap. However, if you use the underlying API (same one that HTTPProvider uses), you could have recordings that overlap.

Scott

The HTTP Provider does not do overlapping recordings. And I don’t have sample code that does overlapping recordings.

You would have to dig into the HTTPProvider code and use the API that it is using to start and stop recordings.

I think the current live stream record module tracks the current recordings based the stream Name which is why its probably limited to one recording per stream.

Scott

As for overlapping recordings of “”“the same stream”“”; this was the question in my mind because it is quite an important aspect as per my requirements.

And I understand that it is possible to create overlapping recordings of the same stream via the LiveStreamRecord module by using the Java API, which is the approach I am planning to take.

Could you please confirm this?

On the other hand, my code review suggests otherwise: I checked the Java source code (ModuleLiveStreamRecord.java and HTTPLiveStreamRecord.java) and it looks like the previous recording of the “”“same stream”“” will be stopped if another one is starting. Below piece of code is taken from ModuleLiveStreamRecord.java:

// add it to the recorders list
synchronized (recorders)
{
	ILiveStreamRecord prevRecorder = recorders.get(streamName);
	if (prevRecorder != null)
		prevRecorder.stopRecording();
	recorders.put(streamName, recorder);
}

Could you please clarify the above for me?

If I am wrong at any point, I would like to know how I can go about having overlapping recordings (VOD files) of the same stream.

Currently I am planning to use nDVR for continuous recording of a stream.

Then there will also be the LiveStreamRecord module in charge to create VOD files of the same stream at pre-determined time periods, “”“which can overlap”“”.

Thanks.

The code snippet you reference above: is not part of the API. It’s part of how the HTTPProvider and module are written. They allow one recording per stream and track the recordings this way. You would need to track your recordings differently.

Look at the code that constructs the recorder, set the params and then calls startRecording(). Do it twice for the same stream and you should have 2 recordings.

Hi Jason,

Thanks for the response.

Actually, clients need to be able to watch the recorded file while the stream is still being recorded.

For example, if the buffer is 5 hours, clients should be able to go back and watch 2 hours before now but the stream would continue to be recorded on the same video file.

And some other clients would connect to watch the live stream as well at the same time.

Hence just to confirm, according to your comments, nDVR is the only way to go, right?

Regards.

Thanks for all the responses. It is much appreciated.

I tried to use the nDVR module for testing purposes but failed.

I may be deviating from the subject here as this may be a basic issue but here it goes.

As far as I understand from the material I found in the forum and the articles, nDVR is supposed to start recording when the stream starts.

Is this correct? And the stream needs to be started via the dvr application whose setup instructions are given in “How to setup and run Wowza nDVR”, right?

I followed the steps here and then tried to start a stream with name “test.stream” and type “rtp” via the application “dvr”.

The file test.stream contains: rtsp://camera-ip-address/axis-media/media.amp.

This works with the example application “live” and I am able to watch the live stream.

But when I start the same stream via the dvr application Wowza complains about timeout and destroys the stream after about 10 seconds.

And I don’t see anything recorded either.

Also, I captured the packets via wireshark and everything looks ok. I can see the RTP packets, etc.

So I am not sure why there’s a timeout.

Below are some sample logs:

2011-12-14 16:49:00 EET comment server INFO 200 - RTPSessionDescriptionDataProviderBasicRTSPWorker.sessionStart: PLAY: rtsp://ip-address/axis-media/media.amp - - -

2011-12-14 16:49:00 EET comment server INFO 200 - RTPSessionDescriptionDataProviderBasicRTSPWorker.processResponse: PLAY: rtsp://ip-address/axis-media/media.amp/ - - -

2011-12-14 16:49:00 EET comment server INFO 200 - RTPMediaCaster.Reconnector[23578365:dvr/definst:test.stream]: done: 2 - - -

2011-12-14 16:49:12 EET comment server INFO 200 - RTPMediaCaster.streamTimeout[23578365:dvr/definst:test.stream]: timeout:12000 diff:12013 reason:101 - - -

2011-12-14 16:49:12 EET comment server INFO 200 - RTPMediaCaster.resetConnection[23578365:dvr/definst:test.stream]: - - -

2011-12-14 16:49:12 EET comment server INFO 200 - RTPMediaCaster.closeRTPSession[23578365:dvr/definst:test.stream] - - -

Regards,

Bora.

So there’s nothing wrong with what I am trying to do, right?

This is the way nDVR works?

And no clue why there’s a timeout?

As I said I can see the incoming RTP traffic with dvr application and the same stream is working with live application…

Regards.

They are on the same Wowza instance.

I tested it again and it works fine with the live application and fails with the dvr (timeout)…

I did restart the Wowza instance several times too.

I am guessing there’s something wrong with the Application.xml of the dvr application but can’t figure out what.

A few differences between the Application.xml’s of both apps.

On dvr:

dvrstreamingpacketizer

On live:

cupertinostreamingpacketizer,smoothstreamingpacketizer,sanjosestreamingpacketizer

On dvr I have below and they are empty on live:

dvrrecorder

dvrfilestorage

On live I have this and it is empty on dvr:

forceInterleaved

true

Boolean

Just now I tried adding the above MediaCaster property to the dvr Application.xml and it worked :slight_smile:

Perhaps this helps someone else…

Thanks.

After the forceInterleaved property is added, problem is gone and I can run the nDVR application.

And it works quite well too.

I have another question here in order to get some pointers about a requirement.

nDVR solves the requirement of clients going back and forth between the recorded stream and the live stream pretty well.

However, what if I need to extract a portion of the recorded stream for example a 1-hour portion from the day before and deliver it to the client in a format that is playable?

What would be the recommended way of doing this? Or is it even possible to extract portions of the nDVR files and save them in a playable format?

Thanks in advance.

OK what I mean by “extracting a portion of the recorded stream” is that the extracted portion can be downloaded by a client to be played back on his/her computer, for example in mp4 format.

I understand there’s no way of doing this as of now, right?

Thanks.