This commit is contained in:
Nikolaj Olsson 2019-10-04 23:01:03 +02:00
parent c069d13400
commit a03a22b194
16 changed files with 736 additions and 118 deletions

View File

@ -211,6 +211,7 @@ Note: Do check free disk space.</WaveFileMalformed>
<MultipleReplaceErrorX>Multiple replace: {0}</MultipleReplaceErrorX>
<AutoBalanceErrorX>Auto balance: {0}</AutoBalanceErrorX>
<OffsetTimeCodes>Offset time codes</OffsetTimeCodes>
<TransportStreamSettings>Transport Stream settings</TransportStreamSettings>
</BatchConvert>
<Beamer>
<Title>Beamer</Title>

View File

@ -351,6 +351,7 @@ namespace Nikse.SubtitleEdit.Core
MultipleReplaceErrorX = "Multiple replace: {0}",
AutoBalanceErrorX = "Auto balance: {0}",
OffsetTimeCodes = "Offset time codes",
TransportStreamSettings = "Transport Stream settings"
};
Beamer = new LanguageStructure.Beamer

View File

@ -574,6 +574,9 @@ namespace Nikse.SubtitleEdit.Core
case "BatchConvert/OffsetTimeCodes":
language.BatchConvert.OffsetTimeCodes = reader.Value;
break;
case "BatchConvert/TransportStreamSettings":
language.BatchConvert.TransportStreamSettings = reader.Value;
break;
case "Beamer/Title":
language.Beamer.Title = reader.Value;
break;

View File

@ -221,6 +221,7 @@
public string MultipleReplaceErrorX { get; set; }
public string AutoBalanceErrorX { get; set; }
public string OffsetTimeCodes { get; set; }
public string TransportStreamSettings { get; set; }
}
public class Beamer

View File

@ -151,6 +151,11 @@ namespace Nikse.SubtitleEdit.Core
public string BatchConvertSsaStyles { get; set; }
public bool BatchConvertUseStyleFromSource { get; set; }
public string BatchConvertExportCustomTextTemplate { get; set; }
public bool BatchConvertTsOverridePosition { get; set; }
public int BatchConvertTsOverrideBottomMargin { get; set; }
public bool BatchConvertTsOverrideScreenSize { get; set; }
public int BatchConvertTsScreenWidth { get; set; }
public int BatchConvertTsScreenHeight { get; set; }
public string ModifySelectionText { get; set; }
public string ModifySelectionRule { get; set; }
public bool ModifySelectionCaseSensitive { get; set; }
@ -280,6 +285,9 @@ namespace Nikse.SubtitleEdit.Core
JoinCorrectTimeCodes = true;
NewEmptyTranslationText = string.Empty;
BatchConvertLanguage = string.Empty;
BatchConvertTsOverrideBottomMargin = 20;
BatchConvertTsScreenWidth = 1920;
BatchConvertTsScreenHeight = 1080;
ModifySelectionRule = "Contains";
ModifySelectionText = string.Empty;
GenerateTimeCodePatterns = "HH:mm:ss;yyyy-MM-dd;dddd dd MMMM yyyy <br>HH:mm:ss;dddd dd MMMM yyyy <br>hh:mm:ss tt;s";

View File

