chore: lots of chores

This commit is contained in:
Stevan Freeborn
2025-08-19 16:25:15 -05:00
parent 3752e9dfa0
commit bd0a7fe3cd
23 changed files with 97 additions and 33 deletions
@@ -16,10 +16,10 @@ public sealed class AudioExtractor : IAudioExtractor
}
/// <summary>
/// Initializes a new instance of the <see cref="AudioExtractor"/> class with a specified FFMpeg service.
/// Initializes a new instance of the <see cref="AudioExtractor"/> class with a specified <see cref="IVideoService"/>.
/// </summary>
/// <param name="videoService">The video service to use for audio extraction.</param>
/// <exception cref="ArgumentNullException">Thrown when the FFMpeg service is null.</exception>
/// <exception cref="ArgumentNullException">Thrown when the video service is null.</exception>
internal AudioExtractor(IVideoService videoService)
{
_videoService = videoService ?? throw new ArgumentNullException(nameof(videoService), $"{nameof(videoService)} cannot be null");
@@ -23,8 +23,8 @@ internal sealed class FFMpegService : IVideoService
}
public async Task CreateClipFromVideoAsync(
string sourcePath,
string destinationPath,
string sourcePath,
string destinationPath,
TimeSpan startTime,
TimeSpan endTime,
TimeSpan? buffer = null
@@ -32,7 +32,7 @@ internal sealed class FFMpegService : IVideoService
{
var start = startTime - (buffer ?? TimeSpan.Zero);
var end = endTime + (buffer ?? TimeSpan.Zero);
await FFMpeg.SubVideoAsync(sourcePath, destinationPath, start, end)
.ConfigureAwait(false);
}
@@ -12,7 +12,7 @@ internal interface IVideoService
/// <param name="audio">The output audio stream.</param>
/// <returns>A task that represents the asynchronous operation. The task result indicates whether the extraction was successful.</returns>
Task<bool> ExtractAudioFromVideoAsync(Stream video, Stream audio);
/// <summary>
/// Creates a clip from a video file based on the specified start and end times.
/// </summary>
@@ -6,14 +6,22 @@ namespace StreamShorts.Library.Media.Video;
/// Represents a service that creates video shorts.
/// </summary>
/// <inheritdoc/>
public class ShortsCreator : IShortsCreator
public sealed class ShortsCreator : IShortsCreator
{
private readonly IVideoService _videoService = new FFMpegService();
/// <summary>
/// Initializes a new instance of the <see cref="ShortsCreator"/> class.
/// </summary>
public ShortsCreator()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ShortsCreator"/> class with a specified <see cref="IVideoService"/>.
/// </summary>
/// <param name="videoService">The video service.</param>
/// <exception cref="ArgumentNullException">Thrown when the video service is null.</exception>
internal ShortsCreator(IVideoService videoService)
{
_videoService = videoService ?? throw new ArgumentNullException(nameof(videoService), $"{nameof(videoService)} cannot be null");
@@ -25,17 +33,17 @@ public class ShortsCreator : IShortsCreator
{
throw new ArgumentNullException(nameof(sourcePath), $"{nameof(sourcePath)} cannot be null or whitespace");
}
if (candidate is null)
{
throw new ArgumentNullException(nameof(candidate), $"{nameof(candidate)} cannot be null");
}
if (string.IsNullOrWhiteSpace(destinationPath))
{
throw new ArgumentNullException(nameof(destinationPath), $"{nameof(destinationPath)} cannot be null or whitespace");
}
await _videoService.CreateClipFromVideoAsync(sourcePath, destinationPath, candidate.StartTime, candidate.EndTime, buffer)
.ConfigureAwait(false);
}