Upload thumbnails to S3

This commit is contained in:
2023-08-01 23:08:57 +01:00
parent 99ad1dc439
commit d2b56c14f9
20 changed files with 482 additions and 110 deletions

View File

@ -0,0 +1,29 @@
using FFMpegCore;
using NostrStreamer.Database;
namespace NostrStreamer.Services.Thumbnail;
public abstract class BaseThumbnailService
{
protected readonly ILogger Logger;
protected readonly Config Config;
protected BaseThumbnailService(Config config, ILogger logger)
{
Config = config;
Logger = logger;
}
protected async Task<string> GenerateThumbnail(UserStream stream)
{
var path = Path.ChangeExtension(Path.GetTempFileName(), ".jpg");
var cmd = FFMpegArguments
.FromUrlInput(new Uri(Config.RtmpHost, $"{stream.Endpoint.App}/source/{stream.User.StreamKey}?vhost=hls.zap.stream"))
.OutputToFile(path, true, o => { o.ForceFormat("image2").WithCustomArgument("-vframes 1"); })
.CancellableThrough(new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
Logger.LogInformation("Running command {cmd}", cmd.Arguments);
await cmd.ProcessAsynchronously();
return path;
}
}