Search code examples
c#windows-forms-designermjpeg

How do I display an MJPEG stream in a Windows Form application?


I have a video stream which comes as an MJPEG over HTTP.

Is there a way to display such stream in a Windows Form application?

I already have a set of routines for displaying simple JPEGs from a webserver, but not continuous MJPEGs. Maybe the two problems are related.


Solution

  • I have found a library which works rather nicely: http://channel9.msdn.com/coding4fun/articles/MJPEG-Decoder

    You can use it as follows in a C# solution

    // class attribute
    MjpegDecoder m_mjpeg;
    
    // In the constructor
    m_mjpeg = new MjpegDecoder();
    m_mjpeg.FrameReady += mjpeg_FrameReady;
    
    // Private method
    private void mjpeg_FrameReady(object sender, FrameReadyEventArgs e)
    {
    
            yourPictureBox.Image = e.Bitmap;
    }
    

    Source is also available for debugging.