Javascript - Recorder

85 views
Skip to first unread message

venky hegde

unread,
Apr 26, 2018, 1:45:02 AM4/26/18
to kurento
Hi,

I'm new to the Kurento, last week I was trying to understand the working of media server by running the hello word tutorial for node.js, the tutorial explains pretty well how the WebRTC work with media server. As the next part of learning, I thought of exploring on server side recording part. I found the tutorial using JavaScript recorder here. However, when I tried executing it streams fine but when I stop and click on play nothing happens. The file URI - file_uri: 'file:///tmp/recorder_demo.webm', // file to be stored in media server has no recorder media as well. Someone please help me where I might have done the mistakes or any extra configuration need for the recording? it there any tutorial to perform recording for node.js ?

TIA.

Kyle Foley

unread,
Apr 26, 2018, 9:56:23 AM4/26/18
to kurento
Can you post the Kurento logs here so we can check it out? If you're running on Ubuntu, they are in /var/log/kurento-media-server/.  One problem I've had with recordings not showing up is having my folder permissions set incorrectly. I did a chmod 777 to my folder and it started working fine after that. Might not be the case for you since you're trying to put it in /tmp but the logs should tell us

venky hegde

unread,
Apr 30, 2018, 12:45:34 AM4/30/18
to kurento
Thank you Kyle. 

Yes I checked the permission for tmp folder its - drwxrwxrwx, I guess that should be fine. I captured the log of my latest run and attaching the same here.

Couple of things I observed,

- when i use wss:// to ws_uri: the demo won't run, it's giving me undefined even though I enabled the secure web socket in kurento.conf.json. so I change ws_uri: to ws:// and demo runs fine. (in log it says Secure websocket server not enabled:)
- When i click the start button it's just works fine, pushes the local media to remote media, when i click on the play, it's not playing back, i guess it's not recording.

I'm not sure what I'm doing wrong.
2018-04-29_23-43-54.00000.pid1867.log
2018-04-30_00-24-23.00001.pid1867.log
2018-04-30_00-24-54.00000.pid4935.log

Kyle Foley

unread,
Apr 30, 2018, 9:34:04 AM4/30/18
to kurento
I'm not seeing anywhere in the logs that the recorder is actually initializing. You are correctly setting the recording profile to WebM though. Are you calling recorderEndpoint.record() somewhere?

venky hegde

unread,
Apr 30, 2018, 11:49:58 AM4/30/18
to kurento
I'm trying to run the demo code provided in Kurento tutorials - http://doc-kurento.readthedocs.io/en/stable/tutorials/js/tutorial-recorder.html. I'm not changing anything in that except 

 ws_uri: 'wss://' + location.hostname + ':8888/kurento',

and here is the startRecording() function which supposed to be called on click of start button.

function startRecording() {
  console.log("onClick");

  var videoInput = document.getElementById("videoInput");
  var videoOutput = document.getElementById("videoOutput");

  showSpinner(videoInput, videoOutput);

  var stopRecordButton = document.getElementById("stop")

  var options = {
    localVideo: videoInput,
    remoteVideo: videoOutput
  };

  if (args.ice_servers) {
    console.log("Use ICE servers: " + args.ice_servers);
    options.configuration = {
      iceServers : JSON.parse(args.ice_servers)
    };
  } else {
    console.log("Use freeice")
  }

  webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options, function(error)
  {
    if(error) return onError(error)

    this.generateOffer(onOffer)
  });

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

    console.log("Offer...");

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

      client.create('MediaPipeline', function(error, pipeline) {
        if (error) return onError(error);

        console.log("Got MediaPipeline");

        var elements =
        [
          {type: 'RecorderEndpoint', params: {uri : args.file_uri}},
          {type: 'WebRtcEndpoint', params: {}}
        ]

        pipeline.create(elements, function(error, elements){
          if (error) return onError(error);

          var recorder = elements[0]
          var webRtc   = elements[1]

          setIceCandidateCallbacks(webRtcPeer, webRtc, onError)

          webRtc.processOffer(offer, function(error, answer) {
            if (error) return onError(error);

            console.log("offer");

            webRtc.gatherCandidates(onError);
            webRtcPeer.processAnswer(answer);
          });

          client.connect(webRtc, webRtc, recorder, function(error) {
            if (error) return onError(error);

            console.log("Connected");

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

              console.log("record");

              stopRecordButton.addEventListener("click", function(event){
                recorder.stop();
                pipeline.release();
                webRtcPeer.dispose();
                videoInput.src = "";
                videoOutput.src = "";

                hideSpinner(videoInput, videoOutput);

                var playButton = document.getElementById('play');
                playButton.addEventListener('click', startPlaying);
              })
            });
          });
        });
      });
    });

tra...@hiregoat.com

unread,
Apr 30, 2018, 2:14:37 PM4/30/18
to kurento
Kyle,

I'd love to talk with you further about helping our start up team with Kurento.  If this is something you'd be interested in, please email me (tra...@hiregoat.com).  

Sorry to hijack this post a bit, but I could not find a way to message you directly.
Reply all
Reply to author
Forward
0 new messages