add controller for video

This commit is contained in:
Oleksandr Bezdieniezhnykh
2024-07-22 16:01:28 +03:00
parent bfbfdf6658
commit 6f78b88007
7 changed files with 80 additions and 35 deletions
+2 -1
View File
@@ -1,11 +1,12 @@
using Azaion.Repository.DTO;
using Azaion.Repository.Entities;
namespace Azaion.Video;
public interface IVideoManager
{
List<VideoDto> GetVideos();
void OpenVideo(Guid mediaId);
Media Get(Guid mediaId);
void CreateAnnotation(Guid mediaId, DateTime time)
{
+29 -4
View File
@@ -1,5 +1,7 @@
using System.Diagnostics;
using Azaion.Repository;
using Azaion.Repository.DTO;
using Azaion.Repository.Entities;
namespace Azaion.Video;
@@ -18,12 +20,36 @@ public class VideoManager(IDbFactory dbFactory) : IVideoManager
})
.ToList());
}
public void OpenVideo(Guid mediaId)
public void EncodeVideo(Guid mediaId)
{
throw new NotImplementedException();
var media = dbFactory.Run(db => db.Medias.SingleOrDefault(x => x.Id == mediaId))!;
string arguments = string.Concat($"-i \"{media.Path}\" ",
"-f hls ",
"-hls_time 2 ",
"-hls_playlist_type vod ",
"-hls_flags independent_segments ",
"-hls_segment_type mpegts ",
$"-hls_segment_filename \"{media.SegmentFile}\"",
$"\"{media.M3U8File}\"");
var process = new Process
{
StartInfo = new()
{
FileName = Constants.FFMPEG_FILE,
Arguments = arguments,
UseShellExecute = true,
},
EnableRaisingEvents = true,
};
process.Start();
}
public Media Get(Guid mediaId) =>
dbFactory.Run(db => db.Medias.SingleOrDefault(x => x.Id == mediaId))!;
public void OpenTestVideo()
{
@@ -31,6 +57,5 @@ public class VideoManager(IDbFactory dbFactory) : IVideoManager
public void FinishAnnotation(Guid mediaId)
{
throw new NotImplementedException();
}
}