Commit: a62d300
Parent: 1df32d1

Align subtitles with seeking in video

Mårten Åsberg committed on 2026-05-09 at 18:42
src/Infrastructure/Ffmpeg/ClipExtractor.cs +12 -1
diff --git a/src/Infrastructure/Ffmpeg/ClipExtractor.cs b/src/Infrastructure/Ffmpeg/ClipExtractor.cs
index d587da8..d44f2a2 100644
@@ -86,11 +86,16 @@ internal sealed partial class ClipExtractor(ILogger<ClipExtractor> logger) : ICl
{
var subtitleOptions = await CreateSubtitleOptions(media, cancellationToken);
var args = FFMpegArguments
.FromFileInput(media.Path, addArguments: options => options.Seek(start).EndSeek(start + duration))
.FromFileInput(
media.Path,
addArguments: options => options.Seek(start).EndSeek(start + duration).WithArgument("-copyts")
)
.OutputToFile(
outputPath,
addArguments: options =>
options
.Seek(start)
.EndSeek(start + duration)
.WithVideoFilters(filter =>
{
if (crop is { Width: var width, Height: var height, X: var x, Y: var y })
@@ -164,6 +169,12 @@ file static class Extensions
public Rectangle? MaxRectangle => dictionary.Count > 0 ? dictionary.MaxBy(kvp => kvp.Value).Key : null;
}
extension(FFMpegArgumentOptions options)
{
public FFMpegArgumentOptions WithArgument(string argument) =>
options.WithArgument(new CustomArgument(argument));
}
extension(VideoFilterOptions filter)
{
public VideoFilterOptions Add(string key, string value) =>