Work on assa

This commit is contained in:
niksedk 2021-06-25 16:43:28 +02:00
parent c4758bb4d2
commit 4ceb59708a
11 changed files with 110 additions and 24 deletions

View File

@ -40,7 +40,7 @@
* Minor fix for split with zero time codes - thx darnn * Minor fix for split with zero time codes - thx darnn
* Try to fix Tools - Join... with different ASSA styles - thx Joe * Try to fix Tools - Join... with different ASSA styles - thx Joe
* Fix crash in "Continuation style" - thx ivandrofly * Fix crash in "Continuation style" - thx ivandrofly
* Make sub preview work with mpv / audio files - thx Rabia * Make sub preview work with mpv + audio only files - thx Rabia
3.6.1 (20th May 2021) 3.6.1 (20th May 2021)

View File

@ -195,6 +195,7 @@ Note: Do check free disk space.</WaveFileMalformed>
<CurrentTextPositionX>Text position: {0}</CurrentTextPositionX> <CurrentTextPositionX>Text position: {0}</CurrentTextPositionX>
<SetPosInfo>Click on video to toggle set/move position</SetPosInfo> <SetPosInfo>Click on video to toggle set/move position</SetPosInfo>
<Clipboard>Clipboard</Clipboard> <Clipboard>Clipboard</Clipboard>
<ResolutionMissing>PlayResX/PlayResY are not set - set the resolution now?</ResolutionMissing>
</AssaSetPosition> </AssaSetPosition>
<AudioToText> <AudioToText>
<Title>Audio to text</Title> <Title>Audio to text</Title>

View File

@ -191,6 +191,7 @@ IF NOT EXIST "temp_zip\Tesseract302" MD "temp_zip\Tesseract302"
ECHO. ECHO.
COPY /Y /V "..\..\..\..\LICENSE.txt" "temp_zip\" COPY /Y /V "..\..\..\..\LICENSE.txt" "temp_zip\"
COPY /Y /V "..\..\..\..\Changelog.txt" "temp_zip\" COPY /Y /V "..\..\..\..\Changelog.txt" "temp_zip\"
COPY /Y /V "..\..\..\..\preview.mkv" "temp_zip\"
COPY /Y /V "Hunspellx86.dll" "temp_zip\" COPY /Y /V "Hunspellx86.dll" "temp_zip\"
COPY /Y /V "Hunspellx64.dll" "temp_zip\" COPY /Y /V "Hunspellx64.dll" "temp_zip\"
COPY /Y /V "SubtitleEdit.exe" "temp_zip\" COPY /Y /V "SubtitleEdit.exe" "temp_zip\"

View File

@ -179,6 +179,7 @@ IF NOT EXIST "temp_zip\Tesseract302" MD "temp_zip\Tesseract302"
ECHO. ECHO.
COPY /Y /V "..\..\..\..\LICENSE.txt" "temp_zip\" COPY /Y /V "..\..\..\..\LICENSE.txt" "temp_zip\"
COPY /Y /V "..\..\..\..\Changelog.txt" "temp_zip\" COPY /Y /V "..\..\..\..\Changelog.txt" "temp_zip\"
COPY /Y /V "..\..\..\..\preview.mkv" "temp_zip\"
COPY /Y /V "Hunspellx86.dll" "temp_zip\" COPY /Y /V "Hunspellx86.dll" "temp_zip\"
COPY /Y /V "Hunspellx64.dll" "temp_zip\" COPY /Y /V "Hunspellx64.dll" "temp_zip\"
COPY /Y /V "SubtitleEdit.exe" "temp_zip\" COPY /Y /V "SubtitleEdit.exe" "temp_zip\"

View File

