Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unfortunate delay #54

Open
nullptr128 opened this issue Sep 29, 2015 · 0 comments
Open

Unfortunate delay #54

nullptr128 opened this issue Sep 29, 2015 · 0 comments

Comments

@nullptr128
Copy link

Hello! I would want to ask if is there a possibility to reduce lag between reality and video produced by MediaStreamRecorder? Because when I move my head when camera is on me, "ondataready" produced blob is from ~2-3 seconds in the past.

I've tried reducing bufferSize to 256kb and changing type property in mediaRecorder, no success.

This is my code:

        recorder = new MediaStreamRecorder( stream );
        recorder.stream = stream;
        recorder.mimeType = 'video/mp4';
        recorder.videoWidth = 640;
        recorder.videoHeight = 480;
        recorder.bufferSize = 256;
        recorder.type = MediaRecorderWrapper;
        recorder.ondataavailable = function ( blob ) {
            console.log( blob );
            var objUrl = URL.createObjectURL( blob );
            video.src = objUrl;
            var dataBlob = { url: objUrl , frame: frameIndex++ };
            console.log( 'emitting data' );
            socket.emit( 'stream-data' , dataBlob , function () {
                var lengthEstimateKB = (dataBlob.url.length + 20) / 1024;
                transferStack += lengthEstimateKB;
                allowSend = true;
            } );
        }

        recorder.start( 50 );

        setInterval( function() {
            context.drawImage( video , 0 , 0 , video.videoWidth , video.videoHeight );
        } , 30 );

As you can see I am outputting ondataavailable immediately to video.src and then I am copying video contents into canvas to eliminate flicker by changing video.src attribute. But things in both my

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant