Document parameters

This commit is contained in:
alex6dj 2021-08-05 15:11:23 -04:00
parent 3a89062384
commit 6247bf6ea4
3 changed files with 57 additions and 0 deletions

View file

@ -4,6 +4,15 @@ namespace FFMpegCore.Extend
{ {
internal static class KeyValuePairExtensions internal static class KeyValuePairExtensions
{ {
/// <summary>
/// Concat the two members of a <see cref="KeyValuePair{TKey,TValue}" />
/// </summary>
/// <param name="pair">Input object</param>
/// <param name="enclose">
/// If true encloses the value part between quotes if contains an space character. If false use the
/// value unmodified
/// </param>
/// <returns>The formatted string</returns>
public static string FormatArgumentPair(this KeyValuePair<string, string> pair, bool enclose) public static string FormatArgumentPair(this KeyValuePair<string, string> pair, bool enclose)
{ {
var key = pair.Key; var key = pair.Key;

View file

@ -2,6 +2,11 @@
{ {
internal static class StringExtensions internal static class StringExtensions
{ {
/// <summary>
/// Enclose string between quotes if contains an space character
/// </summary>
/// <param name="input">The input</param>
/// <returns>The enclosed string</returns>
public static string EncloseIfContainsSpace(this string input) public static string EncloseIfContainsSpace(this string input)
{ {
return input.Contains(" ") ? $"'{input}'" : input; return input.Contains(" ") ? $"'{input}'" : input;

View file

@ -25,6 +25,13 @@ public class SubtitleHardBurnOptions
public readonly Dictionary<string, string> Parameters = new Dictionary<string, string>(); public readonly Dictionary<string, string> Parameters = new Dictionary<string, string>();
/// <summary>
/// Create a new <see cref="SubtitleHardBurnOptions"/> using a provided subtitle file or a video file
/// containing one.
/// </summary>
/// <param name="subtitlePath"></param>
/// <returns></returns>
/// <remarks>Only support .srt and .ass files, and subrip and ssa subtitle streams</remarks>
public static SubtitleHardBurnOptions Create(string subtitlePath) public static SubtitleHardBurnOptions Create(string subtitlePath)
{ {
return new SubtitleHardBurnOptions(subtitlePath); return new SubtitleHardBurnOptions(subtitlePath);
@ -35,26 +42,56 @@ private SubtitleHardBurnOptions(string subtitle)
_subtitle = subtitle; _subtitle = subtitle;
} }
/// <summary>
/// Specify the size of the original video, the video for which the ASS file was composed.
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
public SubtitleHardBurnOptions SetOriginalSize(int width, int height) public SubtitleHardBurnOptions SetOriginalSize(int width, int height)
{ {
return WithParameter("original_size", $"{width}x{height}"); return WithParameter("original_size", $"{width}x{height}");
} }
/// <summary>
/// Specify the size of the original video, the video for which the ASS file was composed.
/// </summary>
/// <param name="size"></param>
/// <returns></returns>
public SubtitleHardBurnOptions SetOriginalSize(Size size) public SubtitleHardBurnOptions SetOriginalSize(Size size)
{ {
return SetOriginalSize(size.Width, size.Height); return SetOriginalSize(size.Width, size.Height);
} }
/// <summary>
/// Set subtitles stream index.
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
/// <remarks>
/// 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
/// </remarks>
public SubtitleHardBurnOptions SetSubtitleIndex(int index) public SubtitleHardBurnOptions SetSubtitleIndex(int index)
{ {
return WithParameter("si", index.ToString()); return WithParameter("si", index.ToString());
} }
/// <summary>
/// Set subtitles input character encoding. Only useful if not UTF-8
/// </summary>
/// <param name="encode">Charset encoding</param>
/// <returns></returns>
public SubtitleHardBurnOptions SetCharacterEncoding(string encode) public SubtitleHardBurnOptions SetCharacterEncoding(string encode)
{ {
return WithParameter("charenc", encode); return WithParameter("charenc", encode);
} }
/// <summary>
/// Override default style or script info parameters of the subtitles
/// </summary>
/// <param name="styleOptions"></param>
/// <returns></returns>
public SubtitleHardBurnOptions WithStyle(StyleOptions styleOptions) public SubtitleHardBurnOptions WithStyle(StyleOptions styleOptions)
{ {
return WithParameter("force_style", styleOptions.TextInternal); return WithParameter("force_style", styleOptions.TextInternal);
@ -78,6 +115,12 @@ public static StyleOptions Create()
return new StyleOptions(); return new StyleOptions();
} }
/// <summary>
/// Used to override default style or script info parameters of the subtitles. It accepts ASS style format
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <returns></returns>
public StyleOptions WithParameter(string key, string value) public StyleOptions WithParameter(string key, string value)
{ {
Parameters.Add(key, value); Parameters.Add(key, value);