@ -43,8 +43,9 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.buttonCancel = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button();
this.buttonHistory = new System.Windows.Forms.Button(); this.buttonHistory = new System.Windows.Forms.Button();
this.buttonTogglePreview = new System.Windows.Forms.Button(); this.buttonTogglePreview = new System.Windows.Forms.Button();
this.seTextBox1 = new Nikse.SubtitleEdit.Controls.SETextBox();
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
this.seTextBox1 = new Nikse.SubtitleEdit.Controls.SETextBox();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.groupBoxPreview.SuspendLayout(); this.groupBoxPreview.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).BeginInit();
@ -198,11 +199,16 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.buttonTogglePreview.UseVisualStyleBackColor = true; this.buttonTogglePreview.UseVisualStyleBackColor = true;
this.buttonTogglePreview.Click += new System.EventHandler(this.buttonTogglePreview_Click); this.buttonTogglePreview.Click += new System.EventHandler(this.buttonTogglePreview_Click);
// //
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// seTextBox1 // seTextBox1
// //
this.seTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.seTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.seTextBox1.BackColor = System.Drawing.SystemColors.WindowFrame; this.seTextBox1.BackColor = System.Drawing.SystemColors.WindowFrame;
this.seTextBox1.ContextMenuStrip = this.contextMenuStrip1;
this.seTextBox1.CurrentLanguage = ""; this.seTextBox1.CurrentLanguage = "";
this.seTextBox1.CurrentLineIndex = 0; this.seTextBox1.CurrentLineIndex = 0;
this.seTextBox1.HideSelection = true; this.seTextBox1.HideSelection = true;
@ -222,9 +228,11 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.seTextBox1.Size = new System.Drawing.Size(522, 156); this.seTextBox1.Size = new System.Drawing.Size(522, 156);
this.seTextBox1.TabIndex = 0; this.seTextBox1.TabIndex = 0;
// //
// timer1 // contextMenuStrip1
// //
this.timer1.Tick += new System.EventHandler(this.timer1_Tick); this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(181, 26);
this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening);
// //
// ApplyCustomStyles // ApplyCustomStyles
// //
@ -274,5 +282,6 @@ namespace Nikse.SubtitleEdit.Forms.Assa
private System.Windows.Forms.Button buttonTogglePreview; private System.Windows.Forms.Button buttonTogglePreview;
private System.Windows.Forms.PictureBox pictureBoxPreview; private System.Windows.Forms.PictureBox pictureBoxPreview;
private System.Windows.Forms.Timer timer1; private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
} }
} }

View File

@ -1,14 +1,13 @@
using Nikse.SubtitleEdit.Controls; using Nikse.SubtitleEdit.Controls;
using Nikse.SubtitleEdit.Core.Common; using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Logic; using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.VideoPlayers;
using System; using System;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Logic.VideoPlayers;
namespace Nikse.SubtitleEdit.Forms.Assa namespace Nikse.SubtitleEdit.Forms.Assa
{ {
@ -65,6 +64,8 @@ namespace Nikse.SubtitleEdit.Forms.Assa
_originalHeight = Height; _originalHeight = Height;
MinimumSize = new Size(MinimumSize.Width, _originalHeight); MinimumSize = new Size(MinimumSize.Width, _originalHeight);
buttonTogglePreview.Visible = LibMpvDynamic.IsInstalled;
seTextBox1.TextChanged += (sender, args) => seTextBox1.TextChanged += (sender, args) =>
{ {
if (_videoLoaded) if (_videoLoaded)
@ -197,7 +198,8 @@ namespace Nikse.SubtitleEdit.Forms.Assa
if (AssaTagHelper.AutoCompleteTextBox(tb, intellisenseListBox)) if (AssaTagHelper.AutoCompleteTextBox(tb, intellisenseListBox))
{ {
var p = GetPositionInForm(tb); var p = GetPositionInForm(tb);
intellisenseListBox.Location = new Point(p.X + 10, p.Y + 40); //TODO: improve position intellisenseListBox.Location = new Point(p.X + 10, p.Y + 30); //TODO: improve position
intellisenseListBox.Height = 185;
intellisenseListBox.Show(); intellisenseListBox.Show();
intellisenseListBox.BringToFront(); intellisenseListBox.BringToFront();
intellisenseListBox.Focus(); intellisenseListBox.Focus();
@ -421,5 +423,19 @@ namespace Nikse.SubtitleEdit.Forms.Assa
_mpv?.Stop(); _mpv?.Stop();
_mpv?.Play(); _mpv?.Play();
} }
private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
if (_intellisenseList != null && _intellisenseList.Focused)
{
_intellisenseList.Hide();
}
else
{
_intellisenseList = DoIntellisense(seTextBox1, _intellisenseList);
}
e.Cancel = true;
}
} }
} }

View File

@ -120,4 +120,7 @@
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>104, 17</value>
</metadata>
</root> </root>

View File

