简体   繁体   中英

Play specific frames in video using C#

I am trying to play part of the video(in this example from frame no 1 to frame 299) in c#. I tried with below code, it works perfectly for single frame but does not display anything after addition of loop. The code does not throw any errors.

        private void button2_Click(object sender, EventArgs e)
        {
            // Open video file
            VideoFileReader reader = new VideoFileReader();
            reader.Open(@"c:\Users\Replay.avi");

            // Read frame no. 1 to 300 and display in picturebox
            for (int j = 1; j < 300; j++)
             {

                Bitmap replay_frame = reader.ReadVideoFrame();
                pictureBox1.Image = replay_frame;
            }
            reader.Close();

        }

Whats wrong with the above code?

I know this is very old but I needed the same thing and found this. All you are missing is pictureBox1.Refresh(); inside your loop. The new image doesn't show up until the picture box is refreshed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM