Files
annotations/Web/Azaion.Web/Azaion.Video/IFfmpegManager.cs
T
Oleksandr Bezdieniezhnykh 7807f5bc90 add quartz for jobs
configure auto-scan folder and create hls files job WIP
2024-07-26 14:11:29 +03:00

38 lines
1.1 KiB
C#

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();
}
}