add quartz for jobs

configure auto-scan folder and create hls files job WIP
This commit is contained in:
Oleksandr Bezdieniezhnykh
2024-07-26 14:11:29 +03:00
parent 5e55210eac
commit 7807f5bc90
18 changed files with 179 additions and 28 deletions
@@ -10,4 +10,8 @@
<ProjectReference Include="..\Azaion.Repository\Azaion.Repository.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
</ItemGroup>
</Project>
@@ -0,0 +1,38 @@
using System.Diagnostics;
using Azaion.Repository;
using Azaion.Repository.DTO.Configs;
using Microsoft.Extensions.Options;
namespace Azaion.Video;
public interface IFfmpegManager
{
void ConvertToHls(string video, string segmentFile, string outFile);
}
public class FfmpegManager(IOptions<FoldersConfig> config) : IFfmpegManager
{
public void ConvertToHls(string video, string segmentFile, string outFile)
{
string arguments = string.Concat($"-i \"{video}\" ",
"-f hls ",
"-hls_time 2 ",
"-hls_playlist_type vod ",
"-hls_flags independent_segments ",
"-hls_segment_type mpegts ",
$"-hls_segment_filename \"{segmentFile}\"",
$"\"{outFile}\"");
var process = new Process
{
StartInfo = new()
{
FileName = config.Value.FfmpegExecutable,
Arguments = arguments,
UseShellExecute = true,
},
EnableRaisingEvents = true,
};
process.Start();
}
}
@@ -3,7 +3,7 @@ using Azaion.Repository.Entities;
namespace Azaion.Video;
public interface IVideoManager
public interface IVideoRepository
{
List<VideoDto> GetVideos();
Media Get(Guid mediaId);
@@ -1,11 +1,13 @@
using System.Diagnostics;
using Azaion.Repository;
using Azaion.Repository.DTO;
using Azaion.Repository.DTO.Configs;
using Azaion.Repository.Entities;
using Microsoft.Extensions.Options;
namespace Azaion.Video;
public class VideoManager(IDbFactory dbFactory) : IVideoManager
public class VideoRepository(IDbFactory dbFactory, IOptions<FoldersConfig> foldersConfig) : IVideoRepository
{
public List<VideoDto> GetVideos()
{
@@ -38,7 +40,7 @@ public class VideoManager(IDbFactory dbFactory) : IVideoManager
{
StartInfo = new()
{
FileName = Constants.FFMPEG_FILE,
FileName = foldersConfig.Value.FfmpegExecutable,
Arguments = arguments,
UseShellExecute = true,
},