Squirrowse/squirrowse.web/Data/SaveVideo.cs
2020-06-19 18:39:08 +02:00

24 lines
716 B
C#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using OpenCvSharp;
namespace squirrowse.web.Data
{
public class SaveVideo : ISaveVideo
{
public async Task SaveData(IAsyncEnumerable<byte[]> stream)
{
var videoname = DateTime.UtcNow.ToShortDateString();
var output = new VideoWriter(videoname, FourCC.FromFourCCValues(FourCCValues.DIVX), 24.998,
new Size(640, 480));
await foreach (var b in stream)
{
await Task.Delay(1000 / 33);
output.Write(Cv2.ImDecode(b, ImreadModes.Unchanged));
// await Task.Delay(1000 / 33);
}
}
}
}