From 75386b6dacdd7a16492d4daa9598d6725b77f42f Mon Sep 17 00:00:00 2001 From: alex6dj Date: Thu, 5 Aug 2021 15:11:23 -0400 Subject: [PATCH] Document parameters Former-commit-id: 6247bf6ea4a0ce4bc74e1f93d4192419c27f3e7a --- FFMpegCore/Extend/KeyValuePairExtensions.cs | 9 ++++ FFMpegCore/Extend/StringExtensions.cs | 5 +++ .../Arguments/SubtitleHardBurnArgument.cs | 43 +++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/FFMpegCore/Extend/KeyValuePairExtensions.cs b/FFMpegCore/Extend/KeyValuePairExtensions.cs index 92dbf6d..28cc087 100644 --- a/FFMpegCore/Extend/KeyValuePairExtensions.cs +++ b/FFMpegCore/Extend/KeyValuePairExtensions.cs @@ -4,6 +4,15 @@ namespace FFMpegCore.Extend { internal static class KeyValuePairExtensions { + /// + /// Concat the two members of a + /// + /// Input object + /// + /// If true encloses the value part between quotes if contains an space character. If false use the + /// value unmodified + /// + /// The formatted string public static string FormatArgumentPair(this KeyValuePair pair, bool enclose) { var key = pair.Key; diff --git a/FFMpegCore/Extend/StringExtensions.cs b/FFMpegCore/Extend/StringExtensions.cs index f4e0169..ddcf54b 100644 --- a/FFMpegCore/Extend/StringExtensions.cs +++ b/FFMpegCore/Extend/StringExtensions.cs @@ -2,6 +2,11 @@ { internal static class StringExtensions { + /// + /// Enclose string between quotes if contains an space character + /// + /// The input + /// The enclosed string public static string EncloseIfContainsSpace(this string input) { return input.Contains(" ") ? $"'{input}'" : input; diff --git a/FFMpegCore/FFMpeg/Arguments/SubtitleHardBurnArgument.cs b/FFMpegCore/FFMpeg/Arguments/SubtitleHardBurnArgument.cs index 552a87b..1186ae2 100644 --- a/FFMpegCore/FFMpeg/Arguments/SubtitleHardBurnArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/SubtitleHardBurnArgument.cs @@ -25,6 +25,13 @@ public class SubtitleHardBurnOptions public readonly Dictionary Parameters = new Dictionary(); + /// + /// Create a new using a provided subtitle file or a video file + /// containing one. + /// + /// + /// + /// Only support .srt and .ass files, and subrip and ssa subtitle streams public static SubtitleHardBurnOptions Create(string subtitlePath) { return new SubtitleHardBurnOptions(subtitlePath); @@ -35,26 +42,56 @@ private SubtitleHardBurnOptions(string subtitle) _subtitle = subtitle; } + /// + /// Specify the size of the original video, the video for which the ASS file was composed. + /// + /// + /// + /// public SubtitleHardBurnOptions SetOriginalSize(int width, int height) { return WithParameter("original_size", $"{width}x{height}"); } + /// + /// Specify the size of the original video, the video for which the ASS file was composed. + /// + /// + /// public SubtitleHardBurnOptions SetOriginalSize(Size size) { return SetOriginalSize(size.Width, size.Height); } + /// + /// Set subtitles stream index. + /// + /// + /// + /// + /// Used when the provided subtitle is an stream of a video file (ex. .mkv) with multiple subtitles. + /// Represent the index of the subtitle not the stream, them the first subtitle index is 0 and second is 1 + /// public SubtitleHardBurnOptions SetSubtitleIndex(int index) { return WithParameter("si", index.ToString()); } + /// + /// Set subtitles input character encoding. Only useful if not UTF-8 + /// + /// Charset encoding + /// public SubtitleHardBurnOptions SetCharacterEncoding(string encode) { return WithParameter("charenc", encode); } + /// + /// Override default style or script info parameters of the subtitles + /// + /// + /// public SubtitleHardBurnOptions WithStyle(StyleOptions styleOptions) { return WithParameter("force_style", styleOptions.TextInternal); @@ -78,6 +115,12 @@ public static StyleOptions Create() return new StyleOptions(); } + /// + /// Used to override default style or script info parameters of the subtitles. It accepts ASS style format + /// + /// + /// + /// public StyleOptions WithParameter(string key, string value) { Parameters.Add(key, value);