@ -29,7 +29,7 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
Nikse.SubtitleEdit.Core.TimeCode timeCode1 = new Nikse.SubtitleEdit.Core.TimeCode();
Nikse.SubtitleEdit.Core.TimeCode timeCode2 = new Nikse.SubtitleEdit.Core.TimeCode();
this.buttonConvert = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.groupBoxConvertOptions = new System.Windows.Forms.GroupBox();
@ -93,6 +93,8 @@
this.contextMenuStripFiles = new System.Windows.Forms.ContextMenuStrip(this.components);
this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparatorTs = new System.Windows.Forms.ToolStripSeparator();
this.transportStreamSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
@ -459,14 +461,14 @@
this.timeUpDownAdjust.Name = "timeUpDownAdjust";
this.timeUpDownAdjust.Size = new System.Drawing.Size(96, 27);
this.timeUpDownAdjust.TabIndex = 1;
timeCode1.Hours = 0;
timeCode1.Milliseconds = 0;
timeCode1.Minutes = 0;
timeCode1.Seconds = 0;
timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00");
timeCode1.TotalMilliseconds = 0D;
timeCode1.TotalSeconds = 0D;
this.timeUpDownAdjust.TimeCode = timeCode1;
timeCode2.Hours = 0;
timeCode2.Milliseconds = 0;
timeCode2.Minutes = 0;
timeCode2.Seconds = 0;
timeCode2.TimeSpan = System.TimeSpan.Parse("00:00:00");
timeCode2.TotalMilliseconds = 0D;
timeCode2.TotalSeconds = 0D;
this.timeUpDownAdjust.TimeCode = timeCode2;
this.timeUpDownAdjust.UseVideoOffset = false;
//
// labelHourMinSecMilliSecond
@ -795,25 +797,39 @@
//
this.contextMenuStripFiles.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.removeToolStripMenuItem,
this.removeAllToolStripMenuItem});
this.removeAllToolStripMenuItem,
this.toolStripSeparatorTs,
this.transportStreamSettingsToolStripMenuItem});
this.contextMenuStripFiles.Name = "contextMenuStripStyles";
this.contextMenuStripFiles.Size = new System.Drawing.Size(133, 48);
this.contextMenuStripFiles.Size = new System.Drawing.Size(217, 98);
this.contextMenuStripFiles.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripFilesOpening);
//
// removeToolStripMenuItem
//
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
this.removeToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
this.removeToolStripMenuItem.Size = new System.Drawing.Size(216, 22);
this.removeToolStripMenuItem.Text = "Remove";
this.removeToolStripMenuItem.Click += new System.EventHandler(this.RemoveToolStripMenuItemClick);
//
// removeAllToolStripMenuItem
//
this.removeAllToolStripMenuItem.Name = "removeAllToolStripMenuItem";
this.removeAllToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
this.removeAllToolStripMenuItem.Size = new System.Drawing.Size(216, 22);
this.removeAllToolStripMenuItem.Text = "Remove all";
this.removeAllToolStripMenuItem.Click += new System.EventHandler(this.RemoveAllToolStripMenuItemClick);
//
// toolStripSeparatorTs
//
this.toolStripSeparatorTs.Name = "toolStripSeparatorTs";
this.toolStripSeparatorTs.Size = new System.Drawing.Size(213, 6);
//
// transportStreamSettingsToolStripMenuItem
//
this.transportStreamSettingsToolStripMenuItem.Name = "transportStreamSettingsToolStripMenuItem";
this.transportStreamSettingsToolStripMenuItem.Size = new System.Drawing.Size(216, 22);
this.transportStreamSettingsToolStripMenuItem.Text = "Transport Stream settings...";
this.transportStreamSettingsToolStripMenuItem.Click += new System.EventHandler(this.TransportStreamSettingsToolStripMenuItem_Click);
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
@ -944,5 +960,7 @@
private System.Windows.Forms.Button buttonBridgeGapsSettings;
private System.Windows.Forms.Button buttonFixRtlSettings;
private System.Windows.Forms.CheckBox checkBoxFixRtl;
private System.Windows.Forms.ToolStripSeparator toolStripSeparatorTs;
private System.Windows.Forms.ToolStripMenuItem transportStreamSettingsToolStripMenuItem;
}
}

View File

@ -251,6 +251,8 @@ namespace Nikse.SubtitleEdit.Forms
_bridgeGaps = new DurationsBridgeGaps(null);
_bridgeGaps.InitializeSettingsOnly();
toolStripSeparatorTs.Visible = false;
transportStreamSettingsToolStripMenuItem.Visible = false;
}
private void buttonChooseFolder_Click(object sender, EventArgs e)
@ -474,6 +476,12 @@ namespace Nikse.SubtitleEdit.Forms
{
listViewInputFiles.Items.Add(item);
}
if (isTs)
{
toolStripSeparatorTs.Visible = true;
transportStreamSettingsToolStripMenuItem.Visible = true;
}
}
catch
{
@ -1857,5 +1865,13 @@ namespace Nikse.SubtitleEdit.Forms
form.ShowDialog(this);
}
}
private void TransportStreamSettingsToolStripMenuItem_Click(object sender, EventArgs e)
{
using (var form = new BatchConvertTsSettings())
{
form.ShowDialog(this);
}
}
}
}

View File

@ -26,11 +26,11 @@ namespace Nikse.SubtitleEdit.Forms
UiUtil.FixLargeFonts(this, buttonOK);
var mode = Configuration.Settings.Tools.BatchConvertFixRtlMode;
if (mode == BatchConvertFixRtl.RemoveUnicode)
if (mode == RemoveUnicode)
{
radioButtonRemoveUnicode.Checked = true;
}
else if (mode == BatchConvertFixRtl.ReverseStartEnd)
else if (mode == ReverseStartEnd)
{
radioButtonReverseStartEnd.Checked = true;
}

View File

