Compare commits
3 Commits
xabe
...
own-wrappe
| Author | SHA1 | Date | |
|---|---|---|---|
| ca8b8a362a | |||
| 2fa0ae063d | |||
| fa33d78ac2 |
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,10 +9,9 @@
|
||||
</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" Version="6.0.2" />
|
||||
<PackageReference Include="FlashCap" Version="1.11.0" />
|
||||
<PackageReference Include="Terminal.Gui" Version="2.0.0-alpha.3931" />
|
||||
<PackageReference Include="Xabe.FFmpeg.Downloader" Version="6.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
|
||||
using FlashCap;
|
||||
using Xabe.FFmpeg;
|
||||
using Terminal.Gui.App;
|
||||
using Terminal.Gui.Configuration;
|
||||
using Terminal.Gui.ViewBase;
|
||||
using Terminal.Gui.Views;
|
||||
|
||||
namespace Flashcap_Demo;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
public async static Task Main(string[] args)
|
||||
public static async Task Main(string[] args)
|
||||
{
|
||||
var backgroundDownload = FFmpeg.DownloadBackground();
|
||||
var app = Application.Create();
|
||||
app.Run<MainWindow>();
|
||||
app.Dispose();
|
||||
var device = new CaptureDevices();
|
||||
var deviceDescriptors = device.GetDescriptors()
|
||||
.Where(x=>x.Characteristics.Length > 0)
|
||||
@@ -21,29 +28,22 @@ internal static class Program
|
||||
Console.WriteLine($"Chosen:\n\t" +
|
||||
$"{captureDeviceDescriptor}\n\t" +
|
||||
$"{characteristic}");
|
||||
if (!backgroundDownload.IsCompleted)
|
||||
{
|
||||
await backgroundDownload;
|
||||
}
|
||||
|
||||
var cancellationTokenSource = new CancellationTokenSource();
|
||||
var mediaInfo = await FFmpeg.GetMediaInfo(captureDeviceDescriptor.Identity.ToString(), cancellationTokenSource.Token);
|
||||
Console.WriteLine("We have both a selected Device and FFmpeg");
|
||||
|
||||
var outName = Path.Join(Directory.GetCurrentDirectory(),"output");
|
||||
|
||||
var parameters =
|
||||
$"-f v4l2 " +
|
||||
$"-framerate {characteristic.FramesPerSecond} " +
|
||||
$"-video_size {characteristic.Width}x{characteristic.Height} " +
|
||||
$"-input_format mjpeg " +
|
||||
$"-y " +
|
||||
$"-report " +
|
||||
$"-i {captureDeviceDescriptor.Identity} " +
|
||||
$"{outName}.mkv";
|
||||
FFmpeg.Conversions.New()
|
||||
.Start(parameters, cancellationTokenSource.Token);
|
||||
// .Build();
|
||||
// Console.WriteLine(cli);
|
||||
|
||||
Console.WriteLine(parameters);
|
||||
await Task.Delay(5000);
|
||||
cancellationTokenSource.Cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
Title = "CapEd";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user