Is it possible to record video from rtsp url?

701 views
Skip to first unread message

dieg...@hotmail.com

unread,
Apr 27, 2016, 7:38:42 AM4/27/16
to kurento
I'm trying record  video from rtsp url but not working. One file is created but size it's 0 Bytes.  This is the code:

function onOffer(error, sdpOffer) {
 
if (error) return onError(error);

 kurentoClient
(args.ws_uri, function (error, kurentoClient) {
 
if (error) return onError(error);

 kurentoClient
.create("MediaPipeline", function (error, pipeline) {
 
if (error) return onError(error);
 console
.log("Got MediaPipeline");
 
var elements =
 
[
 
{type: 'PlayerEndpoint', params: {uri: address.value}},
 
{type: 'RecorderEndpoint', params: {uri: args.file_uri}},
 
{type: 'WebRtcEndpoint', params: {}},

 
]

 pipeline
.create(elements, function (error, elements) {
 
if (error) return onError(error);
 
var player = elements[0];
 
var recorder = elements[1];
 
var webRtcEndpoint = elements[2];

 setIceCandidateCallbacks
(webRtcEndpoint, webRtcPeer, onError);

 webRtcEndpoint
.processOffer(sdpOffer, function (error, sdpAnswer) {
 
if (error) return onError(error);
 console
.log("offer");
 webRtcEndpoint
.gatherCandidates(onError);

 webRtcPeer
.processAnswer(sdpAnswer);
 
});
 kurentoClient
.connect(webRtcEndpoint, webRtcEndpoint, recorder, function (error) {
 
if (error) return onError(error);

 console
.log("Connected");

 recorder
.record(function (error) {
 
if (error) return onError(error);

 console
.log("Record");


 player
.connect(webRtcEndpoint, function (error) {
 
if (error) return onError(error);

 console
.log("PlayerEndpoint-->WebRtcEndpoint connection established");

 player
.play(function (error) {
 
if (error) return onError(error);
 console
.log("Player playing ...");


 recordButton
.addEventListener("click", function (event) {
 recorder
.stop();
 console
.log("Record Stopped");
 
});

 
});
 
});
 
});
 
});
 
});
 
});

 
}
 
);
}


Ivan Gracia

unread,
Apr 27, 2016, 8:00:44 AM4/27/16
to Kurento Public
If you don't connect the player to the recorder, you'll never be able to record it. Moreover, you are not connecting anything to the recorder, so it's not getting any media from any source.

Ivan Gracia



--
You received this message because you are subscribed to the Google Groups "kurento" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kurento+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Diego García

unread,
Apr 28, 2016, 11:32:49 AM4/28/16
to kurento
Thanks for your answer but I don't understand what do you say with this "Moreover, you are not connecting anything to the recorder, so it's not getting any media from any source."

Ivan Gracia

unread,
Apr 28, 2016, 11:49:03 AM4/28/16
to Kurento Public
I got that wrong, sorry. It's the player and not the webrtc endpoint what you need to connect to the recorder. Also, if the webrtc endpoint is not bidirectional, there's no point in connecting it in loopback.

Ivan Gracia


Diego García

unread,
Apr 28, 2016, 12:11:10 PM4/28/16
to kurento
I've used this sample : https://github.com/lulop-k/kurento-rtsp2webrtc , but also I need to record the video.

I changed my code, but it doesn't work.

player.connect(webRtcEndpoint, function (error) {
if (error) return onError(error);

console.log("PlayerEndpoint-->WebRtcEndpoint connection established");

    kurentoClient.connect(player, player, recorder, function (error) {
if (error) return onError(error);
console.log("PlayerEndpoint-->Recorder connection established");


player.play(function (error) {
if (error) return onError(error);
console.log("Player playing ...");

            recorder.record(function (error) {
if (error) return onError(error);

console.log("Record");

                recordButton.addEventListener("click", function (event) {
recorder.stop();
console.log("Record Stopped");
});

});
});
});
});

Ivan Gracia

