Why picturebox is never updated?

I have a very simple forms app where i read a video from my computer and for each frame i want to update picturebox with the current frame. I thought it would be straight forward, but my picturebox is always empty.

private void loadPicture()
{
    VideoFileReader reader = new VideoFileReader();
    reader.Open("local link to video");
    Console.WriteLine(reader.FrameCount);
    for (int i = 0; i < reader.FrameCount; i++)
    {
        Bitmap videoFrame = reader.ReadVideoFrame();
        if (pictureBox1.Image != null)
        {
            pictureBox1.Dispose();
        }
        pictureBox1.Image = videoFrame;
        //Console.WriteLine(pictureBox1.Image.Height);
        videoFrame.Dispose();
    }
    reader.Close();
}

private void Form1_Load_1(object sender, EventArgs e)
{
    loadPicture();
}

I use the Aforge.Video.FFMPEG library to read the video.

What am i doing wrong?


Source: forms

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.