From 726e8cd486716687644176ee81ad6d0a7f6bbb21 Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Thu, 27 Aug 2020 17:22:23 +0200 Subject: [PATCH] #94 Former-commit-id: 76107fb93e305a6eb500361f24aced4229b4d415 --- FFMpegCore/FFMpeg/FFMpeg.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/FFMpegCore/FFMpeg/FFMpeg.cs b/FFMpegCore/FFMpeg/FFMpeg.cs index cee64d8..7aad74f 100644 --- a/FFMpegCore/FFMpeg/FFMpeg.cs +++ b/FFMpegCore/FFMpeg/FFMpeg.cs @@ -280,11 +280,12 @@ public static bool Join(string output, params string[] videos) /// Output video information. public static bool JoinImageSequence(string output, double frameRate = 30, params ImageInfo[] images) { + var tempFolderName = Path.Combine(FFMpegOptions.Options.TempDirectory, Guid.NewGuid().ToString()); var temporaryImageFiles = images.Select((image, index) => { FFMpegHelper.ConversionSizeExceptionCheck(Image.FromFile(image.FullName)); - var destinationPath = Path.Combine(FFMpegOptions.Options.TempDirectory, $"{index.ToString().PadLeft(9, '0')}{image.Extension}"); - Directory.CreateDirectory(FFMpegOptions.Options.TempDirectory); + var destinationPath = Path.Combine(tempFolderName, $"{index.ToString().PadLeft(9, '0')}{image.Extension}"); + Directory.CreateDirectory(tempFolderName); File.Copy(image.FullName, destinationPath); return destinationPath; }).ToArray(); @@ -293,11 +294,8 @@ public static bool JoinImageSequence(string output, double frameRate = 30, param try { return FFMpegArguments - .FromInputFiles(false, Path.Combine(FFMpegOptions.Options.TempDirectory, "%09d.png")) - .WithVideoCodec(VideoCodec.LibX264) + .FromInputFiles(false, Path.Combine(tempFolderName, "%09d.png")) .Resize(firstImage.Width, firstImage.Height) - .WithFrameOutputCount(images.Length) - .WithStartNumber(0) .WithFramerate(frameRate) .OutputToFile(output) .ProcessSynchronously(); @@ -305,6 +303,7 @@ public static bool JoinImageSequence(string output, double frameRate = 30, param finally { Cleanup(temporaryImageFiles); + Directory.Delete(tempFolderName); } }