Error in recorded webm file

283 views
Skip to first unread message

shada...@gmail.com

unread,
Dec 22, 2015, 5:02:57 AM12/22/15
to kurento
Hello All

I am using kurento-one2-many call in my application and I am recording 2 files simultaneously. I am able to record the recorded1.webm  and recorded2.webm files successfully. When I try to get the duration of the recorded files using ffmpeg I do not get proper result and also some times ffmpeg says read error when I try to post-process the recorded files. But this case is not likely always. Some times I get 1st file properly and 2nd file as defected & some times vice-versa, and sometimes both file has problems can anybody please let me know why is this so? 

Thank You
Shadanana

Ivan Gracia

unread,
Dec 22, 2015, 9:14:57 AM12/22/15
to Kurento Public
Is it a modified one2many call, or the regular app with just the recorder added?

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.

shada...@gmail.com

unread,
Dec 23, 2015, 12:09:58 AM12/23/15
to kurento, shada...@gmail.com
Hai Ivan,
 I have done few modifications in one2many call app. Modifications are like, instead of only one presenter, one camera and multiple viewers to that presenter , I have changed presenter variable to presenters map so that many presenters can exist. One presenter will broadcast 2 cameras and both the cameras will get recorded.

My modifications goes here 

 if(presenters[sessionId] == null) {
       
var presenter = {
                        id
: sessionId,                        
                        pipeline
: null,
                        webRtcEndpointCamera1
: null,
                        webRtcEndpointCamera2
: null,
                       
Camera1Recorder : null,
                       
Camera2Recorder : null
               
};
                presenters
[presenter.id] = presenter;
       
}