@ -1,5 +1,6 @@
using Nikse.SubtitleEdit.Core.Common; using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Core.SubtitleFormats; using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Forms.Options;
using Nikse.SubtitleEdit.Logic; using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.VideoPlayers; using Nikse.SubtitleEdit.Logic.VideoPlayers;
using System; using System;
@ -169,7 +170,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
} }
UpdatedSubtitle = new Subtitle(subtitle, false); UpdatedSubtitle = new Subtitle(subtitle, false);
var indices = GetIndices(subtitle); var indices = GetIndices();
for (int i = 0; i < UpdatedSubtitle.Paragraphs.Count; i++) for (int i = 0; i < UpdatedSubtitle.Paragraphs.Count; i++)
{ {
@ -204,7 +205,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
p.Text = Regex.Replace(p.Text, @"\\pos\([\d,\.-]*\)", string.Empty); p.Text = Regex.Replace(p.Text, @"\\pos\([\d,\.-]*\)", string.Empty);
} }
private int[] GetIndices(Subtitle subtitle) private int[] GetIndices()
{ {
return _selectedIndices; return _selectedIndices;
} }
@ -214,7 +215,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
} }
private bool GeneratePreviewViaMpv() private void GeneratePreviewViaMpv()
{ {
var fileName = _videoFileName; var fileName = _videoFileName;
if (!File.Exists(fileName)) if (!File.Exists(fileName))
@ -222,7 +223,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
var isFfmpegAvailable = !Configuration.IsRunningOnWindows || !string.IsNullOrEmpty(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation); var isFfmpegAvailable = !Configuration.IsRunningOnWindows || !string.IsNullOrEmpty(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation);
if (!isFfmpegAvailable) if (!isFfmpegAvailable)
{ {
return false; return;
} }
using (var p = GetFFmpegProcess(fileName)) using (var p = GetFFmpegProcess(fileName))
@ -234,7 +235,23 @@ namespace Nikse.SubtitleEdit.Forms.Assa
if (!LibMpvDynamic.IsInstalled) if (!LibMpvDynamic.IsInstalled)
{ {
return false; if (MessageBox.Show("Download and use \"mpv\" as video player?", "Subtitle Edit", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
{
using (var form = new SettingsMpv(!LibMpvDynamic.IsInstalled))
{
if (form.ShowDialog(this) != DialogResult.OK)
{
return;
}
Configuration.Settings.General.VideoPlayer = "MPV";
}
}
}
if (!LibMpvDynamic.IsInstalled)
{
return;
} }
if (_mpv == null) if (_mpv == null)
@ -246,8 +263,6 @@ namespace Nikse.SubtitleEdit.Forms.Assa
{ {
VideoLoaded(null, null); VideoLoaded(null, null);
} }
return true;
} }
public static Process GetFFmpegProcess(string outputFileName) public static Process GetFFmpegProcess(string outputFileName)
@ -274,7 +289,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
{ {
var format = new AdvancedSubStationAlpha(); var format = new AdvancedSubStationAlpha();
var subtitle = new Subtitle(); var subtitle = new Subtitle();
var indices = GetIndices(subtitle); var indices = GetIndices();
var styleToApply = $"{{\\pos({_x},{_y})}}"; var styleToApply = $"{{\\pos({_x},{_y})}}";
var p = indices.Length > 0 ? var p = indices.Length > 0 ?
@ -401,7 +416,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
var playResY = AdvancedSubStationAlpha.GetTagFromHeader("PlayResY", "[Script Info]", _subtitleWithNewHeader.Header); var playResY = AdvancedSubStationAlpha.GetTagFromHeader("PlayResY", "[Script Info]", _subtitleWithNewHeader.Header);
if (string.IsNullOrEmpty(playResX) || string.IsNullOrEmpty(playResY)) if (string.IsNullOrEmpty(playResX) || string.IsNullOrEmpty(playResY))
{ {
var dialogResult = MessageBox.Show("PlayResX/PlayResY are not set - set the resolution now?", "Subtitle Edit", MessageBoxButtons.YesNoCancel); var dialogResult = MessageBox.Show(LanguageSettings.Current.AssaSetPosition.ResolutionMissing, "Subtitle Edit", MessageBoxButtons.YesNoCancel);
if (dialogResult == DialogResult.OK || dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.OK || dialogResult == DialogResult.Yes)
{ {
_subtitleWithNewHeader.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResX", "PlayResX: " + _videoInfo.Width.ToString(CultureInfo.InvariantCulture), "[Script Info]", _subtitleWithNewHeader.Header); _subtitleWithNewHeader.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResX", "PlayResX: " + _videoInfo.Width.ToString(CultureInfo.InvariantCulture), "[Script Info]", _subtitleWithNewHeader.Header);
@ -415,7 +430,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
private void ShowCurrentPosition() private void ShowCurrentPosition()
{ {
var indices = GetIndices(_subtitle); var indices = GetIndices();
if (indices.Length == 0) if (indices.Length == 0)
{ {
return; return;
@ -446,7 +461,14 @@ namespace Nikse.SubtitleEdit.Forms.Assa
{ {
if (decimal.TryParse(arr[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var x)) if (decimal.TryParse(arr[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var x))
{ {
numericUpDownRotateX.Value = x; try
{
numericUpDownRotateX.Value = x;
}
catch
{
// ignore
}
} }
} }
} }
@ -459,7 +481,14 @@ namespace Nikse.SubtitleEdit.Forms.Assa
{ {
if (decimal.TryParse(arr[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var x)) if (decimal.TryParse(arr[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var x))
{ {
numericUpDownRotateY.Value = x; try
{
numericUpDownRotateY.Value = x;
}
catch
{
// ignore
}
} }
} }
} }
@ -472,7 +501,14 @@ namespace Nikse.SubtitleEdit.Forms.Assa
{ {
if (decimal.TryParse(arr[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var x)) if (decimal.TryParse(arr[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var x))
{ {
numericUpDownRotateZ.Value = x; try
{
numericUpDownRotateZ.Value = x;
}
catch
{
// ignore
}
} }
} }
} }
@ -485,7 +521,14 @@ namespace Nikse.SubtitleEdit.Forms.Assa
{ {
if (decimal.TryParse(arr[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var x)) if (decimal.TryParse(arr[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var x))
{ {
numericUpDownDistortX.Value = x; try
{
numericUpDownDistortX.Value = x;
}
catch
{
// ignore
}
} }
} }
} }
@ -498,7 +541,14 @@ namespace Nikse.SubtitleEdit.Forms.Assa
{ {
if (decimal.TryParse(arr[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var x)) if (decimal.TryParse(arr[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var x))
{ {
numericUpDownDistortY.Value = x; try
{
numericUpDownDistortY.Value = x;
}
catch
{
// ignore
}
} }
} }
} }
@ -506,7 +556,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
private void ShowStyleAlignment() private void ShowStyleAlignment()
{ {
var indices = GetIndices(_subtitle); var indices = GetIndices();
if (indices.Length == 0) if (indices.Length == 0)
{ {
labelStyleAlignment.Text = string.Format(LanguageSettings.Current.AssaSetPosition.StyleAlignmentX, "{\\an2}"); labelStyleAlignment.Text = string.Format(LanguageSettings.Current.AssaSetPosition.StyleAlignmentX, "{\\an2}");

View File

@ -340,6 +340,7 @@ namespace Nikse.SubtitleEdit.Logic
CurrentTextPositionX = "Text position: {0}", CurrentTextPositionX = "Text position: {0}",
SetPosInfo = "Click on video to toggle set/move position", SetPosInfo = "Click on video to toggle set/move position",
Clipboard = "Clipboard", Clipboard = "Clipboard",
ResolutionMissing = "PlayResX/PlayResY are not set - set the resolution now?",
}; };
AudioToText = new LanguageStructure.AudioToText AudioToText = new LanguageStructure.AudioToText

View File

@ -526,6 +526,9 @@ namespace Nikse.SubtitleEdit.Logic
case "AssaSetPosition/Clipboard": case "AssaSetPosition/Clipboard":
language.AssaSetPosition.Clipboard = reader.Value; language.AssaSetPosition.Clipboard = reader.Value;
break; break;
case "AssaSetPosition/ResolutionMissing":
language.AssaSetPosition.ResolutionMissing = reader.Value;
break;
case "AudioToText/Title": case "AudioToText/Title":
language.AudioToText.Title = reader.Value; language.AudioToText.Title = reader.Value;
break; break;

View File

@ -205,6 +205,7 @@
public string CurrentTextPositionX { get; set; } public string CurrentTextPositionX { get; set; }
public string SetPosInfo { get; set; } public string SetPosInfo { get; set; }
public string Clipboard { get; set; } public string Clipboard { get; set; }
public string ResolutionMissing { get; set; }
} }
public class AudioToText public class AudioToText