繁体   English   中英

使用 C# 播放视频中的特定帧

[英]Play specific frames in video using C#

我正在尝试在 c# 中播放部分视频(在此示例中,从第 1 帧到第 299 帧)。 我尝试使用下面的代码,它适用于单帧但在添加循环后不显示任何内容。 该代码不会引发任何错误。

        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();

        }

上面的代码有什么问题?

我知道这已经很老了,但我需要同样的东西并找到了这个。 你所缺少的只是 pictureBox1.Refresh(); 在你的循环里面。 刷新图片框后,新图像才会显示

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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