Xabe.FFmpeg
Xabe.FFmpeg copied to clipboard
Image to video conversion leaves temporary files
When I convert jpeg images to videos, a subdirectory is created with a copy of the source images. This directory isn't removed when processing is complete. For example, one run created a folder C:\Users\User\AppData\Local\Temp\704d7805-ffd3-4484-97f3-68b87be20322\ which contains sequentially named images from "img_001.jpg" through "img_100.jpg" Is there a method that needs to be called to delete these files? I've looked over the code but I can't find one.
-- the code: -- await FFmpeg.Conversions.New() .BuildVideoFromImages(imageFilenames) .SetFrameRate(15) .SetOverwriteOutput(true) .SetOutputFormat(Format.mp4) .SetVideoBitrate(2600000) .SetPixelFormat(PixelFormat.yuv420p) .SetOutput(outputPath).Start();
Hi, Right now you cannot do anything with that but that would be a nice thing to clean up these files. Added to TODO list.
Ok. I am using a workaround where the code looks for new folders with images in the temp directory after processing and deletes them.
Hi, it work
/// <summary>
/// Auto Delete Temp Images (by zh3305)
/// </summary>
/// <param name="conversion"></param>
/// <param name="imageFiles"></param>
/// <returns></returns>
public static IConversion BuildVideoFromImagesDelTemp(this Xabe.FFmpeg.IConversion conversion, IEnumerable<string> imageFiles)
{
var builder = new InputBuilder();
conversion.BuildVideoFromImages(0, builder.PrepareInputFiles(imageFiles.ToList(), out var tempDirectory));
conversion.OnProgress += async (sender, args) =>
{
if (args.Percent==100)
{
Directory.Delete(tempDirectory, true);
}
};
return conversion;
}