如何将视频文件拆分为图像? [英] How do I split a video file into images?

查看:199
本文介绍了如何将视频文件拆分为图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Aforge.Video.DirectShow从视频文件中捕获帧,但是当我到达此行时它无法正常工作

I am trying to capture frames from a video file using Aforge.Video.DirectShow but it doesn't work properly as when I reach on this line

filesource.NewFrame += filesource_NewFrame;

它给出了一个错误线程0x2094已退出代码259(0x103)。当我尝试stepinto

it gives me an error "The thread 0x2094 has exited with code 259 (0x103)." also when i try to stepinto

filesource_NewFrame 

时,它表示代码没有运行,而

it says code is not running whereas

filesource.IsRunning

为true且收到的帧数是$





is true and frames received are 0.


FileVideoSource filesource = new FileVideoSource();
filesource.Source = "C:\\Users\\Zam\\Videos\\akcent 1-cut.avi";
            Console.WriteLine("Start ");
            
            source.Start();
            int i=0;
            if (filesource.IsRunning)
            {
                Console.WriteLine("it is running and source is: "+source.Source);
                while (i <= filesource.FramesReceived)
                {
                    filesource.NewFrame += filesource_NewFrame;
                    Console.WriteLine("Start and execute ");
                    i++;
                }
            }
            else Console.WriteLine("File is not running");
        }

        void filesource_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            mypic.Image = new Bitmap(eventArgs.Frame, 300, 300);
            Console.WriteLine("Working.....");
        }

推荐答案

尝试在while循环外注册事件处理程序。

filesource.NewFrame + = filesource_NewFrame;



我还建议你创建一个表单应用程序而不是控制台应用程序来活动线程。
try registering the event handler outside the while loop.
filesource.NewFrame += filesource_NewFrame;

Also i will suggest you to create a forms application instead of console application to alive the thread.


这篇关于如何将视频文件拆分为图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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