diff --git a/TwitchDownloaderCLI/Program.cs b/TwitchDownloaderCLI/Program.cs index 3b2c5911..3e91e8e9 100644 --- a/TwitchDownloaderCLI/Program.cs +++ b/TwitchDownloaderCLI/Program.cs @@ -86,7 +86,7 @@ private static void DownloadVideo(Options inputOptions) downloadOptions.CropBeginningTime = inputOptions.CropBeginningTime; downloadOptions.CropEnding = inputOptions.CropEndingTime == 0.0 ? false : true; downloadOptions.CropEndingTime = inputOptions.CropEndingTime; - downloadOptions.FfmpegPath = inputOptions.FfmpegPath == null || inputOptions.FfmpegPath == "" ? ffmpegPath : inputOptions.FfmpegPath; + downloadOptions.FfmpegPath = inputOptions.FfmpegPath == null || inputOptions.FfmpegPath == "" ? ffmpegPath : Path.GetFullPath(inputOptions.FfmpegPath); VideoDownloader videoDownloader = new VideoDownloader(downloadOptions); Progress progress = new Progress(); @@ -221,7 +221,7 @@ private static void RenderChat(Options inputOptions) renderOptions.GenerateMask = inputOptions.GenerateMask; renderOptions.InputArgs = inputOptions.InputArgs; renderOptions.OutputArgs = inputOptions.OutputArgs; - renderOptions.FfmpegPath = inputOptions.FfmpegPath == null || inputOptions.FfmpegPath == "" ? ffmpegPath : inputOptions.FfmpegPath; + renderOptions.FfmpegPath = inputOptions.FfmpegPath == null || inputOptions.FfmpegPath == "" ? ffmpegPath : Path.GetFullPath(inputOptions.FfmpegPath); ChatRenderer chatDownloader = new ChatRenderer(renderOptions); Progress progress = new Progress(); diff --git a/TwitchDownloaderCore/ChatRenderer.cs b/TwitchDownloaderCore/ChatRenderer.cs index 02259c5d..43618fa3 100644 --- a/TwitchDownloaderCore/ChatRenderer.cs +++ b/TwitchDownloaderCore/ChatRenderer.cs @@ -197,15 +197,11 @@ private void RenderVideo(ChatRenderOptions renderOptions, Queue f .Replace("{height}", renderOptions.ChatHeight.ToString()).Replace("{width}", renderOptions.ChatWidth.ToString()) .Replace("{save_path}", renderOptions.OutputFile).Replace("{max_int}", int.MaxValue.ToString()); - string ffmpegFile = ""; - if (renderOptions.FfmpegPath != "") - ffmpegFile = "ffmpeg"; - var process = new Process { StartInfo = { - FileName = ffmpegFile, + FileName = renderOptions.FfmpegPath, Arguments = $"{inputArgs} {outputArgs}", UseShellExecute = false, CreateNoWindow = true, @@ -214,6 +210,7 @@ private void RenderVideo(ChatRenderOptions renderOptions, Queue f RedirectStandardError = true } }; + //process.ErrorDataReceived += ErrorDataHandler; process.Start(); @@ -234,7 +231,7 @@ private void RenderVideo(ChatRenderOptions renderOptions, Queue f { StartInfo = { - FileName = ffmpegFile, + FileName = renderOptions.FfmpegPath, Arguments = $"{inputArgs} {outputArgsMask}", UseShellExecute = false, CreateNoWindow = true, @@ -427,6 +424,12 @@ private void RenderVideo(ChatRenderOptions renderOptions, Queue f progress.Report(new ProgressReport() { reportType = ReportType.Log, data = $"FINISHED. RENDER TIME: {(int)stopwatch.Elapsed.TotalSeconds}s SPEED: {(duration / stopwatch.Elapsed.TotalSeconds).ToString("0.##")}x" }); process.WaitForExit(); } + + private void ErrorDataHandler(object sender, DataReceivedEventArgs e) + { + Console.WriteLine(e.Data); + } + [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] private byte[] GetMaskBytes(SKBitmap bufferBitmap, ChatRenderOptions renderOptions) { diff --git a/TwitchDownloaderCore/TwitchDownloaderCore.csproj b/TwitchDownloaderCore/TwitchDownloaderCore.csproj index f03470f0..c711e306 100644 --- a/TwitchDownloaderCore/TwitchDownloaderCore.csproj +++ b/TwitchDownloaderCore/TwitchDownloaderCore.csproj @@ -5,6 +5,7 @@ + diff --git a/TwitchDownloaderCore/TwitchHelper.cs b/TwitchDownloaderCore/TwitchHelper.cs index 87779ca0..be141483 100644 --- a/TwitchDownloaderCore/TwitchHelper.cs +++ b/TwitchDownloaderCore/TwitchHelper.cs @@ -20,7 +20,7 @@ public static async Task GetVideoInfo(int videoId) { client.Encoding = Encoding.UTF8; client.Headers.Add("Accept", "application/vnd.twitchtv.v5+json"); - client.Headers.Add("Client-ID", "kimne78kx3ncx6brgo4mv6wki5h1ko"); + client.Headers.Add("Client-ID", "v8kfhyc2980it9e7t5hhc7baukzuj2"); string response = await client.DownloadStringTaskAsync("https://api.twitch.tv/kraken/videos/" + videoId); JObject result = JObject.Parse(response); return result; @@ -55,7 +55,7 @@ public static async Task GetClipInfo(object clipId) using (WebClient client = new WebClient()) { client.Headers.Add("Accept", "application/vnd.twitchtv.v5+json"); - client.Headers.Add("Client-ID", "kimne78kx3ncx6brgo4mv6wki5h1ko"); + client.Headers.Add("Client-ID", "v8kfhyc2980it9e7t5hhc7baukzuj2"); string response = await client.DownloadStringTaskAsync(String.Format("https://api.twitch.tv/kraken/clips/{0}", clipId)); JObject result = JObject.Parse(response); return result; @@ -556,7 +556,7 @@ public static string GetStreamerName(int id) using (WebClient client = new WebClient()) { client.Headers.Add("Accept", "application/vnd.twitchtv.v5+json; charset=UTF-8"); - client.Headers.Add("Client-Id", "kimne78kx3ncx6brgo4mv6wki5h1ko"); + client.Headers.Add("Client-Id", "v8kfhyc2980it9e7t5hhc7baukzuj2"); JObject response = JObject.Parse(client.DownloadString("https://api.twitch.tv/kraken/users/" + id)); return response["name"].ToString(); diff --git a/TwitchDownloaderCore/TwitchObjects/ChatRoot.cs b/TwitchDownloaderCore/TwitchObjects/ChatRoot.cs index 300e15e5..9a29c6c3 100644 --- a/TwitchDownloaderCore/TwitchObjects/ChatRoot.cs +++ b/TwitchDownloaderCore/TwitchObjects/ChatRoot.cs @@ -106,6 +106,12 @@ public class Emotes public List firstParty { get; set; } } +public class CommentResponse +{ + public List comments { get; set; } + public string _next { get; set; } +} + public class ChatRoot { public Streamer streamer { get; set; } diff --git a/TwitchDownloaderCore/VideoDownloader.cs b/TwitchDownloaderCore/VideoDownloader.cs index 56962fa8..3b320bff 100644 --- a/TwitchDownloaderCore/VideoDownloader.cs +++ b/TwitchDownloaderCore/VideoDownloader.cs @@ -213,8 +213,8 @@ await Task.Run(() => { StartInfo = { - FileName = Path.GetFullPath(downloadOptions.FfmpegPath), - Arguments = String.Format("-y -avoid_negative_ts make_zero -i \"{0}\" -analyzeduration {2} -probesize {2} -c:v copy \"{4}\"", Path.Combine(downloadFolder, "output.ts"), (seekTime - startOffset).ToString(), Int32.MaxValue, seekDuration.ToString(), Path.GetFullPath(downloadOptions.Filename)), + FileName = downloadOptions.FfmpegPath, + Arguments = String.Format("-y -avoid_negative_ts make_zero " + (downloadOptions.CropBeginning ? "-ss {1} " : "") + "-i \"{0}\" -analyzeduration {2} -probesize {2} " + (downloadOptions.CropEnding ? "-t {3} " : "") + "-c:v copy \"{4}\"", Path.Combine(downloadFolder, "output.ts"), (seekTime - startOffset).ToString(), Int32.MaxValue, seekDuration.ToString(), Path.GetFullPath(downloadOptions.Filename)), UseShellExecute = false, CreateNoWindow = true, RedirectStandardInput = false,