文件创建的速度有多快? [英] How fast is File Creation?

查看:71
本文介绍了文件创建的速度有多快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Codeproject,



我目前正在创建一个屏幕录像机。为此,我每隔40毫秒捕获一次屏幕截图,然后我将所有图像拼凑在一起.avi。截图不是问题,我目前使用DirectX来做到这一点:



Hello Codeproject,

I am currently creating a screen recorder. And for this, I capture a screenshot every 40 miliseconds, I then scrape all the images together in an .avi. Screenshotting is not a problem, I currently use DirectX to do that:

Surface s;
public Surface CaptureScreen()
{
    s = Surface.CreateOffscreenPlain(d, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, SlimDX.Direct3D9.Format.A8R8G8B8, Pool.Scratch);
    d.GetFrontBufferData(0, s);
    return s;
}





问题是保存文件所需的时间超过20毫秒,我循环了这个空白在计时器刻度中,间隔为(1000 / FPS(25))。





Problem is that saving the file requires way more than 20 miliseconds, and I loop this void in a Timer Tick with the Interval of (1000 / FPS(25)).

void Tick_Tick(object sender, EventArgs e)
{
    // -- Stop if not recording.
    if (!Recording)
        return;

    // -- Save the screenshot.
    Surface.ToFile(CaptureScreen(), FolderPath + "image" + Directory.GetFiles(FolderPath).Length + ".jpg", ImageFileFormat.Jpg);

}





这真的非常非常慢。我很想知道是否有人对如何提高速度有任何建议,或者甚至没有保存文件。我不知道。



This is really, really, really slow. And I would love to know if anyone has any suggestions on how to increase the speed, or maybe not even saving the file. I don''t know.

推荐答案

你为什么要挽救帧?文件创建比保持文件打开并在其中写入框架消耗更多资源。一个好的编解码器就更少了。直接制作视频。试试这些例如:

http://www.c-sharpcorner .com / UploadFile / armoghanasif / CaptureDesktopActivities11122005013755AM / CaptureDesktopActivities.aspx [ ^ ]

http://mycomponent.blogspot.hu/2009/04/capture-screen-activitiesvideo-using.html [ ^ ]
Why are you struggling with saving frames? File creation consumes more resources than keeping a file open and writing frames in it. Even less with a good codec. Make the video directly. Try these for example:
http://www.c-sharpcorner.com/UploadFile/armoghanasif/CaptureDesktopActivities11122005013755AM/CaptureDesktopActivities.aspx[^]
http://mycomponent.blogspot.hu/2009/04/capture-screen-activitiesvideo-using.html[^]


这是一种可怕的方法。您不能每20毫秒创建和写入MB的数据到文件。您将完全充斥高清频道。



获取VNC或视频捕获库来执行此操作。他们将比你的自制更有效率地完成工作。
This is a horrible way to do this. You can''t create and write MB''s of data to files every 20 milliseconds. You''ll just completely flood the HD channel.

Get a VNC or Video Capture library to do this. They will do a FAR more efficient job than you''re going to "homebrew".


这篇关于文件创建的速度有多快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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