使用Accord Framework时获取System.Runtime.InteropServices.SEHException

时间:2017-03-10 16:17:32

标签: c# asp.net accord.net

我正在通过调用System.Runtime.InteropServices.SEHException

尝试使用Accord Framework创建avi文件时,使用“外部组件抛出异常”消息writer.Open("test.avi", width, height, 25, VideoCodec.MPEG4);

这是我的代码段:

    public class Recording
{
    int width = 320;
    int height = 240;

    int framesCountTest = 0;

    // create instance of video writer
    VideoFileWriter writer = new VideoFileWriter();

    public Recording()
    {
        try
        {
            // create new video file, , Here I'm getting the exception
            writer.Open("test.avi", width, height, 25, VideoCodec.MPEG4);
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }

    public void WriteFrameToFile(Bitmap image)
    {
        if (framesCountTest >= 60) return;

        // create a bitmap to save into the video file
        image = new Bitmap(width, height, PixelFormat.Format24bppRgb);

        writer.WriteVideoFrame(image);

        framesCountTest++;
        if (framesCountTest >= 60) { writer.Close(); }
    }
}

堆栈跟踪:

        StackTrace  "   at sws_getContext(Int32 , Int32 , PixelFormat , Int32 , Int32 , PixelFormat , Int32 , SwsFilter* , SwsFilter* , Double* )\r\n   at Accord.Video.FFMPEG.?A0x9c42894c.open_video(WriterPrivateData data)\r\n   at Accord.Video.FFMPEG.VideoFileWriter.Open(String fileName, Int32 width, Int32 height, Int32 frameRate, VideoCodec codec, Int32 bitRate, AudioCodec audioCodec, Int32 audioBitrate, Int32 sampleRate, Int32 channels)\r\n   at Accord.Video.FFMPEG.VideoFileWriter.Open(String fileName, Int32 width, Int32 height, Int32 frameRate, VideoCodec codec)\r\n   at ELSY.Core.Streaming.Recording..ctor() in C:\\Users\\ustr\\Documents\\Visual Studio 2015\\Projects\\TestVid\\H3\\Core.Stream\\Recording.cs:line 107"   string

0 个答案:

没有答案