Add FFmpeg Downloader
This commit is contained in:
27
Flashcap-Demo/FFmpeg.cs
Normal file
27
Flashcap-Demo/FFmpeg.cs
Normal 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}%";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,9 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FlashCap" Version="1.11.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
|
||||
<PackageReference Include="System.Reactive" Version="6.1.0" />
|
||||
<PackageReference Include="Xabe.FFmpeg.Downloader" Version="6.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -5,8 +5,9 @@ namespace Flashcap_Demo;
|
||||
|
||||
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 deviceDescriptors = device.GetDescriptors()
|
||||
.Where(x=>x.Characteristics.Length > 0)
|
||||
@@ -20,6 +21,13 @@ internal static class Program
|
||||
Console.WriteLine($"Chosen:\n\t" +
|
||||
$"{captureDeviceDescriptor}\n\t" +
|
||||
$"{characteristic}");
|
||||
if (!backgroundDownload.IsCompleted)
|
||||
{
|
||||
await backgroundDownload;
|
||||
}
|
||||
|
||||
Console.WriteLine("We have both a selected Device and FFmpeg");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user