streamproc / MediaStreamRecorder

Cross browser audio/video/screen recording. It supports Chrome, Firefox, Opera and Microsoft Edge. It even works on Android browsers. It follows latest MediaRecorder API standards and provides similar APIs.
https://www.webrtc-experiment.com/msr/
MIT License
2.61k stars 562 forks source link

Can It record a video from M-JPEG stream? #100

Open realcrazysun opened 7 years ago

realcrazysun commented 7 years ago

I have a IP camera and I want to record sometimes,thank you!

muaz-khan commented 7 years ago
<script src="https://cdn.webrtc-experiment.com/DetectRTC.js"></script>
<script>
var videoStream;

if (DetectRTC.isVideoSupportsStreamCapturing) {
    var yourVideoElement = document.querySelector('video');

    if ('captureStream' in yourVideoElement) {
        videoStream = yourVideoElement.captureStream(15);
    } else if ('mozCaptureStream' in yourVideoElement) {
        videoStream = yourVideoElement.mozCaptureStream(15);
    } else if ('webkitCaptureStream' in yourVideoElement) {
        videoStream = yourVideoElement.webkitCaptureStream(15);
    }
}

if (videoStream) {
    var recorder = new MediaStreamRecorder(videStream);
    // your MediaStreamRecorder.js code goes here
}
</script>

Requires: Chrome 53+ i.e. Canary; or Firefox.

You can record youtube HTML5 videos; HLS/DASH based HTML5 videos as well.

realcrazysun commented 7 years ago

Thank you for your response.But my question is to record a video from M-JPEG stream,the element in html is like this <img src='http://192.168.43.1:8080/?action=stream'/> ' .The stream is generated by an Android Device ,and real-time output. Is there any way to record the img src?

muaz-khan commented 7 years ago

You can use canvas.drawImage "repeatedly" to draw image on Canvas2D context.

Then you can use above code to capture Canvas stream.

Then you can record Canvas stream as well, using either MediaStreamRecorder or RecordRTC.

noahjerreel commented 7 years ago

Interesting :)

realcrazysun commented 7 years ago

@noahjerreel Any better idea?The method ' canvas.drawImage "repeatedly" ' is not so efficient。

ghost commented 6 years ago

@realcrazysun Have you got any better way to record Mjpeg_streamer?