@ -0,0 +1,221 @@
namespace Nikse.SubtitleEdit.Forms
{
sealed partial class BatchConvertTsSettings
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.labelBottomMargin = new System.Windows.Forms.Label();
this.checkBoxOverrideOriginalPosition = new System.Windows.Forms.CheckBox();
this.numericUpDownBottomMargin = new System.Windows.Forms.NumericUpDown();
this.numericUpDownWidth = new System.Windows.Forms.NumericUpDown();
this.labelWidth = new System.Windows.Forms.Label();
this.checkBoxOverrideVideoSize = new System.Windows.Forms.CheckBox();
this.numericUpDownHeight = new System.Windows.Forms.NumericUpDown();
this.labelHeight = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownBottomMargin)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWidth)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownHeight)).BeginInit();
this.SuspendLayout();
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(231, 145);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 21);
this.buttonOK.TabIndex = 8;
this.buttonOK.Text = "&OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.ButtonOK_Click);
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(312, 145);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
this.buttonCancel.TabIndex = 9;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// labelBottomMargin
//
this.labelBottomMargin.AutoSize = true;
this.labelBottomMargin.Location = new System.Drawing.Point(23, 47);
this.labelBottomMargin.Name = "labelBottomMargin";
this.labelBottomMargin.Size = new System.Drawing.Size(74, 13);
this.labelBottomMargin.TabIndex = 10;
this.labelBottomMargin.Text = "Bottom margin";
//
// checkBoxOverrideOriginalPosition
//
this.checkBoxOverrideOriginalPosition.AutoSize = true;
this.checkBoxOverrideOriginalPosition.Location = new System.Drawing.Point(26, 24);
this.checkBoxOverrideOriginalPosition.Name = "checkBoxOverrideOriginalPosition";
this.checkBoxOverrideOriginalPosition.Size = new System.Drawing.Size(141, 17);
this.checkBoxOverrideOriginalPosition.TabIndex = 12;
this.checkBoxOverrideOriginalPosition.Text = "Override original position";
this.checkBoxOverrideOriginalPosition.UseVisualStyleBackColor = true;
this.checkBoxOverrideOriginalPosition.CheckedChanged += new System.EventHandler(this.CheckBoxOverrideOriginalPosition_CheckedChanged);
//
// numericUpDownBottomMargin
//
this.numericUpDownBottomMargin.Location = new System.Drawing.Point(105, 45);
this.numericUpDownBottomMargin.Maximum = new decimal(new int[] {
200,
0,
0,
0});
this.numericUpDownBottomMargin.Name = "numericUpDownBottomMargin";
this.numericUpDownBottomMargin.Size = new System.Drawing.Size(62, 20);
this.numericUpDownBottomMargin.TabIndex = 13;
//
// numericUpDownWidth
//
this.numericUpDownWidth.Location = new System.Drawing.Point(291, 50);
this.numericUpDownWidth.Maximum = new decimal(new int[] {
50000,
0,
0,
0});
this.numericUpDownWidth.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDownWidth.Name = "numericUpDownWidth";
this.numericUpDownWidth.Size = new System.Drawing.Size(62, 20);
this.numericUpDownWidth.TabIndex = 15;
this.numericUpDownWidth.Value = new decimal(new int[] {
1920,
0,
0,
0});
//
// labelWidth
//
this.labelWidth.AutoSize = true;
this.labelWidth.Location = new System.Drawing.Point(241, 52);
this.labelWidth.Name = "labelWidth";
this.labelWidth.Size = new System.Drawing.Size(35, 13);
this.labelWidth.TabIndex = 14;
this.labelWidth.Text = "Width";
//
// checkBoxOverrideVideoSize
//
this.checkBoxOverrideVideoSize.AutoSize = true;
this.checkBoxOverrideVideoSize.Location = new System.Drawing.Point(244, 24);
this.checkBoxOverrideVideoSize.Name = "checkBoxOverrideVideoSize";
this.checkBoxOverrideVideoSize.Size = new System.Drawing.Size(116, 17);
this.checkBoxOverrideVideoSize.TabIndex = 16;
this.checkBoxOverrideVideoSize.Text = "Override video size";
this.checkBoxOverrideVideoSize.UseVisualStyleBackColor = true;
this.checkBoxOverrideVideoSize.CheckedChanged += new System.EventHandler(this.CheckBoxOverrideVideoSize_CheckedChanged);
//
// numericUpDownHeight
//
this.numericUpDownHeight.Location = new System.Drawing.Point(291, 76);
this.numericUpDownHeight.Maximum = new decimal(new int[] {
50000,
0,
0,
0});
this.numericUpDownHeight.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDownHeight.Name = "numericUpDownHeight";
this.numericUpDownHeight.Size = new System.Drawing.Size(62, 20);
this.numericUpDownHeight.TabIndex = 18;
this.numericUpDownHeight.Value = new decimal(new int[] {
1080,
0,
0,
0});
//
// labelHeight
//
this.labelHeight.AutoSize = true;
this.labelHeight.Location = new System.Drawing.Point(241, 78);
this.labelHeight.Name = "labelHeight";
this.labelHeight.Size = new System.Drawing.Size(38, 13);
this.labelHeight.TabIndex = 17;
this.labelHeight.Text = "Height";
//
// BatchConvertTsSettings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(399, 178);
this.Controls.Add(this.numericUpDownHeight);
this.Controls.Add(this.labelHeight);
this.Controls.Add(this.checkBoxOverrideVideoSize);
this.Controls.Add(this.numericUpDownWidth);
this.Controls.Add(this.labelWidth);
this.Controls.Add(this.numericUpDownBottomMargin);
this.Controls.Add(this.checkBoxOverrideOriginalPosition);
this.Controls.Add(this.labelBottomMargin);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.buttonCancel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.KeyPreview = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "BatchConvertTsSettings";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "BatchConvertTsSettings";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.BatchConvertTsSettings_KeyDown);
((System.ComponentModel.ISupportInitialize)(this.numericUpDownBottomMargin)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWidth)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownHeight)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Label labelBottomMargin;
private System.Windows.Forms.CheckBox checkBoxOverrideOriginalPosition;
private System.Windows.Forms.NumericUpDown numericUpDownBottomMargin;
private System.Windows.Forms.NumericUpDown numericUpDownWidth;
private System.Windows.Forms.Label labelWidth;
private System.Windows.Forms.CheckBox checkBoxOverrideVideoSize;
private System.Windows.Forms.NumericUpDown numericUpDownHeight;
private System.Windows.Forms.Label labelHeight;
}
}

