I hosted a .mjpeg file locally http://127.0.0.1/web/Images/Stream/somevideo.mjpeg
I tried a few codes in my cshtml page.
1. Video tag method
<video src="http://127.0.0.1/web/Images/Stream/somevideo.mjpeg" controls></video>
2. img tag method
<img src="http://127.0.0.1/web/Images/Stream/somevideo.mjpeg"/>
3. motionjpeg javascript method
The code below copied from here
<img id="motionjpeg" src="http://127.0.0.1/web/Images/Stream/somevideo.mjpeg" />
<script>
//Using jQuery for simplicity
function motionjpeg(id) {
var image = $(id), src;
if (!image.length) return;
src = image.attr("src");
if (src.indexOf("?") < 0) {
image.attr("src", src + "?"); // must have querystring
}
image.on("load", function() {
// this cause the load event to be called "recursively"
this.src = this.src.replace(/?[^\n]*$/, "?") +
(new Date()).getTime(); // 'this' refers to the image
});
}
$(document).ready(function() {
motionjpeg("#motionjpeg"); // Use the function on the image
});
</script>
4. clipchamp javascript method
The only code that works, however only on Chrome but not IE
<div id="mjpeg_player" style="width:600px;"></div>
<script src='http://127.0.0.1/web/Scripts/jquery-clipchamp-mjpeg-player-plugin-master/src/jquery.clipchamp.mjpeg.player.js'></script>
<script>
$(document).ready(function() {
var mjpegUrl = "http://127.0.0.1/web/Images/Stream/somevideo.mjpeg";
var fps = 20;
var autoloop = true;
$('#mjpeg_player').clipchamp_mjpeg_player(mjpegUrl, fps, autoloop,
function(wrapperElement, playerInterface) {
/*
$('#mjpeg_player_stop').click(function(){
playerInterface.finish();
});
*/
});
});
</script>
FYI, I configured the MIME type of .mpjeg as application/octet-stream
Have you tried
multipart/x-mixed-replace
? You will also have to provide boundary parameter so it will look something like this:multipart/x-mixed-replace; boundary=--boundary
you will have to figure out which boundary is used on your hosted mjpeg file to delimit separate frame contents.Could be that the correct mime-type for M-JPEG i.e. Motion JPEG is