Skip to content

Commit

Permalink
Improve user experience, switch to ActiPro Avalonia theme, update Ava…
Browse files Browse the repository at this point in the history
…lonia packages, update readme, minor changes
  • Loading branch information
0x90d committed Oct 24, 2023
1 parent 313d89a commit 5d64ab2
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 318 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Video Duplicate Finder is a cross-platform software to find duplicated video (an
#### FFmpeg & FFprobe:

#### Windows user:
Get latest package from https://ffmpeg.org/download.html I recommend the full (GPL) shared version. If you want to use native ffmpeg binding for much faster speed you must download the **5.0 stable shared** version.
Get latest package from https://ffmpeg.org/download.html I recommend the full (GPL) shared version. If you want to use native ffmpeg binding you **must** use the shared version.

Extract ffmpeg and ffprobe into the same directory of VDF.GUI.dll. Or into a sub folder called `bin`. Or make sure it can be found in `PATH` system environment variable
Extract ffmpeg and ffprobe into the same directory of VDF.GUI.dll or into a sub folder called `bin`. Or make sure it can be found in `PATH` system environment variable

#### Linux user:
Installing ffmpeg:
Expand All @@ -42,15 +42,20 @@ You may get a permission error. Open system settings of your Mac, go to `Privacy
<img src="https://user-images.githubusercontent.com/46010672/129763067-8855a538-4a4f-4831-ac42-938eae9343bd.png" width="510">

# License
Video Duplicate Finder is licensed under GPLv3
Video Duplicate Finder uses ffmpeg / ffprobe (not included) which is licensed under LGPL 2.1 / GPL v2
Video Duplicate Finder is licensed under GPLv3

# Credits / Third Party
- [Avalonia](https://github.com/AvaloniaUI/Avalonia)
- [ActiPro Avalonia Controls (Free Edition)](https://github.com/Actipro/Avalonia-Controls)
- [FFmpeg.AutoGen](https://github.com/Ruslan-B/FFmpeg.AutoGen)
- [protobuf-net](https://github.com/protobuf-net/protobuf-net)
- [SixLabors.ImageSharp](https://github.com/SixLabors/ImageSharp)

# Building
- .NET Core 6.x
- Visual Studio 2022
- Avalonia VS Extension is recommended but not required
- .NET 7.x
- Visual Studio 2022 is recommended

# Committing
- Your pull request should only contain code for a single addition or fix
- Create a pull request for each addition or fix - do NOT merge them into one PR
- Unless it refers to an existing issue, write into your pull request what it does
- For larger PRs I recommend you create an issue for discussion first
2 changes: 1 addition & 1 deletion VDF.Core/FFTools/FFmpegNative/FFmpegHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private static bool FindFFmpegLibraryFiles() {
return false;
}

public static bool DoFFmpegLibraryFilesExist {
internal static bool DoFFmpegLibraryFilesExist {
get {
if (ffmpegLibraryFound)
return true;
Expand Down
6 changes: 3 additions & 3 deletions VDF.Core/Utils/GrayBytesUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static bool VerifyGrayScaleValues(byte[] data, double darkProcent = 80) {

byte[] buffer = new byte[GrayByteValueLength];
int stride = 0;
stride = tempImage.GetPixelRowSpan(0).Length;
stride = tempImage.GetPixelRowSpan(0).Length;
int bytes = stride * original.Height;

int count = 0, all = original.Width * original.Height;
Expand Down Expand Up @@ -130,14 +130,14 @@ public static byte[] FlipGrayScale(byte[] img) {
for (int i = 0; i < vImg.Length; i++)
vImg_flipped[i] = Avx2.Shuffle(vImg[i], vFlipp_shuf[0]);
}
else if (Sse2.IsSupported) {
else if (Sse3.IsSupported) {
flip_img = new byte[img.Length];
Span<Vector128<byte>> vImg = MemoryMarshal.Cast<byte, Vector128<byte>>(img);
Span<Vector128<byte>> vImg_flipped = MemoryMarshal.Cast<byte, Vector128<byte>>(flip_img);
Span<Vector128<byte>> vFlipp_shuf = MemoryMarshal.Cast<byte, Vector128<byte>>(flipp_shuf256);

for (int i = 0; i < vImg.Length; i++)
vImg_flipped[i] = Avx2.Shuffle(vImg[i], vFlipp_shuf[0]);
vImg_flipped[i] = Ssse3.Shuffle(vImg[i], vFlipp_shuf[0]);
}
else {
flip_img = (byte[])img.Clone();
Expand Down
9 changes: 6 additions & 3 deletions VDF.GUI/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:VDF.GUI"
xmlns:actipro="http://schemas.actiprosoftware.com/avaloniaui"
RequestedThemeVariant="Dark">

<Application.Styles>
<FluentTheme />
<!--<FluentTheme />
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml" />
<!--<StyleInclude Source="resm:Avalonia.Controls.DataGrid.Themes.Fluent.xaml?assembly=Avalonia.Controls.DataGrid" />-->
<StyleInclude Source="/Styles/Styles.xaml" />
--><!--<StyleInclude Source="resm:Avalonia.Controls.DataGrid.Themes.Fluent.xaml?assembly=Avalonia.Controls.DataGrid" />--><!--
<StyleInclude Source="/Styles/Styles.xaml" />-->
<actipro:ModernTheme />
<actipro:ModernTheme Includes="NativeDataGrid" />
</Application.Styles>
</Application>
2 changes: 1 addition & 1 deletion VDF.GUI/Data/SettingsFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public static void SaveSettings(string? path = null) {
File.WriteAllText(path, JsonSerializer.Serialize(instance));
}

bool _UseMica = true;
bool _UseMica = false;
[JsonPropertyName("UseMica")]
public bool UseMica {
get => _UseMica;
Expand Down
14 changes: 10 additions & 4 deletions VDF.GUI/Mvvm/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
//

using System.Globalization;
using ActiproSoftware.UI.Avalonia.Themes;
using Avalonia.Data.Converters;
using Avalonia.Media;
using Avalonia.Styling;
using VDF.GUI.Data;

namespace VDF.GUI.Mvvm {
public sealed class NegateBoolConverter : IValueConverter {
Expand All @@ -28,9 +31,12 @@ static class Values {
public static readonly SolidColorBrush GreenBrush = new();
public static readonly SolidColorBrush RedBrush = new();
static Values() {
GreenBrush.Color = Colors.LimeGreen;
RedBrush.Color = Colors.PaleVioletRed;
App.Current!.TryGetResource(ThemeResourceKind.ControlBackgroundBrushSolidSuccess.ToResourceKey(), SettingsFile.Instance.DarkMode ? ThemeVariant.Dark : ThemeVariant.Light, out var greenBrush);
GreenBrush.Color = ((SolidColorBrush)greenBrush!).Color;
App.Current.TryGetResource(ThemeResourceKind.ControlBackgroundBrushSolidDanger.ToResourceKey(), SettingsFile.Instance.DarkMode ? ThemeVariant.Dark : ThemeVariant.Light, out var redBrush);
RedBrush.Color = ((SolidColorBrush)redBrush!).Color;
}

}
public sealed class IsBestConverter : IValueConverter {
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
Expand All @@ -40,7 +46,7 @@ public object Convert(object? value, Type targetType, object? parameter, Culture
}

static class ExtraShortDateTimeFormater {
static string FormatString;
static readonly string FormatString;
public static string DateToString(DateTime value) => String.Format(FormatString, value);
static ExtraShortDateTimeFormater() {
// "g" would be something like "4/10/2008 6:30 AM"
Expand All @@ -52,7 +58,7 @@ static ExtraShortDateTimeFormater() {
}
}
public sealed class ExtraShortDateTimeConverter : IValueConverter {

public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => ExtraShortDateTimeFormater.DateToString((DateTime)value!);

public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
Expand Down
20 changes: 7 additions & 13 deletions VDF.GUI/VDF.GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,19 @@
<None Remove="Properties\**" />
</ItemGroup>
<ItemGroup>
<None Remove="Styles\Styles.xaml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.4" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.4" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.4" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.4" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.4" />
<PackageReference Include="ActiproSoftware.Controls.Avalonia" Version="23.1.0" />
<PackageReference Include="ActiproSoftware.Controls.Avalonia.Themes.DataGrid" Version="23.1.0" />
<PackageReference Include="Avalonia" Version="11.0.5" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.5" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.5" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.5" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.5" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.2" />
<PackageReference Include="DynamicExpresso.Core" Version="2.16.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VDF.Core\VDF.Core.csproj" />
</ItemGroup>
<ItemGroup>
<AvaloniaResource Update="Styles\Styles.xaml">
<Generator>MSBuild:Compile</Generator>
</AvaloniaResource>
</ItemGroup>
<ItemGroup>
<Compile Update="Views\DatabaseViewer.xaml.cs">
<DependentUpon>DatabaseViewer.xaml</DependentUpon>
Expand Down
39 changes: 33 additions & 6 deletions VDF.GUI/ViewModels/MainWindowVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Diagnostics;
using System.Linq;
using System.Reactive;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using Avalonia;
Expand Down Expand Up @@ -357,7 +358,7 @@ void BuildDuplicatesView() {



public static ReactiveCommand<Unit, Unit> LatestReleaseCommand => ReactiveCommand.CreateFromTask(async () => {
public static ReactiveCommand<Unit, Unit> LatestReleaseCommand => ReactiveCommand.CreateFromTask(async () => {
try {
Process.Start(new ProcessStartInfo {
FileName = "https://github.com/0x90d/videoduplicatefinder/releases",
Expand Down Expand Up @@ -714,15 +715,41 @@ private static bool AlternativeOpen(string cmdSingle, string cmdMulti, List<Dupl
}

if (!SettingsFile.Instance.UseNativeFfmpegBinding && !ScanEngine.FFmpegExists) {
await MessageBoxService.Show("Cannot find FFmpeg. Please follow instructions on Github and restart VDF");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
await MessageBoxService.Show("Cannot find FFmpeg executable. The easiest solution is to download ffmpeg and place it in VDF 'bin' folder. Otherwise please follow instructions on Github and restart VDF");
}
else {
await MessageBoxService.Show("Cannot find FFmpeg. Please follow instructions on Github and restart VDF");
}
return;
}
if (!ScanEngine.FFprobeExists) {
await MessageBoxService.Show("Cannot find FFprobe. Please follow instructions on Github and restart VDF");
if (SettingsFile.Instance.UseNativeFfmpegBinding && !ScanEngine.NativeFFmpegExists) {
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
if (await MessageBoxService.Show("Cannot find shared FFmpeg libraries. Would you like to open the download page? Otherwise either uncheck 'Use native ffmpeg binding' in settings or please follow instructions on Github and restart VDF.", MessageBoxButtons.Yes | MessageBoxButtons.No) == MessageBoxButtons.Yes) {
try {
int ffmpegMajorVersion = FFmpeg.AutoGen.ffmpeg.LibraryVersionMap["avcodec"] / 10;
Process.Start(new ProcessStartInfo($"https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n{ffmpegMajorVersion}.0-latest-win64-gpl-shared-{ffmpegMajorVersion}.0.zip") {
UseShellExecute = true
});
await MessageBoxService.Show("After downloading, please extract and copy the 'bin' (!!) folder into VDF folder. Then restart VDF");
}
catch {
await MessageBoxService.Show("Failed to open download page. Please visit: https://github.com/BtbN/FFmpeg-Builds/releases");
}
}
}
else {
await MessageBoxService.Show("Cannot find shared FFmpeg libraries. Either uncheck 'Use native ffmpeg binding' in settings or please follow instructions on Github and restart VDF");
}
return;
}
if (SettingsFile.Instance.UseNativeFfmpegBinding && !ScanEngine.NativeFFmpegExists) {
await MessageBoxService.Show("Cannot find shared FFmpeg libraries. Either uncheck 'Use native ffmpeg binding' in settings or please follow instructions on Github and restart VDF");
if (!ScanEngine.FFprobeExists) {
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
await MessageBoxService.Show("Cannot find FFprobe executable. The easiest solution is to download ffmpeg/ffprobe and place it in VDF 'bin' folder. Otherwise please follow instructions on Github and restart VDF");
}
else {
await MessageBoxService.Show("Cannot find FFprobe. Please follow instructions on Github and restart VDF");
}
return;
}
if (SettingsFile.Instance.UseNativeFfmpegBinding && SettingsFile.Instance.HardwareAccelerationMode == Core.FFTools.FFHardwareAccelerationMode.auto) {
Expand Down
Loading

0 comments on commit 5d64ab2

Please sign in to comment.