Work on assa box

This commit is contained in:
niksedk 2022-01-02 14:51:07 +01:00
parent c928a0e34b
commit 46dc39ec81
4 changed files with 51 additions and 111 deletions

View File

@ -29,6 +29,7 @@
* Improve spell check regarding Yen symbol (¥) - thx Dnkhatri
* Add Nvidia hardware accel encodings for sub burn-in - thx Leon
* FIXED:
* Fix crash in "Set start and offset the rest" w original - thx hamilaci
* Fix for generating empty waveform for online videos - thx OmrSi
* Fix for finding frame rate in some mp4 files - thx OmrSi
* Fix typo for middle/center in WebVTT default property - thx koitsu
@ -42,7 +43,7 @@
* Fix spell check "change word" issue with apostrophe (') - thx Jim
* Fix new-line-char in Bilibili format - thx Kuju29
* Fix "Close video" shortcut - thx OmrSi
* Fix double splace issue in sub burn-in - thx Leon
* Fix double space issue for output file name in sub burn-in - thx Leon
3.6.4 (3rd December 2021)

View File

@ -360,9 +360,11 @@ namespace Nikse.SubtitleEdit.Core.Common
public Color AssaBgBoxColor { get; set; }
public Color AssaBgBoxOutlineColor { get; set; }
public Color AssaBgBoxShadowColor { get; set; }
public Color AssaBgBoxTransparentColor { get; set; }
public string AssaBgBoxStyle { get; set; }
public int AssaBgBoxStyleRadius { get; set; }
public int AssaBgBoxOutlineWidth { get; set; }
public int AssaBgBoxLayer { get; set; }
public string AssaBgBoxDrawing { get; set; }
@ -542,9 +544,11 @@ namespace Nikse.SubtitleEdit.Core.Common
AssaBgBoxColor = Color.FromArgb(200, 0, 0, 0);
AssaBgBoxOutlineColor = Color.FromArgb(200, 80, 80, 80);
AssaBgBoxShadowColor = Color.FromArgb(100, 0, 0, 0);
AssaBgBoxTransparentColor = Color.Cyan;
AssaBgBoxStyle = "square";
AssaBgBoxStyleRadius = 40;
AssaBgBoxOutlineWidth = 0;
AssaBgBoxLayer = -11893;
GenVideoEncoding = "libx264";
GenVideoPreset = "medium";
@ -5510,6 +5514,12 @@ $HorzAlign = Center
settings.Tools.AssaBgBoxShadowColor = ColorTranslator.FromHtml(subNode.InnerText);
}
subNode = node.SelectSingleNode("AssaBgBoxTransparentColor");
if (subNode != null)
{
settings.Tools.AssaBgBoxTransparentColor = ColorTranslator.FromHtml(subNode.InnerText);
}
subNode = node.SelectSingleNode("AssaBgBoxStyle");
if (subNode != null)
{
@ -5528,6 +5538,12 @@ $HorzAlign = Center
settings.Tools.AssaBgBoxOutlineWidth = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("AssaBgBoxLayer");
if (subNode != null)
{
settings.Tools.AssaBgBoxLayer = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("AssaBgBoxDrawing");
if (subNode != null)
{
@ -9556,9 +9572,11 @@ $HorzAlign = Center
textWriter.WriteElementString("AssaBgBoxColor", ColorTranslator.ToHtml(settings.Tools.AssaBgBoxColor));
textWriter.WriteElementString("AssaBgBoxOutlineColor", ColorTranslator.ToHtml(settings.Tools.AssaBgBoxOutlineColor));
textWriter.WriteElementString("AssaBgBoxShadowColor", ColorTranslator.ToHtml(settings.Tools.AssaBgBoxShadowColor));
textWriter.WriteElementString("AssaBgBoxTransparentColor", ColorTranslator.ToHtml(settings.Tools.AssaBgBoxTransparentColor));
textWriter.WriteElementString("AssaBgBoxStyle", settings.Tools.AssaBgBoxStyle);
textWriter.WriteElementString("AssaBgBoxStyleRadius", settings.Tools.AssaBgBoxStyleRadius.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("AssaBgBoxOutlineWidth", settings.Tools.AssaBgBoxOutlineWidth.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("AssaBgBoxLayer", settings.Tools.AssaBgBoxLayer.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("AssaBgBoxDrawing", settings.Tools.AssaBgBoxDrawing);
textWriter.WriteElementString("GenVideoEncoding", settings.Tools.GenVideoEncoding);
textWriter.WriteElementString("GenVideoPreset", settings.Tools.GenVideoPreset);

View File

@ -46,8 +46,6 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.radioButtonTopCenter = new System.Windows.Forms.RadioButton();
this.radioButtonMiddleCenter = new System.Windows.Forms.RadioButton();
this.radioButtonTopLeft = new System.Windows.Forms.RadioButton();
this.label4 = new System.Windows.Forms.Label();
this.numericUpDownDrawingLayer = new System.Windows.Forms.NumericUpDown();
this.textBoxDrawing = new System.Windows.Forms.TextBox();
this.labelRotateX = new System.Windows.Forms.Label();
this.numericUpDownDrawingMarginV = new System.Windows.Forms.NumericUpDown();
@ -59,8 +57,6 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.label1 = new System.Windows.Forms.Label();
this.labelEdgeStyle = new System.Windows.Forms.Label();
this.comboBoxBoxStyle = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.numericUpDownBoxLayer = new System.Windows.Forms.NumericUpDown();
this.label5 = new System.Windows.Forms.Label();
this.numericUpDownPaddingRight = new System.Windows.Forms.NumericUpDown();
this.label6 = new System.Windows.Forms.Label();
@ -93,12 +89,10 @@ namespace Nikse.SubtitleEdit.Forms.Assa
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).BeginInit();
this.groupBoxDrawing.SuspendLayout();
this.groupBoxAlignment.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownDrawingLayer)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownDrawingMarginV)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownDrawMarginH)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaddingBottom)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaddingTop)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownBoxLayer)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaddingRight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaddingLeft)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownShadowWidth)).BeginInit();
@ -171,16 +165,14 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.groupBoxDrawing.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxDrawing.Controls.Add(this.groupBoxAlignment);
this.groupBoxDrawing.Controls.Add(this.label4);
this.groupBoxDrawing.Controls.Add(this.numericUpDownDrawingLayer);
this.groupBoxDrawing.Controls.Add(this.textBoxDrawing);
this.groupBoxDrawing.Controls.Add(this.labelRotateX);
this.groupBoxDrawing.Controls.Add(this.numericUpDownDrawingMarginV);
this.groupBoxDrawing.Controls.Add(this.labelRotateY);
this.groupBoxDrawing.Controls.Add(this.numericUpDownDrawMarginH);
this.groupBoxDrawing.Location = new System.Drawing.Point(591, 12);
this.groupBoxDrawing.Location = new System.Drawing.Point(562, 12);
this.groupBoxDrawing.Name = "groupBoxDrawing";
this.groupBoxDrawing.Size = new System.Drawing.Size(370, 214);
this.groupBoxDrawing.Size = new System.Drawing.Size(399, 214);
this.groupBoxDrawing.TabIndex = 29;
this.groupBoxDrawing.TabStop = false;
this.groupBoxDrawing.Text = "Drawing";
@ -295,38 +287,6 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.radioButtonTopLeft.UseVisualStyleBackColor = true;
this.radioButtonTopLeft.CheckedChanged += new System.EventHandler(this.PreviewValueChanged);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(6, 72);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(33, 13);
this.label4.TabIndex = 32;
this.label4.Text = "Layer";
//
// numericUpDownDrawingLayer
//
this.numericUpDownDrawingLayer.Location = new System.Drawing.Point(100, 70);
this.numericUpDownDrawingLayer.Maximum = new decimal(new int[] {
360,
0,
0,
0});
this.numericUpDownDrawingLayer.Minimum = new decimal(new int[] {
360,
0,
0,
-2147483648});
this.numericUpDownDrawingLayer.Name = "numericUpDownDrawingLayer";
this.numericUpDownDrawingLayer.Size = new System.Drawing.Size(52, 20);
this.numericUpDownDrawingLayer.TabIndex = 33;
this.numericUpDownDrawingLayer.Value = new decimal(new int[] {
8,
0,
0,
-2147483648});
this.numericUpDownDrawingLayer.ValueChanged += new System.EventHandler(this.PreviewValueChanged);
//
// textBoxDrawing
//
this.textBoxDrawing.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -335,7 +295,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.textBoxDrawing.Location = new System.Drawing.Point(6, 112);
this.textBoxDrawing.Multiline = true;
this.textBoxDrawing.Name = "textBoxDrawing";
this.textBoxDrawing.Size = new System.Drawing.Size(358, 96);
this.textBoxDrawing.Size = new System.Drawing.Size(387, 96);
this.textBoxDrawing.TabIndex = 21;
this.textBoxDrawing.TextChanged += new System.EventHandler(this.PreviewValueChanged);
//
@ -480,38 +440,6 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.comboBoxBoxStyle.TabIndex = 26;
this.comboBoxBoxStyle.SelectedIndexChanged += new System.EventHandler(this.comboBoxBoxStyle_SelectedIndexChanged);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(375, 127);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(33, 13);
this.label3.TabIndex = 30;
this.label3.Text = "Layer";
//
// numericUpDownBoxLayer
//
this.numericUpDownBoxLayer.Location = new System.Drawing.Point(414, 127);
this.numericUpDownBoxLayer.Maximum = new decimal(new int[] {
360,
0,
0,
0});
this.numericUpDownBoxLayer.Minimum = new decimal(new int[] {
360,
0,
0,
-2147483648});
this.numericUpDownBoxLayer.Name = "numericUpDownBoxLayer";
this.numericUpDownBoxLayer.Size = new System.Drawing.Size(52, 20);
this.numericUpDownBoxLayer.TabIndex = 31;
this.numericUpDownBoxLayer.Value = new decimal(new int[] {
9,
0,
0,
-2147483648});
this.numericUpDownBoxLayer.ValueChanged += new System.EventHandler(this.PreviewValueChanged);
//
// label5
//
this.label5.AutoSize = true;
@ -891,9 +819,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.Controls.Add(this.buttonPrimaryColor);
this.Controls.Add(this.label5);
this.Controls.Add(this.numericUpDownPaddingRight);
this.Controls.Add(this.label3);
this.Controls.Add(this.label6);
this.Controls.Add(this.numericUpDownBoxLayer);
this.Controls.Add(this.numericUpDownPaddingLeft);
this.Controls.Add(this.groupBoxDrawing);
this.Controls.Add(this.comboBoxBoxStyle);
@ -925,12 +851,10 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.groupBoxDrawing.PerformLayout();
this.groupBoxAlignment.ResumeLayout(false);
this.groupBoxAlignment.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownDrawingLayer)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownDrawingMarginV)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownDrawMarginH)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaddingBottom)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaddingTop)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownBoxLayer)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaddingRight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaddingLeft)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownShadowWidth)).EndInit();
@ -958,8 +882,6 @@ namespace Nikse.SubtitleEdit.Forms.Assa
private System.Windows.Forms.PictureBox pictureBoxPreview;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.GroupBox groupBoxDrawing;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.NumericUpDown numericUpDownDrawingLayer;
private System.Windows.Forms.TextBox textBoxDrawing;
private System.Windows.Forms.Label labelRotateX;
private System.Windows.Forms.NumericUpDown numericUpDownDrawingMarginV;
@ -971,8 +893,6 @@ namespace Nikse.SubtitleEdit.Forms.Assa
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label labelEdgeStyle;
private System.Windows.Forms.ComboBox comboBoxBoxStyle;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.NumericUpDown numericUpDownBoxLayer;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.NumericUpDown numericUpDownPaddingRight;
private System.Windows.Forms.Label label6;

