mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-12-29 08:10:28 -05:00
52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using Kyoo.InternalAPI.TranscoderLink;
|
|
using Kyoo.Models;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.Extensions.Configuration;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Kyoo.InternalAPI
|
|
{
|
|
public class Transcoder : ITranscoder
|
|
{
|
|
private readonly string tempPath;
|
|
|
|
public Transcoder(IConfiguration config)
|
|
{
|
|
tempPath = config.GetValue<string>("tempPath");
|
|
|
|
Debug.WriteLine("&Api INIT (unmanaged stream size): " + TranscoderAPI.Init() + ", Stream size: " + Marshal.SizeOf<Models.Watch.Stream>());
|
|
}
|
|
|
|
public async Task<Track[]> ExtractSubtitles(string path)
|
|
{
|
|
string output = Path.Combine(Path.GetDirectoryName(path), "Subtitles");
|
|
Directory.CreateDirectory(output);
|
|
return await Task.Run(() =>
|
|
{
|
|
TranscoderAPI.ExtractSubtitles(path, output, out Track[] tracks);
|
|
return tracks;
|
|
});
|
|
}
|
|
|
|
public string Transmux(WatchItem episode)
|
|
{
|
|
string temp = Path.Combine(tempPath, episode.Link);
|
|
Directory.CreateDirectory(temp);
|
|
temp = Path.Combine(temp, episode.Link + ".mpd");
|
|
Debug.WriteLine("&Transmuxing " + episode.Link + " at " + episode.Path + ", outputPath: " + temp);
|
|
if (File.Exists(temp) || TranscoderAPI.transmux(episode.Path, temp) == 0)
|
|
return temp;
|
|
else
|
|
return null;
|
|
}
|
|
|
|
public string Transcode(string path)
|
|
{
|
|
return @"D:\Videos\Anohana\AnoHana S01E01.mp4";
|
|
}
|
|
}
|
|
}
|