View File

@ -0,0 +1,68 @@
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms
{
public sealed partial class BatchConvertTsSettings : Form
{
public BatchConvertTsSettings()
{
UiUtil.PreInitialize(this);
InitializeComponent();
UiUtil.FixFonts(this);
Text = Configuration.Settings.Language.BatchConvert.TransportStreamSettings;
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
buttonOK.Text = Configuration.Settings.Language.General.Ok;
UiUtil.FixLargeFonts(this, buttonOK);
checkBoxOverrideOriginalPosition.Checked = Configuration.Settings.Tools.BatchConvertTsOverridePosition;
numericUpDownBottomMargin.Value = Configuration.Settings.Tools.BatchConvertTsOverrideBottomMargin;
checkBoxOverrideVideoSize.Checked = Configuration.Settings.Tools.BatchConvertTsOverrideScreenSize;
numericUpDownWidth.Value = Configuration.Settings.Tools.BatchConvertTsScreenWidth;
numericUpDownHeight.Value = Configuration.Settings.Tools.BatchConvertTsScreenHeight;
CheckBoxOverrideOriginalPosition_CheckedChanged(null, null);
CheckBoxOverrideVideoSize_CheckedChanged(null, null);
}
private void CheckBoxOverrideOriginalPosition_CheckedChanged(object sender, System.EventArgs e)
{
labelBottomMargin.Enabled = checkBoxOverrideOriginalPosition.Checked;
numericUpDownBottomMargin.Enabled = checkBoxOverrideOriginalPosition.Checked;
}
private void CheckBoxOverrideVideoSize_CheckedChanged(object sender, System.EventArgs e)
{
labelWidth.Enabled = checkBoxOverrideVideoSize.Checked;
numericUpDownWidth.Enabled = checkBoxOverrideVideoSize.Checked;
labelHeight.Enabled = checkBoxOverrideVideoSize.Checked;
numericUpDownHeight.Enabled = checkBoxOverrideVideoSize.Checked;
if (checkBoxOverrideVideoSize.Checked && !checkBoxOverrideOriginalPosition.Checked)
{
checkBoxOverrideOriginalPosition.Checked = true;
}
checkBoxOverrideOriginalPosition.Enabled = !checkBoxOverrideVideoSize.Checked;
CheckBoxOverrideOriginalPosition_CheckedChanged(null, null);
}
private void BatchConvertTsSettings_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
DialogResult = DialogResult.Cancel;
}
}
private void ButtonOK_Click(object sender, System.EventArgs e)
{
Configuration.Settings.Tools.BatchConvertTsOverridePosition = checkBoxOverrideOriginalPosition.Checked;
Configuration.Settings.Tools.BatchConvertTsOverrideBottomMargin = (int)numericUpDownBottomMargin.Value;
Configuration.Settings.Tools.BatchConvertTsOverrideScreenSize= checkBoxOverrideVideoSize.Checked;
Configuration.Settings.Tools.BatchConvertTsScreenWidth = (int)numericUpDownWidth.Value;
Configuration.Settings.Tools.BatchConvertTsScreenHeight = (int)numericUpDownHeight.Value;
DialogResult = DialogResult.OK;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -356,6 +356,14 @@ namespace Nikse.SubtitleEdit.Forms
}
else
{
if (param.OverridePosition != null &&
param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.ScreenWidth &&
param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.ScreenHeight)
{
param.LeftMargin = param.OverridePosition.Value.X;
param.BottomMargin = param.ScreenHeight - param.OverridePosition.Value.Y - param.Bitmap.Height;
}
param.Buffer = BluRaySupPicture.CreateSupFrame(brSub, param.Bitmap, param.FramesPerSeconds, param.BottomMargin, param.LeftMargin, param.Alignment, param.OverridePosition);
}
}

