Commit: aa2768e
Parent: e2865f1

Fix cropping issues

Mårten Åsberg committed on 2026-05-18 at 10:40
src/Cli/Program.cs +6 -18
diff --git a/src/Cli/Program.cs b/src/Cli/Program.cs
index 2ae4b59..42bb2b1 100644
@@ -6,7 +6,6 @@ using Microsoft.Extensions.Logging;
using Slopper.Cli;
using Slopper.Cli.YouTubeAuth;
using Slopper.Domain;
using Slopper.Domain.Describer;
using Slopper.Infrastructure.Ai;
using Slopper.Infrastructure.Database;
using Slopper.Infrastructure.Ffmpeg;
@@ -31,28 +30,17 @@ var logger = app.Services.GetRequiredService<ILogger<Program>>();
using var scope = app.Services.CreateScope();
var timeProvider = scope.ServiceProvider.GetRequiredService<TimeProvider>();
var clipSelector = scope.ServiceProvider.GetRequiredService<ClipSelector>();
var clipRepository = scope.ServiceProvider.GetRequiredService<IClipRepository>();
var clipDescriber = scope.ServiceProvider.GetRequiredService<ClipDescriber>();
var clipExtractor = scope.ServiceProvider.GetRequiredService<IClipExtractor>();
var media = new MediaItem(Guid.Parse(args[0]), args[1], new Subtitles.Embedded(int.Parse(args[2])));
var (start, duration) = await clipSelector.PickClip(media, lifetime.ApplicationStopping);
var utcNow = timeProvider.GetUtcNow();
var clipId = Guid.CreateVersion7(utcNow);
var clipPath = Path.Join(args[3], $"{clipId}.mp4");
var descriptionTask = clipDescriber.DescribeClip(media, start, duration, lifetime.ApplicationStopping);
var media = new MediaItem(Guid.CreateVersion7(utcNow), args[0], new Subtitles.Embedded(int.Parse(args[1])));
await clipExtractor.ExtractClip(media, start, duration, clipPath, lifetime.ApplicationStopping);
var start = TimeSpan.Parse(args[2]);
var duration = TimeSpan.Parse(args[3]);
var description = await descriptionTask;
var clipId = Guid.CreateVersion7(utcNow);
var clipPath = Path.Join(args[4], $"{clipId}.mp4");
var clip = new Clip(clipId, media.Id, clipPath, start, duration, utcNow, description.Caption)
{
Tags = description.Tags,
};
await clipRepository.Save(clip, lifetime.ApplicationStopping);
await clipExtractor.ExtractClip(media, start, duration, clipPath, lifetime.ApplicationStopping);
await app.StopAsync();
src/Cli/Properties/launchSettings.json +1 -2
diff --git a/src/Cli/Properties/launchSettings.json b/src/Cli/Properties/launchSettings.json
index 756f498..6891cb5 100644
@@ -7,8 +7,7 @@
"launchBrowser": false,
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
},
"commandLineArgs": "2026-05-11 12:00:00.000000+00:00"
}
}
}
}
src/Infrastructure/Ffmpeg/ClipExtractor.cs +1 -4
diff --git a/src/Infrastructure/Ffmpeg/ClipExtractor.cs b/src/Infrastructure/Ffmpeg/ClipExtractor.cs
index c9ad301..ff1e483 100644
@@ -42,10 +42,7 @@ internal sealed partial class ClipExtractor(ILogger<ClipExtractor> logger) : ICl
addArguments: options =>
options
.WithVideoFilters(filter =>
filter
.Add("zscale", "t=linear:npl=100")
.Add("format", "yuv420p")
.Add("cropdetect", "mode=black:limit=24:round=2")
filter.Add("format", "yuv420p").Add("cropdetect", "mode=black:limit=24:round=2:skip=0")
)
.ForceFormat("null")
)