Search code examples
htmlvideomjpeg

How to play mjpeg as video not image?


I have mjpeg stream (generated by ffserver) and I consume this stream as image, like this:

<img src='http://localhost:8090/live.mjpg'>

Basically I can see video within img tag, however it is still an image for a browser -- I don't get any controls like stop/play.

Thus my question, is it possible to consume this stream via video tag to get the controls? I tried it (in Chrome) and I get empty controls box (no video content).

I am not looking for cross-browser ancient compatibility, I am looking for consuming mjpeg video stream as video, not as animated image.


Solution

  • The <video> tag only supports the following mimetypes:

    • video/webm
    • video/ogg
    • video/mp4 (firefox only?)

    (source: MDN)

    so you would need to convert the mjpg (video/x-motion-jpeg) to one of these. You might want to use a proxy server.