Workaround for incorrect output_idx issue

This commit is contained in:
Jaex 2023-07-14 00:52:22 +03:00
parent f7a8d504ee
commit 4f4f983b9a

View file

@ -29,6 +29,7 @@
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
@ -123,13 +124,14 @@ public string GetFFmpegArgs(bool isCustom = false)
}
else if (FFmpeg.VideoSource.Equals(FFmpegCLIManager.SourceDDAGrab, StringComparison.OrdinalIgnoreCase))
{
Screen[] screens = Screen.AllScreens.OrderBy(x => !x.Primary).ToArray();
int monitorIndex = 0;
Rectangle captureArea = Screen.AllScreens[0].Bounds;
Rectangle captureArea = screens[0].Bounds;
int maxIntersectionArea = 0;
for (int i = 0; i < Screen.AllScreens.Length; i++)
for (int i = 0; i < screens.Length; i++)
{
Screen screen = Screen.AllScreens[i];
Screen screen = screens[i];
Rectangle intersection = Rectangle.Intersect(screen.Bounds, CaptureArea);
int intersectionArea = intersection.Width * intersection.Height;
@ -139,14 +141,14 @@ public string GetFFmpegArgs(bool isCustom = false)
monitorIndex = i;
captureArea = new Rectangle(intersection.X - screen.Bounds.X, intersection.Y - screen.Bounds.Y, intersection.Width, intersection.Height);
if (FFmpeg.IsEvenSizeRequired)
{
captureArea = CaptureHelpers.EvenRectangleSize(captureArea);
}
}
}
if (FFmpeg.IsEvenSizeRequired)
{
captureArea = CaptureHelpers.EvenRectangleSize(captureArea);
}
// https://ffmpeg.org/ffmpeg-filters.html#ddagrab
AppendInputDevice(args, "lavfi", FFmpeg.IsAudioSourceSelected);
args.Append("-i ddagrab=");