Emgu Capture可以超级快速地播放视频 [英] Emgu Capture plays video super fast

查看:257
本文介绍了Emgu Capture可以超级快速地播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用Emgu播放视频时,其播放速度比应有的速度快。这是相关的代码。

 公共Form1()
{
InitializeComponent();

_capture = new Capture( test.avi);
Application.Idle + = RefreshFrames;
}

保护无效RefreshFrames(对象发送者,EventArgs e)
{
imageBox.Image = _capture.QueryFrame();
}

我尝试使用Capture对象上的SetCaptureProperty方法设置FPS,但是

解决方案

程序没有其他函数调用时,将调用Application.Idle句柄。并且您的计算机拥有免费资源。不能在设定的时间段调用它。

  Timer My_Time = new Timer();而是设置计时器并使用它的刻度功能设置播放速度。

  Timer My_Time = new Timer(); 
int FPS = 30;

公共Form1()
{
InitializeComponent();

//帧速率
My_Timer.Interval = 1000 / FPS;
My_Timer.Tick + =新的EventHandler(My_Timer_Tick);
My_Timer.Start();
_capture = new Capture( test.avi);
}

private void My_Timer_Tick(object sender,EventArgs e)
{
imageBox.Image = _capture.QueryFrame();
}

上面的代码应按您的意愿进行,调整FPS以获得所需的播放速度。如果您还有其他需要让我知道,



欢呼声



Chris


When I am playing back a video using Emgu, it plays back way faster than it should. Here is the relevant code.

public Form1()
{
    InitializeComponent();

    _capture = new Capture("test.avi");
    Application.Idle += RefreshFrames;
}

protected void RefreshFrames(object sender, EventArgs e)
{
    imageBox.Image = _capture.QueryFrame();
}

I tried to set the FPS using the SetCaptureProperty method on the Capture object, but it still plays in super fast motion.

解决方案

The Application.Idle handle is called when no other function is being called by you program and you computer has free resources. It is not designed to be called at set periods. Instead set a timer up and use it's tick function to set the playback speed.

Timer My_Time = new Timer();
int FPS = 30;

public Form1()
{
    InitializeComponent();

    //Frame Rate
    My_Timer.Interval = 1000 / FPS;
    My_Timer.Tick += new EventHandler(My_Timer_Tick);
    My_Timer.Start();
    _capture = new Capture("test.avi");   
}

private void My_Timer_Tick(object sender, EventArgs e)
{
    imageBox.Image = _capture.QueryFrame();
}

The above code should do what you wish, Adjust FPS to get the desired playback speed. If you need anything else let me know,

Cheers

Chris

这篇关于Emgu Capture可以超级快速地播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