mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 00:24:14 +01:00
29 lines
802 B
C#
29 lines
802 B
C#
|
using SkiaSharp;
|
|||
|
|
|||
|
namespace FFMpegCore.Extensions.SkiaSharp
|
|||
|
{
|
|||
|
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);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|