Add FFmpeg Downloader

This commit is contained in:
2026-01-07 23:57:39 +01:00
parent 729e33881b
commit fa33d78ac2
3 changed files with 37 additions and 4 deletions

27
Flashcap-Demo/FFmpeg.cs Normal file
View File

@@ -0,0 +1,27 @@
using Xabe.FFmpeg;
using Xabe.FFmpeg.Downloader;
namespace Flashcap_Demo;
public class FFmpeg
{
public static Task DownloadBackground()
{
return FFmpegDownloader.GetLatestVersion(FFmpegVersion.Official, new Progress<ProgressInfo>(info =>
{
if (info.TotalBytes<=1)return;
var percentageDone = (double)info.DownloadedBytes / info.TotalBytes;
Console.Write($"Downloaded {FormatBytes(info.DownloadedBytes)} of {FormatBytes(info.TotalBytes)}, {FormatPercentage(percentageDone)}\r");
}));
}
private static string FormatBytes(long bytes)
{
return $"{bytes / 1000000.0d:#00.00}MB";
}
private static string FormatPercentage(double percentage)
{
return $"{percentage*100:00.00}%";
}
}

View File

@@ -9,9 +9,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FlashCap" Version="1.11.0" /> <PackageReference Include="Xabe.FFmpeg.Downloader" Version="6.0.2" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
<PackageReference Include="System.Reactive" Version="6.1.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -5,8 +5,9 @@ namespace Flashcap_Demo;
internal static class Program internal static class Program
{ {
public static void Main(string[] args) public static async Task Main(string[] args)
{ {
var backgroundDownload = FFmpeg.DownloadBackground();
var device = new CaptureDevices(); var device = new CaptureDevices();
var deviceDescriptors = device.GetDescriptors() var deviceDescriptors = device.GetDescriptors()
.Where(x=>x.Characteristics.Length > 0) .Where(x=>x.Characteristics.Length > 0)
@@ -20,6 +21,13 @@ internal static class Program
Console.WriteLine($"Chosen:\n\t" + Console.WriteLine($"Chosen:\n\t" +
$"{captureDeviceDescriptor}\n\t" + $"{captureDeviceDescriptor}\n\t" +
$"{characteristic}"); $"{characteristic}");
if (!backgroundDownload.IsCompleted)
{
await backgroundDownload;
}
Console.WriteLine("We have both a selected Device and FFmpeg");
} }
} }