View File

@ -40,10 +40,8 @@ namespace Nikse.SubtitleEdit.Forms.Assa
private readonly VideoInfo _videoInfo;
private bool _loading = true;
private static readonly Regex FrameFinderRegex = new Regex(@"[Ff]rame=\s*\d+", RegexOptions.Compiled);
private long _processedFrames;
private string _assaBox;
private readonly Random _random = new Random();
private int _top;
private int _bottom;
private int _left;
@ -51,6 +49,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
private Color _boxColor;
private Color _boxShadowColor;
private Color _boxOutlineColor;
private long _processedFrames;
public AssSetBackground(Subtitle subtitle, int[] selectedIndices, string videoFileName, VideoInfo videoInfo)
{
@ -70,8 +69,6 @@ namespace Nikse.SubtitleEdit.Forms.Assa
_selectedIndices = selectedIndices;
// Text = LanguageSettings.Current.AssaSetPosition.SetPosition;
groupBoxPreview.Text = LanguageSettings.Current.General.Preview;
comboBoxBoxStyle.Items.Clear();
comboBoxBoxStyle.Items.Add(LanguageSettings.Current.AssaProgressBarGenerator.SquareCorners);
comboBoxBoxStyle.Items.Add(LanguageSettings.Current.AssaProgressBarGenerator.RoundedCorners);
@ -80,7 +77,6 @@ namespace Nikse.SubtitleEdit.Forms.Assa
buttonOK.Text = LanguageSettings.Current.General.Ok;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
if (Configuration.Settings.Tools.AssaBgBoxStyle == "spikes")
{
comboBoxBoxStyle.SelectedIndex = 2;
@ -213,10 +209,12 @@ namespace Nikse.SubtitleEdit.Forms.Assa
});
var p = UpdatedSubtitle.Paragraphs[posAndSize.Index];
var p2 = new Paragraph(_assaBox ?? string.Empty, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds);
p2.Layer = (int)numericUpDownBoxLayer.Value;
p2.Style = "SE-box-bg";
p2.Extra = "SE-box-bg";
var p2 = new Paragraph(_assaBox ?? string.Empty, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds)
{
Layer = Configuration.Settings.Tools.AssaBgBoxLayer,
Style = "SE-box-bg",
Extra = "SE-box-bg"
};
UpdatedSubtitle.Paragraphs.Add(p2);
if (!string.IsNullOrWhiteSpace(textBoxDrawing.Text))
@ -265,13 +263,14 @@ namespace Nikse.SubtitleEdit.Forms.Assa
pDrawing.Text = pos + pDrawing.Text;
pDrawing.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds;
pDrawing.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds;
pDrawing.Layer = (int)numericUpDownDrawingLayer.Value;
pDrawing.Layer = Configuration.Settings.Tools.AssaBgBoxLayer + 1;
pDrawing.Style = "SE-box-drawing";
pDrawing.Extra = "SE-box-drawing";
UpdatedSubtitle.Paragraphs.Add(pDrawing);
}
}
UpdatedSubtitle.Renumber();
DialogResult = DialogResult.OK;
}
@ -393,12 +392,14 @@ namespace Nikse.SubtitleEdit.Forms.Assa
Right = right,
});
var p2 = new Paragraph(_assaBox ?? string.Empty, 0, 1000);
p2.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds;
p2.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds;
p2.Layer = (int)numericUpDownBoxLayer.Value;
p2.Style = "SE-box-bg";
p2.Extra = "SE-box-bg";
var p2 = new Paragraph(_assaBox ?? string.Empty, 0, 1000)
{
StartTime = { TotalMilliseconds = p.StartTime.TotalMilliseconds },
EndTime = { TotalMilliseconds = p.EndTime.TotalMilliseconds },
Layer = Configuration.Settings.Tools.AssaBgBoxLayer,
Style = "SE-box-bg",
Extra = "SE-box-bg"
};
subtitle.Paragraphs.Add(p2);
subtitle.Header = _subtitleWithNewHeader.Header ?? AdvancedSubStationAlpha.DefaultHeader;
@ -465,7 +466,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
pDrawing.Text = pos + pDrawing.Text;
pDrawing.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds;
pDrawing.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds;
pDrawing.Layer = (int)numericUpDownDrawingLayer.Value;
pDrawing.Layer = Configuration.Settings.Tools.AssaBgBoxLayer + 1;
pDrawing.Style = "SE-box-drawing";
pDrawing.Extra = "SE-box-drawing";
subtitle.Paragraphs.Add(pDrawing);
@ -601,7 +602,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
2,
_videoInfo.Width,
_videoInfo.Height,
Color.Cyan,
Configuration.Settings.Tools.AssaBgBoxTransparentColor,
false,
25,
null);
@ -636,10 +637,10 @@ namespace Nikse.SubtitleEdit.Forms.Assa
using (var bmp = new Bitmap(bmpFileName))
{
var nBmp = new NikseBitmap(bmp);
_top = nBmp.CalcTopCropping(Color.Cyan);
_bottom = nBmp.Height - nBmp.CalcBottomCropping(Color.Cyan);
_left = nBmp.CalcLeftCropping(Color.Cyan);
_right = nBmp.Width - nBmp.CalcRightCropping(Color.Cyan);
_top = nBmp.CalcTopCropping(Configuration.Settings.Tools.AssaBgBoxTransparentColor);
_bottom = nBmp.Height - nBmp.CalcBottomCropping(Configuration.Settings.Tools.AssaBgBoxTransparentColor);
_left = nBmp.CalcLeftCropping(Configuration.Settings.Tools.AssaBgBoxTransparentColor);
_right = nBmp.Width - nBmp.CalcRightCropping(Configuration.Settings.Tools.AssaBgBoxTransparentColor);
positionAndSize.Top = _top;
@ -685,7 +686,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
_selectedIndices.Length + 2,
_videoInfo.Width,
_videoInfo.Height,
Color.Cyan,
Configuration.Settings.Tools.AssaBgBoxTransparentColor,
false,
25,
null); // TODO Progress
@ -738,10 +739,10 @@ namespace Nikse.SubtitleEdit.Forms.Assa
var nBmp = new NikseBitmap(bmp);
list.Add(new PositionAndSize
{
Top = nBmp.CalcTopCropping(Color.Cyan),
Bottom = nBmp.Height - nBmp.CalcBottomCropping(Color.Cyan),
Left = nBmp.CalcLeftCropping(Color.Cyan),
Right = nBmp.Width - nBmp.CalcRightCropping(Color.Cyan),
Top = nBmp.CalcTopCropping(Configuration.Settings.Tools.AssaBgBoxTransparentColor),
Bottom = nBmp.Height - nBmp.CalcBottomCropping(Configuration.Settings.Tools.AssaBgBoxTransparentColor),
Left = nBmp.CalcLeftCropping(Configuration.Settings.Tools.AssaBgBoxTransparentColor),
Right = nBmp.Width - nBmp.CalcRightCropping(Configuration.Settings.Tools.AssaBgBoxTransparentColor),
Index = idx,
});
}