2

我有几行可以用来录制屏幕的 C# 代码。但我找不到解决方法来确定自定义视频输出大小。我的屏幕分辨率是 1920x1080,虽然我尝试为记录分配新的大小它保持不变。(库:Microsoft Expression Encoder,包括所有依赖项)

我在按钮点击事件中使用的代码:

        ScreenCaptureJob _screenCaptureJob = new ScreenCaptureJob();
        Rectangle _screenRectangle = Screen.PrimaryScreen.Bounds;

        _screenCaptureJob.CaptureRectangle = _screenRectangle;
        _screenCaptureJob.ScreenCaptureVideoProfile.Size = new Size(600, 400); //By doing this Is it supposed to resize original size to 600x400 pixels?
        _screenCaptureJob.ScreenCaptureVideoProfile.AutoFit = true;
        _screenCaptureJob.ShowFlashingBoundary = false;
        _screenCaptureJob.ScreenCaptureVideoProfile.FrameRate = 20;
        _screenCaptureJob.CaptureMouseCursor = true;
        _screenCaptureJob.ScreenCaptureVideoProfile.SmoothStreaming = true;
        _screenCaptureJob.ScreenCaptureVideoProfile.Quality = 20;
        _screenCaptureJob.OutputScreenCaptureFileName = string.Format(@"C:\test.wmv");

        if (File.Exists(_screenCaptureJob.OutputScreenCaptureFileName))
        {
            File.Delete(_screenCaptureJob.OutputScreenCaptureFileName);
        }

        _screenCaptureJob.Start();

提前致谢!

4

1 回答 1

0

您需要做的是将 _screenRectangle 设置为您的自定义尺寸:

_screenCaptureJob.CaptureRectangle = new Rectangle(0, 0, 600, 400);

屏幕录制大小可以不分配。

问候,尼古拉

于 2014-10-06T08:11:08.947 回答