sipsorcery-org / sipsorcery

A WebRTC, SIP and VoIP library for C# and .NET. Designed for real-time communications apps.
https://sipsorcery-org.github.io/sipsorcery
Other
1.42k stars 431 forks source link

Gdigrab Screen Capture Issue With Scaled Display #1071

Closed nodminger closed 1 month ago

nodminger commented 6 months ago

I have two displays and wanted to capture both the display and stream them using FFMpegFileAndDeviceTest Source code. When I run this raw ffmpeg command ffmpeg -f gdigrab -offset_x 0 -offset_y 0 -video_size 1920x1722 -i desktop output.mp4 I am able to capture a video. But when I use the same attributes (offset_x: 0, offset_y: 0, video_size: 1920x1722, i(path): desktop) in Sipsorcery by modifying this line videoSource = new SIPSorceryMedia.FFmpeg.FFmpegScreenSource("desktop", new System.Drawing.Rectangle(0, 0, 1920, 1722), 10); I get this error image

why does the total height reduces. This only happens when the screen is scaled. But even then, with raw ffmpeg command I am able to capture the stream. Only when I use FFMpeg from Sipsorcery, this issue arises.

My Two Displays: 1: 1920x954 : 100% Scaled 2: 1024x768 : 125% Scaled

When I use FFMpeg directly i get the height as 1722. image

ChristopheI commented 6 months ago

This use case (broadcast 2 screens in same time) was not targeted. Don't hesitate to create a PR :)

nodminger commented 6 months ago

I attempted to share my second screen alone, and that's when I encountered this issue. After checking further, I discovered that FFMpeg v4 exhibits this problem by default. Even when I executed this raw code, ffmpeg -f gdigrab -offset_x 0 -offset_y 0 -video_size 1920x1722 -i desktop output.mp4, the error persisted. But, with FFMpeg v6, I no longer encounter this error using the same raw command (though the issue still persists in Sipsorcery). So, I believe this issue is related to FFMpeg.Autogen or SipsorceryMedia.FFMpeg.