feat: trying to create clips...probs a waste of time grrrrrrr

This commit is contained in:
Stevan Freeborn
2025-08-12 00:17:37 -05:00
parent 8feadcf23c
commit 85304eadd1
12 changed files with 177 additions and 13 deletions
@@ -1,3 +1,4 @@
using FFMpegCore;
using FFMpegCore.Enums;
using FFMpegCore.Pipes;
@@ -21,4 +22,20 @@ internal sealed class FFMpegService : IVideoService
.ProcessAsynchronously()
.ConfigureAwait(false);
}
public async Task<Stream> ExtractClipFromVideoAsync(Stream video, TimeSpan start, TimeSpan end, TimeSpan? buffer = null)
{
var startTime = start - (buffer ?? TimeSpan.Zero);
var endTime = end + (buffer ?? TimeSpan.Zero);
var outputStream = new MemoryStream();
await FFMpegArguments
.FromPipeInput(new StreamPipeSource(video), o => o.Seek(startTime).EndSeek(endTime))
.OutputToPipe(new StreamPipeSink(outputStream), o => o.CopyChannel().ForceFormat("webm"))
.ProcessAsynchronously()
.ConfigureAwait(false);
outputStream.Position = 0;
return outputStream;
}
}