diff --git a/Kyoo/Controllers/Transcoder/Transcoder.cs b/Kyoo/Controllers/Transcoder/Transcoder.cs index 5ad2e368..f596eb48 100644 --- a/Kyoo/Controllers/Transcoder/Transcoder.cs +++ b/Kyoo/Controllers/Transcoder/Transcoder.cs @@ -20,8 +20,8 @@ namespace Kyoo.Controllers public Transcoder(IConfiguration config) { - _transmuxPath = config.GetValue("transmuxTempPath"); - _transcodePath = config.GetValue("transcodeTempPath"); + _transmuxPath = Path.GetFullPath(config.GetValue("transmuxTempPath")); + _transcodePath = Path.GetFullPath(config.GetValue("transcodeTempPath")); if (TranscoderAPI.init() != Marshal.SizeOf()) throw new BadTranscoderException(); @@ -78,10 +78,11 @@ namespace Kyoo.Controllers public async Task Transcode(WatchItem episode) { + return null; // Not implemented yet. string folder = Path.Combine(_transcodePath, episode.Link); string manifest = Path.Combine(folder, episode.Link + ".m3u8"); float playableDuration = 0; - bool transmuxFailed = false; + bool transcodeFailed = false; try { @@ -99,11 +100,11 @@ namespace Kyoo.Controllers Task.Run(() => { - transmuxFailed = TranscoderAPI.transcode(episode.Path, manifest.Replace('\\', '/'), out playableDuration) != 0; + transcodeFailed = TranscoderAPI.transcode(episode.Path, manifest.Replace('\\', '/'), out playableDuration) != 0; }); - while (playableDuration < 10 || (!File.Exists(manifest) && !transmuxFailed)) + while (playableDuration < 10 || (!File.Exists(manifest) && !transcodeFailed)) await Task.Delay(10); - return transmuxFailed ? null : manifest; + return transcodeFailed ? null : manifest; } } } diff --git a/Kyoo/Views/API/VideoAPI.cs b/Kyoo/Views/API/VideoAPI.cs index 8393095d..b3d51941 100644 --- a/Kyoo/Views/API/VideoAPI.cs +++ b/Kyoo/Views/API/VideoAPI.cs @@ -15,12 +15,14 @@ namespace Kyoo.Api private readonly ILibraryManager _libraryManager; private readonly ITranscoder _transcoder; private readonly string _transmuxPath; + private readonly string _transcodePath; public VideoController(ILibraryManager libraryManager, ITranscoder transcoder, IConfiguration config) { _libraryManager = libraryManager; _transcoder = transcoder; _transmuxPath = config.GetValue("transmuxTempPath"); + _transcodePath = config.GetValue("transcodeTempPath"); } [HttpGet("{showSlug}-s{seasonNumber}e{episodeNumber}")] @@ -51,7 +53,7 @@ namespace Kyoo.Api [HttpGet("transmux/{episodeLink}/segment/{chunk}")] public IActionResult GetTransmuxedChunk(string episodeLink, string chunk) { - string path = Path.Combine(_transmuxPath, episodeLink); + string path = Path.GetFullPath(Path.Combine(_transmuxPath, episodeLink)); path = Path.Combine(path, "segments" + Path.DirectorySeparatorChar + chunk); return PhysicalFile(path, "video/MP2T"); @@ -71,6 +73,15 @@ namespace Kyoo.Api return StatusCode(500); } + [HttpGet("transcode/{episodeLink}/segment/{chunk}")] + public IActionResult GetTranscodedChunk(string episodeLink, string chunk) + { + string path = Path.GetFullPath(Path.Combine(_transcodePath, episodeLink)); + path = Path.Combine(path, "segments" + Path.DirectorySeparatorChar + chunk); + + return PhysicalFile(path, "video/MP2T"); + } + [HttpGet("{movieSlug}")] [Authorize(Policy="Play")] diff --git a/Kyoo/Views/WebClient b/Kyoo/Views/WebClient index a0f3da72..ee72f573 160000 --- a/Kyoo/Views/WebClient +++ b/Kyoo/Views/WebClient @@ -1 +1 @@ -Subproject commit a0f3da729cf4160d12f1b45d093b388c8e9f9199 +Subproject commit ee72f573bd4815ebf7918e76a797310c140cf454