kurentoClient.create('MediaPipeline', function(error, pipeline) {
if (error) {
stop(sessionId);
return callback(error);
}

if (presenters[sessionId] === null) {
stop(sessionId);
return callback(noPresenterMessage);
}

presenters[sessionId].pipeline = pipeline;
pipeline.create('WebRtcEndpoint', function(error, webRtcEndpoint) {
if (error) {
stop(sessionId);
return callback(error);
}

if (presenters[sessionId] === null) {
stop(sessionId);
return callback(noPresenterMessage);
}

webRtcEndpoint.setMaxVideoSendBandwidth(2500);
webRtcEndpoint.setMinVideoSendBandwidth(1500);
webRtcEndpoint.setMaxVideoRecvBandwidth(2500);
webRtcEndpoint.setMaxOuputBitrate(2500000);
webRtcEndpoint.setMinOuputBitrate(2000000);
if(cam == '1') {
presenters[sessionId].webRtcEndpointCamera1 = webRtcEndpoint;
presenters[sessionId].Camera1Recorder = webRtcEndpoint;

                if (candidatesQueue1[sessionId]) {
                    while(candidatesQueue1[sessionId].length) {
                        var candidate = candidatesQueue1[sessionId].shift();
                        webRtcEndpoint.addIceCandidate(candidate);
                    }
                }

                webRtcEndpoint.on('OnIceCandidate', function(event) {
                    var candidate = kurento.register.complexTypes.IceCandidate(event.candidate);
                    ws.send(JSON.stringify({
                      id : 'iceCandidate',
                        candidate : candidate
                    }));
                });

webRtcEndpoint.processOffer(sdpOffer, function(error, sdpAnswer) {
if (error) {
stop(sessionId);
return callback(error);
}

if (presenters[sessionId] === null) {
stop(sessionId);
return callback(noPresenterMessage);
}

callback(null, sdpAnswer);
});
recordParams = {
           uri : "file:///home/kurentofiles/myVideo1.webm", 
mediaProfile: "WEBM"
        };

pipeline.create("RecorderEndpoint", recordParams, function(error, recorderEndpoint) {

                                if (error) {
                                        console.log("Recorder problem");
                                        return sendError(res, 500, error);
                                }
                                
presenters[sessionId].Camera1Recorder = recorderEndpoint;
presenters[sessionId].webRtcEndpointCamera1.connect(presenters[sessionId].Camera1Recorder);
                                presenters[sessionId].Camera1Recorder.record();
                               
});
else if (cam == '2') {
presenters[sessionId].webRtcEndpointCamera2 = webRtcEndpoint;
presenters[sessionId].Camera2Recorder = webRtcEndpoint;

                if (candidatesQueue2[sessionId]) {
                    while(candidatesQueue2[sessionId].length) {
                        var candidate = candidatesQueue2[sessionId].shift();
                        webRtcEndpoint.addIceCandidate(candidate);
                    }
                }

                webRtcEndpoint.on('OnIceCandidate', function(event) {
                    var candidate = kurento.register.complexTypes.IceCandidate(event.candidate);
                    ws.send(JSON.stringify({
                        id : 'iceCandidate',
                        candidate : candidate
                    }));
                });

webRtcEndpoint.processOffer(sdpOffer, function(error, sdpAnswer) {
if (error) {
stop(sessionId);
return callback(error);
}

if (presenters[sessionId] === null) {
stop(sessionId);
return callback(noPresenterMessage);
}

callback(null, sdpAnswer);
});
recordParams2 = {
           uri : "file:///home/kurentofiles/myVideo2.webm", 
mediaProfile: "WEBM"
        };

pipeline.create("RecorderEndpoint", recordParams2, function(error, recorderEndpoint) {

                                if (error) {
                                        console.log("Recorder problem");
                                        return sendError(res, 500, error);
                                }
                                
presenters[sessionId].Camera2Recorder = recorderEndpoint;
presenters[sessionId].webRtcEndpointCamera2.connect(presenters[sessionId].Camera2Recorder);
                                presenters[sessionId].Camera2Recorder.record();
                               
}
                
webRtcEndpoint.gatherCandidates(function(error) {
                    if (error) {
                        stop(sessionId);
                        return callback(error);
                    }
                });
            });



Every time when I record My 2nd recorded file (MyVideo2.webm) will be proper. I mean I can do post processing on it, ffmpeg will show the file duration, dimensions properly. But with  first file I cannot do anything as ffmpeg says read error and also it truncates some packets of the file if I try to post process. And interestingly this problem exists only If 2 cameras are present. I mean If only 1 camera is present then MyVideo1.webm will be proper with out errors.  

Please help me out with this issue

Many Thanks
Shadanana 

Ivan Gracia

unread,
Dec 23, 2015, 9:58:39 AM12/23/15
to Kurento Public, shada...@gmail.com
Are you able to see both streams? I mean, apart from recording, do you get booth feeds? When negotiating the webrtc connections and sending the ICE candidates, I don't see how you differentiate one webrtc from the other. I'm wondering if you are keeping two RTCPeerConnections in the client, or only one.

Ivan Gracia



Message has been deleted

karthike...@gmail.com

unread,
Jan 15, 2016, 1:26:45 AM1/15/16
to kurento, shada...@gmail.com
Hello Ivan,

I am facing almost similar kind of issue as described by Shadanana. I am trying to stream 2 cameras from one presenter and trying to receive it in viewers end. I have created  2 separate webrtc endpoints for presenters and viewers as well. let me consider the same code sequence that has been given above

My presenter function : 
if(presenters[sessionId] == null) {
        var presenter = {
                        id : sessionId,                        
                        pipeline : null,
                        webRtcEndpointCamera1 : null,
                        webRtcEndpointCamera2 : null,
                        Camera1Recorder : null,
                        Camera2Recorder : null
                };
                presenters[presenter.id] = presenter;
        }


kurentoClient.create('MediaPipeline', function(error, pipeline) {
if (error) {
stop(sessionId);
return callback(error);
}

if (presenters[sessionId] === null) {
stop(sessionId);
return callback(noPresenterMessage);
}

presenters[sessionId].pipeline = pipeline;
 
if(camera == '1') {
                        pipeline.create('WebRtcEndpoint', function(error, webRtcEndpoint) {
                            ......
                            . . . . . .
                   });
              } 

else if(camera == '2') {
                        pipeline.create('WebRtcEndpoint', function(error, webRtcEndpoint) {
                            ......
                            . . . . . .
                   });
              } 


Similarly 2 separate webRtcEndpoint has been created for viewers function as well

my client side code goes here: 

function start() {
showSpinner(video);

var options = {
localVideo: video,
                        mediaConstraints : constraints,
onicecandidate : onIceCandidate
   }

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

this.generateOffer(onOfferPresenter);
                         myarray.push(webRtcPeer);
});
}

The start function will run twice if 2 camera feeds are given. I am able to capture both the streams but not able to receive it in viewers end. I get an error stating : 
Received message: "id":"viewerResponse","response":"rejected","message":"code":40004,"responseTimestamp":1452838844004,"stack":"Error: Media elements does not share pipeline

But everything works well with single camera. I am bit confused and not able to recognize where did I go wrong. Please help to overcome this issue

Thank You
Karthik Vaidya


On Tuesday, December 22, 2015 at 3:32:57 PM UTC+5:30, shada...@gmail.com wrote:

karthike...@gmail.com

unread,
Jan 15, 2016, 1:54:25 AM1/15/16
to kurento, shada...@gmail.com
Heyyy !! I got the Solution for my issue. pipeline was creating twice and it was mismatching. Handled it and now its going easy

Thank You


On Tuesday, December 22, 2015 at 3:32:57 PM UTC+5:30, shada...@gmail.com wrote:

Ivan Gracia

unread,
Jan 15, 2016, 4:32:34 AM1/15/16
to Kurento Public, shada...@gmail.com
Hey! I see the line "Error: Media elements does not share pipeline has given you the clue ;-)

Ivan Gracia



karthike...@gmail.com

unread,
Jan 16, 2016, 4:19:31 AM1/16/16
to kurento, shada...@gmail.com
Enter code here...

Hello Ivan,
    Exactly that error line gave me a clue when I thought bit deeper on it.. :) so cheers..

    Now I tried to increase the resolution of the video from default 480p to 720p even to 1080p. When I searched for the similar topic in group I found your answer in this link :  https://groups.google.com/forum/#!msg/kurento/KvmpWvUjs_8/0V5yLebRy4MJ but I have also seen that you have said "Those constraints are not according to the specification." in few other questions for same mediaConstraints format . I tried like this :

                var constraints = {
                                audio: {
                                optional: [{
                                sourceId: mikeId
                                   }]
                                },

                                video: {
                                optional: [{
                                      maxWidth : 1080,
 minWidth : 720,
                                     sourceId: cameraId
                                    }]
                                }
                             };

                var options = {
                        localVideo: video,
                        mediaConstraints : constraints,
                        onicecandidate : onIceCandidate
                        }
                webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerSendonly(options, function(error)

But no success.. Error was "failed to execute 'webkitGetUserMedia' or 'Navigator ': malformed constraints object "
How can I set the resolution ??

Thanks
Karthik  Vaidya

On Tuesday, December 22, 2015 at 3:32:57 PM UTC+5:30, shada...@gmail.com wrote:

karthike...@gmail.com

unread,
Jan 16, 2016, 4:53:57 AM1/16/16
to kurento, shada...@gmail.com
Heyy !! :) I got it working.. just made small changes.. :) :P

var constraints = {
                                audio: {
                                optional: [{
                                sourceId: mikeid
                                   }]
                                },

                                video: {
                                mandatory: {
                                minWidth: 1280,
                                minHeight: 720,
                                minFrameRate: 30
                                        },
                                optional: [{
                                sourceId: cameraid
                                    }]
                                }
                             };


Now going good..
Cheers 


On Tuesday, December 22, 2015 at 3:32:57 PM UTC+5:30, shada...@gmail.com wrote:

Ivan Gracia

unread,
Jan 18, 2016, 4:34:56 AM1/18/16
to Kurento Public, shada...@gmail.com
Cool! But watch it, as those constraints are still not according to spec ;-) They should be something similar to this

var constraints = {
    audio: false,
    video: {
        width: { min: 1024, ideal: 1280, max: 1920 },
        height: { min: 576, ideal: 720, max: 1080 },
    }
};
Check this great stackoverflow answer. You can also use this test page to check the effect with different values.


Ivan Gracia



karthike...@gmail.com

unread,
Jan 20, 2016, 8:01:01 AM1/20/16
to kurento, shada...@gmail.com
Thanks Ivan, I modified the constraints as you suggested.. :) :)


On Tuesday, December 22, 2015 at 3:32:57 PM UTC+5:30, shada...@gmail.com wrote:

Ivan Gracia

unread,
Jan 20, 2016, 8:03:57 AM1/20/16
to kurento, shada...@gmail.com
You are welcome ;-)

karthike...@gmail.com

unread,
Jan 21, 2016, 1:52:49 AM1/21/16
to kurento, shada...@gmail.com
Hello Ivan :)

Here I am again with another question..:) I am wondering if I can change the audio source and resolution dynamically while my video is being broadcasted and recorded. Is there any such possibilities??  Let me be more clear. Imagine I have 4 microphones connected and visible in dropdown and I am initially broadcasting in 720p. So after some time I wish to switch to mike3 and 1080p without reloading the session.. How can I achieve This..? Please help

Thank You
Karthik 


On Tuesday, December 22, 2015 at 3:32:57 PM UTC+5:30, shada...@gmail.com wrote:

Ivan Gracia

unread,
Jan 21, 2016, 5:28:08 AM1/21/16
to Kurento Public, shada...@gmail.com
Hi Karthik,

Please open a separate thread for this, as it's a totally and unrelated topic. We can continue there :-)

Ivan Gracia



Reply all
Reply to author
Forward
0 new messages