Is it possible to transfer part of the screen for the local network in real time? ScreenCaptureJob can only transfer a stream to a file, and if you want to transfer this file, it is blocked because it is being used by another process.
jobScreenCap = new ScreenCaptureJob();
job = new LiveJob();
var capRect = new System.Drawing.Rectangle(0, 0, 300, 200);
jobScreenCap.CaptureRectangle = capRect;
jobScreenCap.ScreenCaptureVideoProfile = new ScreenCaptureVideoProfile();
jobScreenCap.ScreenCaptureVideoProfile.Force16Pixels = true;
EncoderDevice device = jobScreenCap.VideoDeviceSource;
jobScreenCap.OutputPath = @"C:\output\ScreenCap";
var fileName = @"C:\output\ScreenCap\test1.ismv";
jobScreenCap.OutputScreenCaptureFileName = fileName;
jobScreenCap.Start();
LiveFileSource fileSource = job.AddFileSource(fileName);
job.ActivateSource(fileSource);
var format = new PullBroadcastPublishFormat();
format.BroadcastPort = 8080;
job.PublishFormats.Add(format);
job.StartEncoding();
EDIT:
New problem, it does not work in real time. I have a delay of 10 seconds, I need in real time or at least 1 second. It does not go through the Internet
Server Code:
job = new LiveJob();
Collection<EncoderDevice> devices = EncoderDevices.FindDevices(EncoderDeviceType.Video);
EncoderDevice device = devices[0];
LiveDeviceSource source = job.AddDeviceSource(device, null);
source.ScreenCaptureSourceProperties = new ScreenCaptureSourceProperties
{
CaptureCursor = true,
CaptureLargeCursor = false,
FrameRate = 6,
CaptureLayeredWindow = true,
Height =600,
Width = 800,
Left = 0,
Top = 0,
};
job.ActivateSource(source);
job.ApplyPreset(LivePresets.VC1256kDSL16x9);
var format = new PullBroadcastPublishFormat {BroadcastPort = 8080};
job.PublishFormats.Add(format);
var data = job.BufferWindowSize;
job.StartEncoding();
Player Code:
<Window x:Class="XescPlayer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="600" Width="800">
<Grid>
<MediaElement Name="VideoControl" Source="http://localhost:8080" />
</Grid>
source
share