Saving Live Streams – Recording, a Quick How To Guide

SHARE

Server running? Check. Video streaming? Affirmative. Recorded files? Hmm . . . they should be here. Streaming video is awesome, but what if I want to preserve my three hour live cat cam for years to come? Well with a few snippets of code you can save your video to last unto antiquity (or at… Continue reading Saving Live Streams – Recording, a Quick How To Guide

Server running? Check. Video streaming? Affirmative. Recorded files? Hmm . . . they should be here. Streaming video is awesome, but what if I want to preserve my three hour live cat cam for years to come? Well with a few snippets of code you can save your video to last unto antiquity (or at least until your hardrive crashes).


**1 – Set Publish Method**

The R5Stream.publish method will establish the server connection and begin publishing. You will need to set the type parameter to R5RecordTypeRecord on the R5Stream.publish method.

iOS (Objective C):

[self.stream publish:[self getStreamName:PUBLISH] type:R5RecordTypeRecord];

iOS (Swift):

self.stream.publish(self.getStreamName(PUBLISH), type: R5RecordTypeRecord)

Android (Java):

stream.publish(Publish.config.name, R5Stream.RecordType.Record);

This will then save the video as an FLV in the applications “streams” directory. You can then (if you wish) manipulate it with FFMPEG to convert to different formats, and/or combine the streams post recording.

Note: The iOS code samples were modified from the example apps found on our Gitub for clarity. If you are using one of the Red5 Pro example apps you will need to change self.stream to self.publish


**2 – Set Type Parameter**

The type parameter tells the server the recording mode to use on the server.

R5RecordTypeLive – Stream but do not record

R5RecordTypeRecord – Stream and record the file name. Replace existing save.

R5RecordTypeAppend – Stream and append the recording to any existing save.


**3 – Finding your Files**

This is an example of how it could potentially look on your web browser and on your file system.

On the Web Browser:

You’ll need to make sure you’re using he correct IP address to locate your streams.

http://123.456.7.8:5080/live/streams/

On the File Systems:

your server directory/webapps/live/streams/

These might need a bit of modifying depending on the directory you’re saving things to. But this should be generally where you’d find your recorded files.

If you need additional help with converting these saved files to MP4, please see this blog post.