diff --git a/Kyoo.Transcoder/include/transcoder.h b/Kyoo.Transcoder/include/transcoder.h index ae76c326..d81413b8 100644 --- a/Kyoo.Transcoder/include/transcoder.h +++ b/Kyoo.Transcoder/include/transcoder.h @@ -11,7 +11,7 @@ extern "C" API int Init(); -extern "C" API int transmux(const char *path, const char *outPath); +extern "C" API int transmux(const char *path, const char *outPath, const char *stream_uri); //Take the path of the file and the path of the output directory. It will return the list of subtitle streams in the streams variable. The int returned is the number of subtitles extracted. extern "C" API Stream* extract_subtitles(const char *path, const char *outPath, int *streamCount, int *subtitleCount); diff --git a/Kyoo.Transcoder/src/Transcoder.cpp b/Kyoo.Transcoder/src/Transcoder.cpp index 4c0b47c1..64211076 100644 --- a/Kyoo.Transcoder/src/Transcoder.cpp +++ b/Kyoo.Transcoder/src/Transcoder.cpp @@ -8,7 +8,7 @@ int Init() return sizeof(Stream); } -int transmux(const char *path, const char *out_path, const char *get_uri) +int transmux(const char *path, const char *out_path, const char *stream_uri) { AVFormatContext *in_ctx = NULL; AVFormatContext *out_ctx = NULL; @@ -54,8 +54,11 @@ int transmux(const char *path, const char *out_path, const char *get_uri) av_dump_format(out_ctx, 0, out_path, true); - av_dict_set(&options, "init_seg_name", ((std::string)get_uri + (std::string)"/init-stream$RepresentationID$.m4s").c_str(), AV_DICT_DONT_STRDUP_VAL); - av_dict_set(&options, "media_seg_name", ((std::string)get_uri + (std::string)"/chunk-stream$RepresentationID$-$Number%05d$.m4s").c_str(), AV_DICT_DONT_STRDUP_VAL); + //std::string val = (std::string)stream_uri + (std::string)"init-stream$RepresentationID$.m4s"; + //av_dict_set(&options, "dirname", val.c_str(), 0); + //av_dict_set(&options, "init_seg_name", val.c_str(), 0); + //val = (std::string)stream_uri + (std::string)"chunk-stream$RepresentationID$-$Number%05d$.m4s"; + //av_dict_set(&options, "media_seg_name", val.c_str(), 0); if (open_output_file_for_write(out_ctx, out_path, &options) != 0) return 1; diff --git a/Kyoo/InternalAPI/Transcoder/Transcoder.cs b/Kyoo/InternalAPI/Transcoder/Transcoder.cs index eb750572..34ba70e8 100644 --- a/Kyoo/InternalAPI/Transcoder/Transcoder.cs +++ b/Kyoo/InternalAPI/Transcoder/Transcoder.cs @@ -33,12 +33,15 @@ namespace Kyoo.InternalAPI 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; + string folder = Path.Combine(tempPath, episode.Link); + string manifest = Path.Combine(folder, episode.Link + ".mpd"); + + Directory.CreateDirectory(folder); + Debug.WriteLine("&Transmuxing " + episode.Link + " at " + episode.Path + ", outputPath: " + folder); + + //FFMPEG require us to put DirectorySeparaorChar as '/' for his internal regex. + if (File.Exists(manifest) || TranscoderAPI.transmux(episode.Path, manifest.Replace('\\', '/'), (folder + Path.DirectorySeparatorChar).Replace('\\', '/')) == 0) + return manifest; else return null; } diff --git a/Kyoo/InternalAPI/Transcoder/TranscoderAPI.cs b/Kyoo/InternalAPI/Transcoder/TranscoderAPI.cs index 015ccd94..910e12d7 100644 --- a/Kyoo/InternalAPI/Transcoder/TranscoderAPI.cs +++ b/Kyoo/InternalAPI/Transcoder/TranscoderAPI.cs @@ -14,7 +14,7 @@ namespace Kyoo.InternalAPI.TranscoderLink public extern static int Init(); [DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)] - public extern static int transmux(string path, string out_path); + public extern static int transmux(string path, string out_path, string stream_uri); [DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)] private extern static IntPtr extract_subtitles(string path, string out_path, out int array_length, out int track_count);