diff --git a/Wasari.FFmpeg/FFmpegService.cs b/Wasari.FFmpeg/FFmpegService.cs index 2ffc721..c4a8b53 100644 --- a/Wasari.FFmpeg/FFmpegService.cs +++ b/Wasari.FFmpeg/FFmpegService.cs @@ -171,22 +171,21 @@ private static Command CreateCommand() .WithWorkingDirectory(Environment.CurrentDirectory); } - private string? GetTemporaryFile(string? baseFilePath = null) + private string? GetTemporaryFile(string extension, string? baseFilePath = null) { if (baseFilePath != null) { var fileName = Path.GetFileNameWithoutExtension(baseFilePath); - var fileExtension = Path.GetExtension(baseFilePath); var fileDirectory = Path.GetDirectoryName(baseFilePath); - return $"{fileDirectory}{Path.DirectorySeparatorChar}{fileName}_wasari_tmp.{fileExtension}"; + return $"{fileDirectory}{Path.DirectorySeparatorChar}{fileName}_wasari_tmp{extension}"; } if (!Options.Value.UseTemporaryEncodingPath) return null; var tempFileName = Path.GetFileNameWithoutExtension(Path.GetTempFileName()); - return Path.Combine(Path.GetTempPath(), $"{tempFileName}.mp4"); + return Path.Combine(Path.GetTempPath(), $"{tempFileName}.{extension}"); } public TimeSpan? GetVideoDuration(IMediaAnalysis mediaAnalysis) @@ -247,7 +246,7 @@ public async Task CheckIfVideoStreamIsValid(string filePath) public async Task DownloadEpisode(T episode, string filePath, IProgress? progress) where T : IWasariEpisode { - var tempFileName = GetTemporaryFile(); + var tempFileName = GetTemporaryFile(Path.GetExtension(filePath)); var arguments = await BuildArgumentsForEpisode(episode, tempFileName ?? filePath).ToArrayAsync(); var ffmpegCommand = CreateCommand() .WithValidation(CommandResultValidation.None)