View File

@ -18,6 +18,7 @@ using Nikse.SubtitleEdit.Forms.Ocr;
namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
{
public static class CommandLineConverter
{
private static StreamWriter _stdOutWriter;
@ -1273,7 +1274,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
if ((ext.Equals(".ts", StringComparison.OrdinalIgnoreCase) || ext.Equals(".m2ts", StringComparison.OrdinalIgnoreCase)) &&
(FileUtil.IsTransportStream(fileName) || FileUtil.IsM2TransportStream(fileName)))
{
ConvertFromTsToBluRaySup(fileName, outputFolder, overwrite, _stdOutWriter);
TsToBluRaySup.ConvertFromTsToBluRaySup(fileName, outputFolder, overwrite, _stdOutWriter);
}
else
{
@ -1483,62 +1484,71 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
else if (BatchConvert.BdnXmlSubtitle.RemoveChar(' ').Equals(targetFormat.RemoveChar(' '), StringComparison.OrdinalIgnoreCase))
{
targetFormatFound = true;
outputFileName = FormatOutputFileNameForBatchConvert(fileName, ".xml", outputFolder, overwrite);
_stdOutWriter?.Write($"{count}: {Path.GetFileName(fileName)} -> {outputFileName}...");
using (var form = new ExportPngXml())
var ext = Path.GetExtension(fileName);
if ((ext.Equals(".ts", StringComparison.OrdinalIgnoreCase) || ext.Equals(".m2ts", StringComparison.OrdinalIgnoreCase)) &&
(FileUtil.IsTransportStream(fileName) || FileUtil.IsM2TransportStream(fileName)))
{
form.Initialize(sub, format, ExportPngXml.ExportFormats.BdnXml, fileName, null, null);
int width = 1920;
int height = 1080;
if (!string.IsNullOrEmpty(Configuration.Settings.Tools.ExportBluRayVideoResolution))
TsToBdnXml.ConvertFromTsToBdnXml(fileName, outputFolder, overwrite, _stdOutWriter);
}
else
{
outputFileName = FormatOutputFileNameForBatchConvert(fileName, ".xml", outputFolder, overwrite);
_stdOutWriter?.Write($"{count}: {Path.GetFileName(fileName)} -> {outputFileName}...");
using (var form = new ExportPngXml())
{
var parts = Configuration.Settings.Tools.ExportBluRayVideoResolution.Split('x');
if (parts.Length == 2 && Utilities.IsInteger(parts[0]) && Utilities.IsInteger(parts[1]))
form.Initialize(sub, format, ExportPngXml.ExportFormats.BdnXml, fileName, null, null);
int width = 1920;
int height = 1080;
if (!string.IsNullOrEmpty(Configuration.Settings.Tools.ExportBluRayVideoResolution))
{
width = int.Parse(parts[0]);
height = int.Parse(parts[1]);
}
}
if (resolution != null)
{
width = resolution.Value.X;
height = resolution.Value.Y;
}
var sb = new StringBuilder();
var imagesSavedCount = 0;
var isImageBased = IsImageBased(format);
for (int index = 0; index < sub.Paragraphs.Count; index++)
{
var mp = form.MakeMakeBitmapParameter(index, width, height);
mp.LineJoin = Configuration.Settings.Tools.ExportPenLineJoin;
if (binaryParagraphs != null && binaryParagraphs.Count > 0)
{
if (binaryParagraphs.Count > index)
var parts = Configuration.Settings.Tools.ExportBluRayVideoResolution.Split('x');
if (parts.Length == 2 && Utilities.IsInteger(parts[0]) && Utilities.IsInteger(parts[1]))
{
mp.Bitmap = binaryParagraphs[index].GetBitmap();
mp.Forced = binaryParagraphs[index].IsForced;
width = int.Parse(parts[0]);
height = int.Parse(parts[1]);
}
}
else if (isImageBased)
if (resolution != null)
{
using (var ms = new MemoryStream(File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(fileName), sub.Paragraphs[index].Text))))
width = resolution.Value.X;
height = resolution.Value.Y;
}
var sb = new StringBuilder();
var imagesSavedCount = 0;
var isImageBased = IsImageBased(format);
for (int index = 0; index < sub.Paragraphs.Count; index++)
{
var mp = form.MakeMakeBitmapParameter(index, width, height);
mp.LineJoin = Configuration.Settings.Tools.ExportPenLineJoin;
if (binaryParagraphs != null && binaryParagraphs.Count > 0)
{
mp.Bitmap = (Bitmap)Image.FromStream(ms);
if (binaryParagraphs.Count > index)
{
mp.Bitmap = binaryParagraphs[index].GetBitmap();
mp.Forced = binaryParagraphs[index].IsForced;
}
}
else if (isImageBased)
{
using (var ms = new MemoryStream(File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(fileName), sub.Paragraphs[index].Text))))
{
mp.Bitmap = (Bitmap)Image.FromStream(ms);
}
}
else
{
mp.Bitmap = ExportPngXml.GenerateImageFromTextWithStyle(mp);
}
imagesSavedCount = form.WriteBdnXmlParagraph(width, sb, form.GetBottomMarginInPixels(sub.Paragraphs[index]), height, imagesSavedCount, mp, index, Path.GetDirectoryName(outputFileName));
if (index % 50 == 0)
{
System.Windows.Forms.Application.DoEvents();
}
}
else
{
mp.Bitmap = ExportPngXml.GenerateImageFromTextWithStyle(mp);
}
imagesSavedCount = form.WriteBdnXmlParagraph(width, sb, form.GetBottomMarginInPixels(sub.Paragraphs[index]), height, imagesSavedCount, mp, index, Path.GetDirectoryName(outputFileName));
if (index % 50 == 0)
{
System.Windows.Forms.Application.DoEvents();
}
form.WriteBdnXmlFile(imagesSavedCount, sb, outputFileName);
}
form.WriteBdnXmlFile(imagesSavedCount, sb, outputFileName);
}
_stdOutWriter?.WriteLine(" done.");
}
@ -1647,67 +1657,12 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
}
}
private static void ConvertFromTsToBluRaySup(string fileName, string outputFolder, bool overwrite, StreamWriter stdOutWriter)
{
var tsParser = new TransportStreamParser();
tsParser.Parse(fileName, (position, total) =>
{
var percent = (int)Math.Round(position * 100.0 / total);
stdOutWriter?.Write("\rParsing transport stream: {0}%", percent);
});
stdOutWriter?.Write("\r".PadRight(32, ' '));
stdOutWriter?.Write("\r");
var videoInfo = UiUtil.GetVideoInfo(fileName);
int width = 720;
int height = 576;
if (videoInfo.Success && videoInfo.Width > 0 && videoInfo.Height > 0)
{
width = videoInfo.Width;
height = videoInfo.Height;
}
foreach (int pid in tsParser.SubtitlePacketIds)
{
var outputFileName = FormatOutputFileNameForBatchConvert(Utilities.GetPathAndFileNameWithoutExtension(fileName) + "-" + pid + Path.GetExtension(fileName), ".sup", outputFolder, overwrite);
stdOutWriter?.WriteLine($"Saving PID {pid} to {outputFileName}...");
var sub = tsParser.GetDvbSubtitles(pid);
using (var binarySubtitleFile = new FileStream(outputFileName, FileMode.Create))
{
for (int index = 0; index < sub.Count; index++)
{
var p = sub[index];
var pos = p.GetPosition();
var bmp = sub[index].GetBitmap();
var nbmp = new NikseBitmap(bmp);
pos.Top += nbmp.CropTopTransparent(0);
pos.Left += nbmp.CropSidesAndBottom(0, Color.FromArgb(0, 0, 0, 0), true);
bmp.Dispose();
bmp = nbmp.GetBitmap();
var mp = new ExportPngXml.MakeBitmapParameter
{
Bitmap = bmp,
P = new Paragraph(string.Empty, p.StartMilliseconds, p.EndMilliseconds),
ScreenWidth = width,
ScreenHeight = height,
OverridePosition = new Point(pos.Left, pos.Top)
};
ExportPngXml.MakeBluRaySupImage(mp);
binarySubtitleFile.Write(mp.Buffer, 0, mp.Buffer.Length);
if (mp.Bitmap != null)
{
mp.Bitmap.Dispose();
mp.Bitmap = null;
}
}
}
}
}
private static bool IsImageBased(SubtitleFormat format)
internal static bool IsImageBased(SubtitleFormat format)
{
return format is TimedTextImage || format is FinalCutProImage || format is SpuImage || format is Dost || format is SeImageHtmlIndex || format is BdnXml;
}
private static string FormatOutputFileNameForBatchConvert(string fileName, string extension, string outputFolder, bool overwrite)
internal static string FormatOutputFileNameForBatchConvert(string fileName, string extension, string outputFolder, bool overwrite)
{
string outputFileName = Path.ChangeExtension(fileName, extension);
if (!string.IsNullOrEmpty(outputFolder))

View File

@ -0,0 +1,98 @@
using System;
using System.Drawing;
using System.IO;
using System.Text;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Core.TransportStream;
using Nikse.SubtitleEdit.Forms;
namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
{
public static class TsToBdnXml
{
public static void ConvertFromTsToBdnXml(string fileName, string outputFolder, bool overwrite, StreamWriter stdOutWriter)
{
var tsParser = new TransportStreamParser();
tsParser.Parse(fileName, (position, total) =>
{
var percent = (int)Math.Round(position * 100.0 / total);
stdOutWriter?.Write("\rParsing transport stream: {0}%", percent);
});
stdOutWriter?.Write("\r".PadRight(32, ' '));
stdOutWriter?.Write("\r");
var videoInfo = UiUtil.GetVideoInfo(fileName);
int width = 1920;
int height = 1080;
if (videoInfo.Success && videoInfo.Width > 0 && videoInfo.Height > 0)
{
width = videoInfo.Width;
height = videoInfo.Height;
}
if (Configuration.Settings.Tools.BatchConvertTsOverrideScreenSize &&
Configuration.Settings.Tools.BatchConvertTsScreenWidth > 0 &&
Configuration.Settings.Tools.BatchConvertTsScreenHeight > 0)
{
width = Configuration.Settings.Tools.BatchConvertTsScreenWidth;
height = Configuration.Settings.Tools.BatchConvertTsScreenHeight;
}
using (var form = new ExportPngXml())
{
foreach (int pid in tsParser.SubtitlePacketIds)
{
var outputFileName = CommandLineConverter.FormatOutputFileNameForBatchConvert(Utilities.GetPathAndFileNameWithoutExtension(fileName) + "-" + pid + Path.GetExtension(fileName), ".xml", outputFolder, overwrite);
stdOutWriter?.WriteLine($"Saving PID {pid} to {outputFileName}...");
var sub = tsParser.GetDvbSubtitles(pid);
var subtitle = new Subtitle();
for (int index = 0; index < sub.Count; index++)
{
var p = sub[index];
subtitle.Paragraphs.Add(new Paragraph(string.Empty, p.StartMilliseconds, p.EndMilliseconds));
}
form.Initialize(subtitle, new SubRip(), BatchConvert.BdnXmlSubtitle, fileName, videoInfo, fileName);
var sb = new StringBuilder();
var imagesSavedCount = 0;
for (int index = 0; index < sub.Count; index++)
{
var p = sub[index];
var pos = p.GetPosition();
var bmp = sub[index].GetBitmap();
var nbmp = new NikseBitmap(bmp);
pos.Top += nbmp.CropTopTransparent(0);
pos.Left += nbmp.CropSidesAndBottom(0, Color.FromArgb(0, 0, 0, 0), true);
bmp.Dispose();
bmp = nbmp.GetBitmap();
var mp = form.MakeMakeBitmapParameter(index, width, height);
mp.Bitmap = bmp;
mp.P = new Paragraph(string.Empty, p.StartMilliseconds, p.EndMilliseconds);
mp.ScreenWidth = width;
mp.ScreenHeight = height;
int bottomMarginInPixels;
if (Configuration.Settings.Tools.BatchConvertTsOverridePosition ||
Configuration.Settings.Tools.BatchConvertTsOverrideScreenSize &&
Configuration.Settings.Tools.BatchConvertTsScreenWidth > 0 &&
Configuration.Settings.Tools.BatchConvertTsScreenHeight > 0)
{
mp.BottomMargin = Configuration.Settings.Tools.BatchConvertTsOverrideBottomMargin;
bottomMarginInPixels = Configuration.Settings.Tools.BatchConvertTsOverrideBottomMargin;
mp.Alignment = ContentAlignment.BottomCenter;
}
else
{
mp.OverridePosition = new Point(pos.Left, pos.Top); // use original position
bottomMarginInPixels = Configuration.Settings.Tools.BatchConvertTsScreenHeight - pos.Top - mp.Bitmap.Height;
}
imagesSavedCount = form.WriteBdnXmlParagraph(width, sb, bottomMarginInPixels, height, imagesSavedCount, mp, index, Path.GetDirectoryName(outputFileName));
if (mp.Bitmap != null)
{
mp.Bitmap.Dispose();
mp.Bitmap = null;
}
}
form.WriteBdnXmlFile(imagesSavedCount, sb, outputFileName);
}
}
}
}
}

View File

@ -0,0 +1,89 @@
using System;
using System.Drawing;
using System.IO;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Core.TransportStream;
using Nikse.SubtitleEdit.Forms;
namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
{
public static class TsToBluRaySup
{
public static void ConvertFromTsToBluRaySup(string fileName, string outputFolder, bool overwrite, StreamWriter stdOutWriter)
{
var tsParser = new TransportStreamParser();
tsParser.Parse(fileName, (position, total) =>
{
var percent = (int)Math.Round(position * 100.0 / total);
stdOutWriter?.Write("\rParsing transport stream: {0}%", percent);
});
stdOutWriter?.Write("\r".PadRight(32, ' '));
stdOutWriter?.Write("\r");
var videoInfo = UiUtil.GetVideoInfo(fileName);
int width = 720;
int height = 576;
if (videoInfo.Success && videoInfo.Width > 0 && videoInfo.Height > 0)
{
width = videoInfo.Width;
height = videoInfo.Height;
}
if (Configuration.Settings.Tools.BatchConvertTsOverrideScreenSize &&
Configuration.Settings.Tools.BatchConvertTsScreenWidth > 0 &&
Configuration.Settings.Tools.BatchConvertTsScreenHeight > 0)
{
width = Configuration.Settings.Tools.BatchConvertTsScreenWidth;
height = Configuration.Settings.Tools.BatchConvertTsScreenHeight;
}
using (var form = new ExportPngXml())
{
form.Initialize(new Subtitle(), new SubRip(), BatchConvert.BluRaySubtitle, fileName, videoInfo, fileName);
foreach (int pid in tsParser.SubtitlePacketIds)
{
var outputFileName = CommandLineConverter.FormatOutputFileNameForBatchConvert(Utilities.GetPathAndFileNameWithoutExtension(fileName) + "-" + pid + Path.GetExtension(fileName), ".sup", outputFolder, overwrite);
stdOutWriter?.WriteLine($"Saving PID {pid} to {outputFileName}...");
var sub = tsParser.GetDvbSubtitles(pid);
using (var binarySubtitleFile = new FileStream(outputFileName, FileMode.Create))
{
for (int index = 0; index < sub.Count; index++)
{
var p = sub[index];
var pos = p.GetPosition();
var bmp = sub[index].GetBitmap();
var nbmp = new NikseBitmap(bmp);
pos.Top += nbmp.CropTopTransparent(0);
pos.Left += nbmp.CropSidesAndBottom(0, Color.FromArgb(0, 0, 0, 0), true);
bmp.Dispose();
bmp = nbmp.GetBitmap();
var mp = form.MakeMakeBitmapParameter(index, width, height);
mp.Bitmap = bmp;
mp.P = new Paragraph(string.Empty, p.StartMilliseconds, p.EndMilliseconds);
mp.ScreenWidth = width;
mp.ScreenHeight = height;
if (Configuration.Settings.Tools.BatchConvertTsOverridePosition ||
Configuration.Settings.Tools.BatchConvertTsOverrideScreenSize &&
Configuration.Settings.Tools.BatchConvertTsScreenWidth > 0 &&
Configuration.Settings.Tools.BatchConvertTsScreenHeight > 0)
{
mp.BottomMargin = Configuration.Settings.Tools.BatchConvertTsOverrideBottomMargin;
mp.Alignment = ContentAlignment.BottomCenter;
}
else
{
mp.OverridePosition = new Point(pos.Left, pos.Top); // use original position
}
ExportPngXml.MakeBluRaySupImage(mp);
binarySubtitleFile.Write(mp.Buffer, 0, mp.Buffer.Length);
if (mp.Bitmap != null)
{
mp.Bitmap.Dispose();
mp.Bitmap = null;
}
}
}
}
}
}
}
}

View File

@ -86,6 +86,12 @@
<Compile Include="Controls\AudioVisualizer.Designer.cs">
<DependentUpon>AudioVisualizer.cs</DependentUpon>
</Compile>
<Compile Include="Forms\BatchConvertTsSettings.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\BatchConvertTsSettings.Designer.cs">
<DependentUpon>BatchConvertTsSettings.cs</DependentUpon>
</Compile>
<Compile Include="Forms\BookmarkAdd.cs">
<SubType>Form</SubType>
</Compile>
@ -980,6 +986,8 @@
<Compile Include="Logic\CommandLineConvert\CommandLineConverter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Logic\CommandLineConvert\TsToBdnXml.cs" />
<Compile Include="Logic\CommandLineConvert\TsToBluRaySup.cs" />
<Compile Include="Logic\DarkTheme.cs" />
<Compile Include="Logic\FindReplaceDialogHelper.cs" />
<Compile Include="Logic\ListViewSorter.cs" />
@ -1062,6 +1070,9 @@
<EmbeddedResource Include="Controls\AudioVisualizer.resx">
<DependentUpon>AudioVisualizer.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\BatchConvertTsSettings.resx">
<DependentUpon>BatchConvertTsSettings.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\BookmarkAdd.resx">
<DependentUpon>BookmarkAdd.cs</DependentUpon>
</EmbeddedResource>