muaz-khan / RecordRTC

RecordRTC is WebRTC JavaScript library for audio/video as well as screen activity recording. It supports Chrome, Firefox, Opera, Android, and Microsoft Edge. Platforms: Linux, Mac and Windows.
https://www.webrtc-experiment.com/RecordRTC/
MIT License
6.54k stars 1.75k forks source link

setRecordingDuration does not work under 1 second #780

Open tomatopuree opened 2 years ago

tomatopuree commented 2 years ago

Hello,

rrtc.setRecordingDuration(time_in_ms)

For time_in_ms here, anything below 1000 defaults to video chunks 1000 ms long. Is it possible to reduce the chunk size?

Thank you

tomatopuree commented 2 years ago

Hello,

I was able to vary the video chunk size by modifying handleRecordingDuration in RecordRTC.js. Specifically:

    function handleRecordingDuration(counter) {
        counter = counter || 0;

        if (self.state === 'paused') {
            setTimeout(function() {
                handleRecordingDuration(counter);
            }, 300);
            return;
        }

        if (self.state === 'stopped') {
            return;
        }

        if (counter >= self.recordingDuration) {
            stopRecording(self.onRecordingStopped);
            return;
        }

        counter += 300;

        setTimeout(function() {
            handleRecordingDuration(counter);
        }, 300);
    }

I am using these small chunks to continuously transfer video from a client to a server. At server side, I merge these recordings together with ffmpeg.

When I do so I see that the merged video is missing the frames in between the chunks, and the frames which do end up at the beginning or end of chunks have a slight patchy red hue to them.

I use the value of 300 because I get video from a WebRTC stream showing a video with 30 frames per second.

What milisecond value should I specify here instead of 300 to reproduce a smooth video whose chunks do not drop frames?

Thank you