unread,
Apr 28, 2016, 12:18:35 PM4/28/16
to Kurento Public
Why do you have the player twice in there?
 kurentoClient.connect(player, player, recorder,
I don't think that's doing what you think it's doing. You could just do player.connect(recorder, function(error) { /* do some stuff here */ })

Ivan Gracia


Diego García

unread,
Apr 28, 2016, 12:33:41 PM4/28/16
to kurento
I'm not sure, I saw it another example but I tried it before :

player.connect(webRtcEndpoint, function (error) {
   
if (error) return onError(error);
   
console.log("PlayerEndpoint-->WebRtcEndpoint connection established");

 
   
player.connect(recorder, function (error) {

       
if (error) return onError(error);
       
console.log("PlayerEndpoint-->Recorder connection established");

       
player.play(function (error) {
           
if (error) return onError(error);
           
console.log("Player playing ...");

           
recorder.record(function (error) {
               
if (error) return onError(error);
               
console.log("Record");

               
recordButton.addEventListener("click", function (event) {
                   
recorder.stop();
                   
console.log("Record Stopped");
               
});

           
});
       
});
   
});
});

Ivan Gracia

unread,
Apr 28, 2016, 1:09:32 PM4/28/16
to Kurento Public
That should work. Check all the constructor params that you've used in the endpoints: the URLs of the recorder and the player. Also check your KMS logs for errors.

Ivan Gracia


Message has been deleted
Message has been deleted

diego...@gmail.com

unread,
May 2, 2016, 4:59:40 AM5/2/16
to kurento
Hi,

I think the the constructors parameters are correct but I'm not sure.


 if the log file is located at /var/log/kurento-media-server/media-server.log then there are no errors, because I don't find it (media-server.log is not created).

what is the problem?.

Ivan Gracia

unread,
May 2, 2016, 5:02:33 AM5/2/16
to Kurento Public
Did you upgrade from a previous version? Check the owner of that folder. In version 6.4.0 we changed the user that runs the process from nobody to kurento. That user should have write permissions in /var/log/kurento-media-server and wherever you are going to record the files.

Ivan Gracia


diego...@gmail.com

unread,
May 2, 2016, 5:33:04 AM5/2/16
to kurento
No, It is a new installation

ls -la var/log/kurento-media-server/
total 8
drwxr-xr-x  2 kurento root   4096 may  2 11:25 .
drwxrwxr-x 15 root    syslog 4096 may  2 11:18 ..

The recorded file it's created on the desktop but the size is 0.

Ivan Gracia

unread,
May 2, 2016, 5:34:39 AM5/2/16
to Kurento Public
Do you get the loopback video?  Can you check that at least?

Ivan Gracia


diego...@gmail.com

unread,
May 2, 2016, 5:51:54 AM5/2/16
to kurento
Sorry, I don't understand what you ask me. It is the first time I use kurento and my English is not very good. Could you explain it better?. Thanks

Ivan Gracia

unread,
May 2, 2016, 6:09:31 AM5/2/16
to Kurento Public
I'm asking if the video arrives at the media server at all. Perhaps the issue is not the recorder, but that the video is not getting from your client to the server. Did you ever check any of the tutorials, like the hello-world, to make sure your setup is correct?

Ivan Gracia


diego...@gmail.com

unread,
May 2, 2016, 6:41:28 AM5/2/16
to kurento
I think so, the code it's similar to https://github.com/lulop-k/kurento-rtsp2webrtc but adding the recoder. I paste http/rtsp url video in the browser and the video is played correctly. Hello world sample obtains the video from a local webcam, but that's not what I need.

...

Ivan Gracia

unread,
May 2, 2016, 7:15:12 AM5/2/16
to Kurento Public
Well, you should also check that the media server can indeed get the video from the remote source. Check first without adding the recorder! Perhaps the issue is that you don't get the video at all.

Ivan Gracia


diego...@gmail.com

unread,
May 2, 2016, 7:50:21 AM5/2/16
to kurento
Ok. I removed the recorder and the sample running correctly. I do not know to check now. I'm sorry for being a little annoying but I need to do this.

...

diego...@gmail.com

unread,
May 2, 2016, 10:43:00 AM5/2/16
to kurento, diego...@gmail.com
I got to record. Later I will write as was resolved for the purpose of help the community. Thanks for everything.
...

diego...@gmail.com

unread,
May 3, 2016, 7:00:54 AM5/3/16
to kurento
HI, 

The recorder works in kurento 5, but does not work in version 6.4.0. The code is the same.
I changed the owner of the directory where to save the file, from nobody  to kurento.

I have checked the log, and it seems that everything is correct.

The created file size is 0.

I checked this post: https://groups.google.com/forum/#!topic/kurento/SsuFWCXX0EY  and added  this code:

  type: 'RecorderEndpoint', params: {
   
stopOnEndOfStream:true,
   
mediaProfile:'WEBM',
   
uri: args.file_uri
}
but it does not work.

Any idea why it fails to change the version?.
Thanks.

El lunes, 2 de mayo de 2016, 13:15:12 (UTC+2), igracia escribió:
...

David Fernandez Lopez

unread,
May 3, 2016, 7:05:04 AM5/3/16
to kur...@googlegroups.com
If your video doesn't have audio, use WEBM_VIDEO_ONLY instead of WEBM.
David Fernández López

diego...@gmail.com

unread,
May 3, 2016, 7:10:48 AM5/3/16
to kurento
OMG, it's working. Thousands of thank yous. 
...
Reply all
Reply to author
Forward
0 new messages