private static void RenderChat(Options inputOptions) { ChatRenderOptions renderOptions = new ChatRenderOptions(); renderOptions.InputFile = inputOptions.InputFile; renderOptions.OutputFile = inputOptions.OutputFile; renderOptions.BackgroundColor = SKColor.Parse(inputOptions.BackgroundColor); renderOptions.MessageColor = SKColor.Parse(inputOptions.MessageColor); renderOptions.ChatHeight = inputOptions.ChatHeight; renderOptions.ChatWidth = inputOptions.ChatWidth; renderOptions.BttvEmotes = inputOptions.BttvEmotes; renderOptions.FfzEmotes = inputOptions.FfzEmotes; renderOptions.Outline = inputOptions.Outline; renderOptions.OutlineSize = inputOptions.OutlineSize; renderOptions.Font = inputOptions.Font; renderOptions.FontSize = inputOptions.FontSize; switch (inputOptions.MessageFontStyle.ToLower()) { case "normal": renderOptions.MessageFontStyle = SKFontStyle.Normal; break; case "bold": renderOptions.MessageFontStyle = SKFontStyle.Bold; break; case "italic": renderOptions.MessageFontStyle = SKFontStyle.Italic; break; } switch (inputOptions.UsernameFontStyle.ToLower()) { case "normal": renderOptions.UsernameFontStyle = SKFontStyle.Normal; break; case "bold": renderOptions.UsernameFontStyle = SKFontStyle.Bold; break; case "italic": renderOptions.UsernameFontStyle = SKFontStyle.Italic; break; } renderOptions.UpdateRate = inputOptions.UpdateRate; renderOptions.PaddingLeft = inputOptions.PaddingLeft; renderOptions.Framerate = inputOptions.Framerate; renderOptions.InputArgs = inputOptions.InputArgs; renderOptions.OutputArgs = inputOptions.OutputArgs; renderOptions.FfmpegPath = inputOptions.FfmpegPath == null || inputOptions.FfmpegPath == "" ? ffmpegPath : inputOptions.FfmpegPath; ChatRenderer chatDownloader = new ChatRenderer(renderOptions); Progress <ProgressReport> progress = new Progress <ProgressReport>(); progress.ProgressChanged += Progress_ProgressChanged; chatDownloader.RenderVideoAsync(progress, new CancellationToken()).Wait(); }
public async Task RunAsync() { ChatRenderer downloader = new ChatRenderer(DownloadOptions); Progress <ProgressReport> progress = new Progress <ProgressReport>(); progress.ProgressChanged += Progress_ProgressChanged; Status = TwitchTaskStatus.Running; OnPropertyChanged("Status"); try { await downloader.RenderVideoAsync(progress, TokenSource.Token); if (TokenSource.IsCancellationRequested) { Status = TwitchTaskStatus.Cancelled; OnPropertyChanged("Status"); } else { Status = TwitchTaskStatus.Finished; OnPropertyChanged("Status"); } } catch { Status = TwitchTaskStatus.Failed; OnPropertyChanged("Status"); } }
private async void btnRender_Click(object sender, RoutedEventArgs e) { bool validInputs = ValidateInputs(); if (validInputs) { SaveFileDialog saveFileDialog = new SaveFileDialog(); string fileFormat = comboFormat.SelectedItem.ToString(); saveFileDialog.Filter = $"{fileFormat} Files | *.{fileFormat.ToLower()}"; saveFileDialog.RestoreDirectory = true; saveFileDialog.FileName = Path.GetFileNameWithoutExtension(textJson.Text) + "." + fileFormat.ToLower(); if (saveFileDialog.ShowDialog() == true) { SKColor backgroundColor = new SKColor(colorBackground.SelectedColor.Value.R, colorBackground.SelectedColor.Value.G, colorBackground.SelectedColor.Value.B, colorBackground.SelectedColor.Value.A); SKColor messageColor = new SKColor(colorFont.SelectedColor.Value.R, colorFont.SelectedColor.Value.G, colorFont.SelectedColor.Value.B); SaveSettings(); ChatRenderOptions options = GetOptions(saveFileDialog.FileName); SetImage("Images/ppOverheat.gif", true); btnRender.IsEnabled = false; ChatRenderer currentRender = new ChatRenderer(options); Progress <ProgressReport> renderProgress = new Progress <ProgressReport>(OnProgressChanged); try { await currentRender.RenderVideoAsync(renderProgress, new CancellationToken()); statusMessage.Text = "Done"; SetImage("Images/ppHop.gif", true); } catch (Exception ex) { statusMessage.Text = "ERROR"; SetImage("Images/peepoSad.png", false); AppendLog("ERROR: " + ex.Message); } statusProgressBar.Value = 0; btnRender.IsEnabled = true; } } else { MessageBox.Show("Please double check your inputs are valid", "Unable to parse inputs", MessageBoxButton.OK, MessageBoxImage.Error); } }
private async void btnRender_Click(object sender, RoutedEventArgs e) { bool validInputs = ValidateInputs(); if (validInputs) { SaveFileDialog saveFileDialog = new SaveFileDialog(); string fileFormat = comboFormat.SelectedItem.ToString(); saveFileDialog.Filter = $"{fileFormat} Files | *.{fileFormat.ToLower()}"; saveFileDialog.RestoreDirectory = true; saveFileDialog.FileName = Path.GetFileNameWithoutExtension(textJson.Text) + "." + fileFormat.ToLower(); if (saveFileDialog.ShowDialog() == true) { SKColor backgroundColor = new SKColor(colorBackground.SelectedColor.Value.R, colorBackground.SelectedColor.Value.G, colorBackground.SelectedColor.Value.B, colorBackground.SelectedColor.Value.A); SKColor messageColor = new SKColor(colorFont.SelectedColor.Value.R, colorFont.SelectedColor.Value.G, colorFont.SelectedColor.Value.B); SaveSettings(); ChatRenderOptions options = new ChatRenderOptions() { InputFile = textJson.Text, OutputFile = saveFileDialog.FileName, BackgroundColor = backgroundColor, ChatHeight = Int32.Parse(textHeight.Text), ChatWidth = Int32.Parse(textWidth.Text), BttvEmotes = (bool)checkBTTV.IsChecked, FfzEmotes = (bool)checkFFZ.IsChecked, Outline = (bool)checkOutline.IsChecked, Font = (string)comboFont.SelectedItem, FontSize = Double.Parse(textFontSize.Text), UpdateRate = Double.Parse(textUpdateTime.Text), Timestamp = (bool)checkTimestamp.IsChecked, MessageColor = messageColor, Framerate = Int32.Parse(textFramerate.Text), InputArgs = Settings.Default.FfmpegInputArgs, OutputArgs = Settings.Default.FfmpegOutputArgs, MessageFontStyle = SKFontStyle.Normal, UsernameFontStyle = SKFontStyle.Bold, GenerateMask = (bool)checkMask.IsChecked, OutlineSize = 4, FfmpegPath = "ffmpeg", TempFolder = Settings.Default.TempPath, SubMessages = (bool)checkSub.IsChecked }; options.PaddingLeft = (int)Math.Floor(2 * options.EmoteScale); SetImage("Images/ppOverheat.gif", true); btnRender.IsEnabled = false; ChatRenderer currentRender = new ChatRenderer(options); Progress <ProgressReport> renderProgress = new Progress <ProgressReport>(OnProgressChanged); try { await currentRender.RenderVideoAsync(renderProgress, new CancellationToken()); statusMessage.Text = "Done"; SetImage("Images/ppHop.gif", true); } catch (Exception ex) { statusMessage.Text = "ERROR"; SetImage("Images/peepoSad.png", false); AppendLog("ERROR: " + ex.Message); } statusProgressBar.Value = 0; btnRender.IsEnabled = true; } } else { MessageBox.Show("Please double check your inputs are valid", "Unable to parse inputs", MessageBoxButton.OK, MessageBoxImage.Error); } }
private static void RenderChat(Options inputOptions) { ChatRenderOptions renderOptions = new ChatRenderOptions(); renderOptions.InputFile = inputOptions.InputFile; renderOptions.OutputFile = inputOptions.OutputFile; renderOptions.BackgroundColor = SKColor.Parse(inputOptions.BackgroundColor); renderOptions.MessageColor = SKColor.Parse(inputOptions.MessageColor); renderOptions.ChatHeight = inputOptions.ChatHeight; renderOptions.ChatWidth = inputOptions.ChatWidth; renderOptions.BttvEmotes = inputOptions.BttvEmotes; renderOptions.FfzEmotes = inputOptions.FfzEmotes; renderOptions.Outline = inputOptions.Outline; renderOptions.OutlineSize = inputOptions.OutlineSize; renderOptions.Font = inputOptions.Font; renderOptions.FontSize = inputOptions.FontSize; switch (inputOptions.MessageFontStyle.ToLower()) { case "normal": renderOptions.MessageFontStyle = SKFontStyle.Normal; break; case "bold": renderOptions.MessageFontStyle = SKFontStyle.Bold; break; case "italic": renderOptions.MessageFontStyle = SKFontStyle.Italic; break; } switch (inputOptions.UsernameFontStyle.ToLower()) { case "normal": renderOptions.UsernameFontStyle = SKFontStyle.Normal; break; case "bold": renderOptions.UsernameFontStyle = SKFontStyle.Bold; break; case "italic": renderOptions.UsernameFontStyle = SKFontStyle.Italic; break; } renderOptions.UpdateRate = inputOptions.UpdateRate; renderOptions.PaddingLeft = inputOptions.PaddingLeft; renderOptions.Framerate = inputOptions.Framerate; renderOptions.GenerateMask = inputOptions.GenerateMask; renderOptions.InputArgs = inputOptions.InputArgs; renderOptions.OutputArgs = inputOptions.OutputArgs; renderOptions.FfmpegPath = inputOptions.FfmpegPath == null || inputOptions.FfmpegPath == "" ? ffmpegPath : Path.GetFullPath(inputOptions.FfmpegPath); renderOptions.TempFolder = inputOptions.TempFolder; renderOptions.SubMessages = inputOptions.SubMessages; if (renderOptions.GenerateMask && renderOptions.BackgroundColor.Alpha == 255) { Console.WriteLine("[WARNING] - Generate mask option has been selected with an opaque background. You most likely want to set a transparent background with --background-color \"#00000000\""); } ChatRenderer chatDownloader = new ChatRenderer(renderOptions); Progress <ProgressReport> progress = new Progress <ProgressReport>(); progress.ProgressChanged += Progress_ProgressChanged; chatDownloader.RenderVideoAsync(progress, new CancellationToken()).Wait(); }