Skip to content

Commit

Permalink
Automatically fix video/audio sources
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaex committed Jan 19, 2024
1 parent a8809da commit 7407df1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
4 changes: 2 additions & 2 deletions GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
[assembly: AssemblyProduct("ShareX")]
[assembly: AssemblyCopyright("Copyright (c) 2007-2024 ShareX Team")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("15.0.1")]
[assembly: AssemblyFileVersion("15.0.1")]
[assembly: AssemblyVersion("15.0.2")]
[assembly: AssemblyFileVersion("15.0.2")]
19 changes: 19 additions & 0 deletions ShareX.ScreenCaptureLib/ScreenRecording/FFmpegOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#endregion License Information (GPL v3)

using ShareX.HelpersLib;
using System;

namespace ShareX.ScreenCaptureLib
{
Expand Down Expand Up @@ -136,5 +137,23 @@ public string Extension
public bool IsAnimatedImage => VideoCodec == FFmpegVideoCodec.gif || VideoCodec == FFmpegVideoCodec.libwebp || VideoCodec == FFmpegVideoCodec.apng;

public bool IsEvenSizeRequired => !IsAnimatedImage;

// TEMP: For backward compatibility
public void FixSources()
{
if (VideoSource.Equals("None", StringComparison.OrdinalIgnoreCase))
{
VideoSource = FFmpegCaptureDevice.None.Value;
}
else if (VideoSource.Equals("GDI grab", StringComparison.OrdinalIgnoreCase))
{
VideoSource = FFmpegCaptureDevice.GDIGrab.Value;
}

if (AudioSource.Equals("None", StringComparison.OrdinalIgnoreCase))
{
AudioSource = FFmpegCaptureDevice.None.Value;
}
}
}
}
19 changes: 18 additions & 1 deletion ShareX/SettingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public static void LoadHotkeysConfig(bool fallbackSupport = true)
HotkeysConfig = HotkeysConfig.Load(HotkeysConfigFilePath, BackupFolder, fallbackSupport);
HotkeysConfig.CreateBackup = true;
HotkeysConfig.CreateWeeklyBackup = true;
HotkeysConfigBackwardCompatibilityTasks();
}

public static void LoadAllSettings()
Expand Down Expand Up @@ -229,9 +230,10 @@ private static void ApplicationConfigBackwardCompatibilityTasks()
}
}

if (Settings.IsUpgradeFrom("15.0.0"))
if (Settings.IsUpgradeFrom("15.0.1"))
{
DefaultTaskSettings.CaptureSettings.ScrollingCaptureOptions = new ScrollingCaptureOptions();
DefaultTaskSettings.CaptureSettings.FFmpegOptions.FixSources();
}
}

Expand Down Expand Up @@ -268,6 +270,21 @@ private static void UploadersConfigBackwardCompatibilityTasks()
}
}

private static void HotkeysConfigBackwardCompatibilityTasks()
{
if (Settings.IsUpgradeFrom("15.0.1"))
{
foreach (TaskSettings taskSettings in HotkeysConfig.Hotkeys.Select(x => x.TaskSettings))
{
if (taskSettings != null && taskSettings.CaptureSettings != null)
{
taskSettings.CaptureSettings.ScrollingCaptureOptions = new ScrollingCaptureOptions();
taskSettings.CaptureSettings.FFmpegOptions.FixSources();
}
}
}
}

public static void CleanupHotkeysConfig()
{
foreach (TaskSettings taskSettings in HotkeysConfig.Hotkeys.Select(x => x.TaskSettings))
Expand Down

0 comments on commit 7407df1

Please sign in to comment.