Skip to content

Commit

Permalink
Fix CLI log level FFmpeg (#1031)
Browse files Browse the repository at this point in the history
* Remove verbose FFmpeg option

* Update README

* Convert --verbose-ffmpeg to log levels with warning
  • Loading branch information
ScrubN authored Apr 6, 2024
1 parent f843c2c commit 4f23a06
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 deletions.
3 changes: 0 additions & 3 deletions TwitchDownloaderCLI/Modes/Arguments/ChatRenderArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ internal sealed class ChatRenderArgs : TwitchDownloaderArgs
[Option("temp-path", Default = "", HelpText = "Path to temporary folder to use for cache.")]
public string TempFolder { get; set; }

[Option("verbose-ffmpeg", Default = false, HelpText = "Prints every message from FFmpeg.")]
public bool LogFfmpegOutput { get; set; }

[Option("skip-drive-waiting", Default = false, HelpText = "Do not wait for the output drive to transmit a ready signal before writing the next frame. Waiting is usually only necessary on low-end USB drives.")]
public bool SkipDriveWaiting { get; set; }

Expand Down
1 change: 0 additions & 1 deletion TwitchDownloaderCLI/Modes/RenderChat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ private static ChatRenderOptions GetRenderOptions(ChatRenderArgs inputOptions, I
"system" or "none" => EmojiVendor.None,
_ => throw new NotSupportedException("Invalid emoji vendor. Valid values are: 'twitter' / 'twemoji', and 'google' / 'notocolor'")
},
LogFfmpegOutput = inputOptions.LogFfmpegOutput,
SkipDriveWaiting = inputOptions.SkipDriveWaiting,
EmoteScale = inputOptions.ScaleEmote,
BadgeScale = inputOptions.ScaleBadge,
Expand Down
3 changes: 0 additions & 3 deletions TwitchDownloaderCLI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,6 @@ Other = `1`, Broadcaster = `2`, Moderator = `4`, VIP = `8`, Subscriber = `16`, P
**--temp-path**
(Default: ` `) Path to temporary folder for cache.

**--verbose-ffmpeg**
(Default: `false`) Prints every message from FFmpeg.

**--skip-drive-waiting**
(Default: `false`) Do not wait for the output drive to transmit a ready signal before writing the next frame. Waiting is usually only necessary on low-end USB drives. Skipping can result in 1-5% render speed increases.

Expand Down
23 changes: 23 additions & 0 deletions TwitchDownloaderCLI/Tools/PreParseArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ private static string[] ConvertFromOldSyntax(string[] args, string processFileNa
processedArgs = ConvertSilentSyntax(processedArgs);
}

if (args.Any(x => x is "--verbose-ffmpeg"))
{
Console.WriteLine("[INFO] The program has switched from --verbose-ffmpeg to log levels, consider using log levels instead. '--log-level Status,Info,Warning,Error,Ffmpeg' will be applied to the current session. Run \'{0} help\' for more information.", processFileName);
processedArgs = ConvertVerboseFfmpegSyntax(processedArgs);
}

return processedArgs.ToArray();
}

Expand Down Expand Up @@ -107,5 +113,22 @@ private static List<string> ConvertSilentSyntax(List<string> args)

return args;
}

private static List<string> ConvertVerboseFfmpegSyntax(List<string> args)
{
for (var i = 0; i < args.Count; i++)
{
if (args[i].Equals("--verbose-ffmpeg"))
{
// If the user is still using --verbose-ffmpeg they probably aren't using log levels yet, so its safe to assume that there won't be a double-parse error
args[i] = "--log-level";
var logLevels = Enum.GetNames(typeof(LogLevel))
.Where(x => x is not nameof(LogLevel.None) and not nameof(LogLevel.Verbose));
args.Insert(i + 1, string.Join(',', logLevels));
}
}

return args;
}
}
}
13 changes: 5 additions & 8 deletions TwitchDownloaderCore/ChatRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,13 @@ private FfmpegProcess GetFfmpegProcess(int partNumber, bool isMask)
SavePath = savePath
};

if (renderOptions.LogFfmpegOutput && _progress != null)
process.ErrorDataReceived += (_, e) =>
{
process.ErrorDataReceived += (_, e) =>
if (e.Data != null)
{
if (e.Data != null)
{
_progress.LogFfmpeg(e.Data);
}
};
}
_progress.LogFfmpeg(e.Data);
}
};

process.Start();
process.BeginErrorReadLine();
Expand Down
1 change: 0 additions & 1 deletion TwitchDownloaderCore/Options/ChatRenderOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public string MaskFile
public int AccentStrokeWidth => (int)(8 * ReferenceScale * AccentStrokeScale);
public int AccentIndentWidth => (int)(32 * ReferenceScale * AccentIndentScale);
public bool Offline { get; set; }
public bool LogFfmpegOutput { get; set; } = false;
public bool BlockArtPreWrap { get; set; } = false;
public double BlockArtPreWrapWidth { get; set; }
public float BlockArtCharWidth { get; set; }
Expand Down
1 change: 0 additions & 1 deletion TwitchDownloaderWPF/PageChatRender.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public ChatRenderOptions GetOptions(string filename)
Offline = checkOffline.IsChecked.GetValueOrDefault(),
AllowUnlistedEmotes = true,
DisperseCommentOffsets = checkDispersion.IsChecked.GetValueOrDefault(),
LogFfmpegOutput = true
};
if (RadioEmojiNotoColor.IsChecked == true)
options.EmojiVendor = EmojiVendor.GoogleNotoColor;
Expand Down

0 comments on commit 4f23a06

Please sign in to comment.