FFMpegCore/FFMpegCore.Extensions.System.Drawing.Common/BitmapExtensions.cs
2023-02-13 11:25:45 +01:00

28 lines
814 B
C#

using SkiaSharp;
namespace FFMpegCore.Extensions.System.Drawing.Common
{
public static class BitmapExtensions
{
public static bool AddAudio(this SKBitmap poster, string audio, string output)
{
var destination = $"{Environment.TickCount}.png";
using (var fileStream = File.OpenWrite(destination))
{
poster.Encode(fileStream, SKEncodedImageFormat.Png, default); // PNG does not respect the quality parameter
}
try
{
return FFMpeg.PosterWithAudio(destination, audio, output);
}
finally
{
if (File.Exists(destination))
{
File.Delete(destination);
}
}
}
}
}