mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
parent
0d3f98a011
commit
726e8cd486
1 changed files with 5 additions and 6 deletions
|
@ -280,11 +280,12 @@ public static bool Join(string output, params string[] videos)
|
||||||
/// <returns>Output video information.</returns>
|
/// <returns>Output video information.</returns>
|
||||||
public static bool JoinImageSequence(string output, double frameRate = 30, params ImageInfo[] images)
|
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) =>
|
var temporaryImageFiles = images.Select((image, index) =>
|
||||||
{
|
{
|
||||||
FFMpegHelper.ConversionSizeExceptionCheck(Image.FromFile(image.FullName));
|
FFMpegHelper.ConversionSizeExceptionCheck(Image.FromFile(image.FullName));
|
||||||
var destinationPath = Path.Combine(FFMpegOptions.Options.TempDirectory, $"{index.ToString().PadLeft(9, '0')}{image.Extension}");
|
var destinationPath = Path.Combine(tempFolderName, $"{index.ToString().PadLeft(9, '0')}{image.Extension}");
|
||||||
Directory.CreateDirectory(FFMpegOptions.Options.TempDirectory);
|
Directory.CreateDirectory(tempFolderName);
|
||||||
File.Copy(image.FullName, destinationPath);
|
File.Copy(image.FullName, destinationPath);
|
||||||
return destinationPath;
|
return destinationPath;
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
|
@ -293,11 +294,8 @@ public static bool JoinImageSequence(string output, double frameRate = 30, param
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return FFMpegArguments
|
return FFMpegArguments
|
||||||
.FromInputFiles(false, Path.Combine(FFMpegOptions.Options.TempDirectory, "%09d.png"))
|
.FromInputFiles(false, Path.Combine(tempFolderName, "%09d.png"))
|
||||||
.WithVideoCodec(VideoCodec.LibX264)
|
|
||||||
.Resize(firstImage.Width, firstImage.Height)
|
.Resize(firstImage.Width, firstImage.Height)
|
||||||
.WithFrameOutputCount(images.Length)
|
|
||||||
.WithStartNumber(0)
|
|
||||||
.WithFramerate(frameRate)
|
.WithFramerate(frameRate)
|
||||||
.OutputToFile(output)
|
.OutputToFile(output)
|
||||||
.ProcessSynchronously();
|
.ProcessSynchronously();
|
||||||
|
@ -305,6 +303,7 @@ public static bool JoinImageSequence(string output, double frameRate = 30, param
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Cleanup(temporaryImageFiles);
|
Cleanup(temporaryImageFiles);
|
||||||
|
Directory.Delete(tempFolderName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue