mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Added two new subtitle formats
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1796 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
5c1685b124
commit
e28630399f
328
src/Forms/HardSubExtract.Designer.cs
generated
Normal file
328
src/Forms/HardSubExtract.Designer.cs
generated
Normal file
@ -0,0 +1,328 @@
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
partial class HardSubExtract
|
||||
{
|
||||
/// <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.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.domainUpDown2 = new System.Windows.Forms.DomainUpDown();
|
||||
this.domainUpDown1 = new System.Windows.Forms.DomainUpDown();
|
||||
this.checkBox2 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox1 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxBackgroundTransparent = new System.Windows.Forms.CheckBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.pictureBoxBackground = new System.Windows.Forms.PictureBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.groupBoxImportResult = new System.Windows.Forms.GroupBox();
|
||||
this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
|
||||
this.pictureBox2 = new System.Windows.Forms.PictureBox();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.panelVlc = new System.Windows.Forms.Panel();
|
||||
this.button3 = new System.Windows.Forms.Button();
|
||||
this.button4 = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBackground)).BeginInit();
|
||||
this.groupBoxImportResult.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.label4);
|
||||
this.groupBox1.Controls.Add(this.label3);
|
||||
this.groupBox1.Controls.Add(this.domainUpDown2);
|
||||
this.groupBox1.Controls.Add(this.domainUpDown1);
|
||||
this.groupBox1.Controls.Add(this.checkBox2);
|
||||
this.groupBox1.Controls.Add(this.checkBox1);
|
||||
this.groupBox1.Controls.Add(this.checkBoxBackgroundTransparent);
|
||||
this.groupBox1.Controls.Add(this.label2);
|
||||
this.groupBox1.Controls.Add(this.pictureBox1);
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
this.groupBox1.Controls.Add(this.pictureBoxBackground);
|
||||
this.groupBox1.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(298, 225);
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Detection options";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(163, 119);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(33, 13);
|
||||
this.label4.TabIndex = 18;
|
||||
this.label4.Text = "pixels";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(13, 166);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(139, 13);
|
||||
this.label3.TabIndex = 17;
|
||||
this.label3.Text = "Scan interval in milliseconds";
|
||||
//
|
||||
// domainUpDown2
|
||||
//
|
||||
this.domainUpDown2.Location = new System.Drawing.Point(16, 182);
|
||||
this.domainUpDown2.Name = "domainUpDown2";
|
||||
this.domainUpDown2.Size = new System.Drawing.Size(120, 20);
|
||||
this.domainUpDown2.TabIndex = 16;
|
||||
this.domainUpDown2.Text = "domainUpDown2";
|
||||
//
|
||||
// domainUpDown1
|
||||
//
|
||||
this.domainUpDown1.Location = new System.Drawing.Point(37, 117);
|
||||
this.domainUpDown1.Name = "domainUpDown1";
|
||||
this.domainUpDown1.Size = new System.Drawing.Size(120, 20);
|
||||
this.domainUpDown1.TabIndex = 15;
|
||||
this.domainUpDown1.Text = "domainUpDown1";
|
||||
//
|
||||
// checkBox2
|
||||
//
|
||||
this.checkBox2.AutoSize = true;
|
||||
this.checkBox2.Checked = true;
|
||||
this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.checkBox2.Location = new System.Drawing.Point(16, 97);
|
||||
this.checkBox2.Name = "checkBox2";
|
||||
this.checkBox2.Size = new System.Drawing.Size(141, 17);
|
||||
this.checkBox2.TabIndex = 14;
|
||||
this.checkBox2.Text = "Only search lower image";
|
||||
this.checkBox2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBox1
|
||||
//
|
||||
this.checkBox1.AutoSize = true;
|
||||
this.checkBox1.Checked = true;
|
||||
this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.checkBox1.Location = new System.Drawing.Point(109, 58);
|
||||
this.checkBox1.Name = "checkBox1";
|
||||
this.checkBox1.Size = new System.Drawing.Size(119, 17);
|
||||
this.checkBox1.TabIndex = 13;
|
||||
this.checkBox1.Text = "Only exact matches";
|
||||
this.checkBox1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxBackgroundTransparent
|
||||
//
|
||||
this.checkBoxBackgroundTransparent.AutoSize = true;
|
||||
this.checkBoxBackgroundTransparent.Checked = true;
|
||||
this.checkBoxBackgroundTransparent.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.checkBoxBackgroundTransparent.Location = new System.Drawing.Point(109, 31);
|
||||
this.checkBoxBackgroundTransparent.Name = "checkBoxBackgroundTransparent";
|
||||
this.checkBoxBackgroundTransparent.Size = new System.Drawing.Size(119, 17);
|
||||
this.checkBoxBackgroundTransparent.TabIndex = 12;
|
||||
this.checkBoxBackgroundTransparent.Text = "Only exact matches";
|
||||
this.checkBoxBackgroundTransparent.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(43, 59);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(60, 13);
|
||||
this.label2.TabIndex = 11;
|
||||
this.label2.Text = "Font color1";
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.pictureBox1.Location = new System.Drawing.Point(16, 51);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(21, 21);
|
||||
this.pictureBox1.TabIndex = 10;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(43, 32);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(60, 13);
|
||||
this.label1.TabIndex = 9;
|
||||
this.label1.Text = "Font color1";
|
||||
//
|
||||
// pictureBoxBackground
|
||||
//
|
||||
this.pictureBoxBackground.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.pictureBoxBackground.Location = new System.Drawing.Point(16, 24);
|
||||
this.pictureBoxBackground.Name = "pictureBoxBackground";
|
||||
this.pictureBoxBackground.Size = new System.Drawing.Size(21, 21);
|
||||
this.pictureBoxBackground.TabIndex = 8;
|
||||
this.pictureBoxBackground.TabStop = false;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(12, 243);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 1;
|
||||
this.button1.Text = "Start";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBoxImportResult
|
||||
//
|
||||
this.groupBoxImportResult.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBoxImportResult.Controls.Add(this.SubtitleListview1);
|
||||
this.groupBoxImportResult.Location = new System.Drawing.Point(316, 12);
|
||||
this.groupBoxImportResult.Name = "groupBoxImportResult";
|
||||
this.groupBoxImportResult.Size = new System.Drawing.Size(580, 228);
|
||||
this.groupBoxImportResult.TabIndex = 3;
|
||||
this.groupBoxImportResult.TabStop = false;
|
||||
this.groupBoxImportResult.Text = "Preview";
|
||||
//
|
||||
// SubtitleListview1
|
||||
//
|
||||
this.SubtitleListview1.AllowDrop = true;
|
||||
this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.SubtitleListview1.DisplayExtraFromExtra = false;
|
||||
this.SubtitleListview1.FirstVisibleIndex = -1;
|
||||
this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.SubtitleListview1.FullRowSelect = true;
|
||||
this.SubtitleListview1.GridLines = true;
|
||||
this.SubtitleListview1.HideSelection = false;
|
||||
this.SubtitleListview1.Location = new System.Drawing.Point(6, 19);
|
||||
this.SubtitleListview1.MultiSelect = false;
|
||||
this.SubtitleListview1.Name = "SubtitleListview1";
|
||||
this.SubtitleListview1.OwnerDraw = true;
|
||||
this.SubtitleListview1.Size = new System.Drawing.Size(568, 187);
|
||||
this.SubtitleListview1.TabIndex = 0;
|
||||
this.SubtitleListview1.UseCompatibleStateImageBehavior = false;
|
||||
this.SubtitleListview1.UseSyntaxColoring = true;
|
||||
this.SubtitleListview1.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// pictureBox2
|
||||
//
|
||||
this.pictureBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pictureBox2.Location = new System.Drawing.Point(316, 275);
|
||||
this.pictureBox2.Name = "pictureBox2";
|
||||
this.pictureBox2.Size = new System.Drawing.Size(580, 277);
|
||||
this.pictureBox2.TabIndex = 4;
|
||||
this.pictureBox2.TabStop = false;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Location = new System.Drawing.Point(316, 246);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(75, 23);
|
||||
this.button2.TabIndex = 5;
|
||||
this.button2.Text = "Go forward";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// panelVlc
|
||||
//
|
||||
this.panelVlc.Location = new System.Drawing.Point(12, 275);
|
||||
this.panelVlc.Name = "panelVlc";
|
||||
this.panelVlc.Size = new System.Drawing.Size(298, 136);
|
||||
this.panelVlc.TabIndex = 6;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
this.button3.Location = new System.Drawing.Point(397, 246);
|
||||
this.button3.Name = "button3";
|
||||
this.button3.Size = new System.Drawing.Size(154, 23);
|
||||
this.button3.TabIndex = 7;
|
||||
this.button3.Text = "Check for text";
|
||||
this.button3.UseVisualStyleBackColor = true;
|
||||
this.button3.Click += new System.EventHandler(this.button3_Click);
|
||||
//
|
||||
// button4
|
||||
//
|
||||
this.button4.Location = new System.Drawing.Point(557, 246);
|
||||
this.button4.Name = "button4";
|
||||
this.button4.Size = new System.Drawing.Size(154, 23);
|
||||
this.button4.TabIndex = 8;
|
||||
this.button4.Text = "Check for text";
|
||||
this.button4.UseVisualStyleBackColor = true;
|
||||
this.button4.Click += new System.EventHandler(this.button4_Click);
|
||||
//
|
||||
// HardSubExtract
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(908, 564);
|
||||
this.Controls.Add(this.button4);
|
||||
this.Controls.Add(this.button3);
|
||||
this.Controls.Add(this.panelVlc);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.pictureBox2);
|
||||
this.Controls.Add(this.groupBoxImportResult);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.KeyPreview = true;
|
||||
this.Name = "HardSubExtract";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "HardSubExtract";
|
||||
this.Shown += new System.EventHandler(this.HardSubExtract_Shown);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBackground)).EndInit();
|
||||
this.groupBoxImportResult.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.PictureBox pictureBoxBackground;
|
||||
private System.Windows.Forms.DomainUpDown domainUpDown1;
|
||||
private System.Windows.Forms.CheckBox checkBox2;
|
||||
private System.Windows.Forms.CheckBox checkBox1;
|
||||
private System.Windows.Forms.CheckBox checkBoxBackgroundTransparent;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.DomainUpDown domainUpDown2;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.GroupBox groupBoxImportResult;
|
||||
private Controls.SubtitleListView SubtitleListview1;
|
||||
private System.Windows.Forms.PictureBox pictureBox2;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.Panel panelVlc;
|
||||
private System.Windows.Forms.Button button3;
|
||||
private System.Windows.Forms.Button button4;
|
||||
}
|
||||
}
|
86
src/Forms/HardSubExtract.cs
Normal file
86
src/Forms/HardSubExtract.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Nikse.SubtitleEdit.Logic;
|
||||
using Nikse.SubtitleEdit.Logic.VideoPlayers;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
public partial class HardSubExtract : Form
|
||||
{
|
||||
private string _videoFileName;
|
||||
private LibVlc11xDynamic _libVlc;
|
||||
private VideoInfo _videoInfo;
|
||||
int startMilliseconds = 6000;
|
||||
|
||||
public HardSubExtract(string videoFileName)
|
||||
{
|
||||
InitializeComponent();
|
||||
_videoFileName = videoFileName;
|
||||
_libVlc = new LibVlc11xDynamic();
|
||||
}
|
||||
|
||||
private void HardSubExtract_Shown(object sender, EventArgs e)
|
||||
{
|
||||
_videoInfo = Utilities.GetVideoInfo(_videoFileName, null);
|
||||
_libVlc.Initialize(panelVlc, _videoFileName, null, null);
|
||||
}
|
||||
|
||||
private Bitmap GetSnapShot(long milliseconds)
|
||||
{
|
||||
string fileName = Path.GetTempFileName() + ".png";
|
||||
_libVlc.CurrentPosition = milliseconds / 1000.0;
|
||||
_libVlc.TakeSnapshot(fileName, (uint)_videoInfo.Width, (uint)_videoInfo.Height);
|
||||
int i=0;
|
||||
while (i < 100 && !File.Exists(fileName))
|
||||
{
|
||||
System.Threading.Thread.Sleep(50);
|
||||
Application.DoEvents();
|
||||
i++;
|
||||
}
|
||||
System.Threading.Thread.Sleep(10);
|
||||
Application.DoEvents();
|
||||
Bitmap bmp = null;
|
||||
try
|
||||
{
|
||||
using (var ms = new MemoryStream(File.ReadAllBytes(fileName)))
|
||||
{
|
||||
bmp = ((Bitmap)Bitmap.FromStream(ms)); // avoid locking file
|
||||
}
|
||||
File.Delete(fileName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return bmp;
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
Bitmap oldBitmap = pictureBox2.Image as Bitmap;
|
||||
pictureBox2.Image = GetSnapShot(startMilliseconds);
|
||||
if (oldBitmap != null)
|
||||
oldBitmap.Dispose();
|
||||
startMilliseconds += 100;
|
||||
}
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
NikseBitmap nbmp = new NikseBitmap(pictureBox2.Image as Bitmap);
|
||||
nbmp.MakeOneColorRemoverOthers(Color.Black, 100);
|
||||
pictureBox2.Image = nbmp.GetBitmap();
|
||||
}
|
||||
|
||||
private void button4_Click(object sender, EventArgs e)
|
||||
{
|
||||
NikseBitmap nbmp = new NikseBitmap(pictureBox2.Image as Bitmap);
|
||||
nbmp.MakeOneColorRemoverOthers(Color.White, 50);
|
||||
pictureBox2.Image = nbmp.GetBitmap();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
120
src/Forms/HardSubExtract.resx
Normal file
120
src/Forms/HardSubExtract.resx
Normal 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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -9561,6 +9561,17 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
MakeAutoDuration();
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.Modifiers == (Keys.Control | Keys.Alt | Keys.Shift) && e.KeyCode == Keys.X)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_videoFileName))
|
||||
{
|
||||
e.SuppressKeyPress = true;
|
||||
var form = new HardSubExtract(_videoFileName);
|
||||
if (form.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TABS - MUST BE LAST
|
||||
else if (tabControlButtons.SelectedTab == tabPageAdjust)
|
||||
|
@ -210,8 +210,17 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
string pluginsFolder = Configuration.PluginsDirectory;
|
||||
if (!Directory.Exists(pluginsFolder))
|
||||
Directory.CreateDirectory(pluginsFolder);
|
||||
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(pluginsFolder);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show("Unable to create plugin folder " + pluginsFolder + ": " + exception.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
var ms = new MemoryStream(e.Result);
|
||||
|
||||
ZipExtractor zip = ZipExtractor.Open(ms);
|
||||
@ -256,8 +265,17 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
string pluginsFolder = Configuration.PluginsDirectory;
|
||||
if (!Directory.Exists(pluginsFolder))
|
||||
Directory.CreateDirectory(pluginsFolder);
|
||||
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(pluginsFolder);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show("Unable to create plugin folder " + pluginsFolder + ": " + exception.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
System.Diagnostics.Process.Start(pluginsFolder);
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,41 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeOneColorRemoverOthers(Color c, int maxDif)
|
||||
{
|
||||
byte[] buffer = new byte[4];
|
||||
buffer[0] = c.B;
|
||||
buffer[1] = c.G;
|
||||
buffer[2] = c.R;
|
||||
buffer[3] = c.A;
|
||||
|
||||
byte[] bufferTransparent = new byte[4];
|
||||
bufferTransparent[0] = 0;
|
||||
bufferTransparent[1] = 0;
|
||||
bufferTransparent[2] = 0;
|
||||
bufferTransparent[3] = 0;
|
||||
for (int i = 0; i < _bitmapData.Length; i += 4)
|
||||
{
|
||||
if (_bitmapData[i+3] > 20)
|
||||
{
|
||||
if (Math.Abs(buffer[0] - _bitmapData[i]) < maxDif &&
|
||||
Math.Abs(buffer[1] - _bitmapData[i + 1]) < maxDif &&
|
||||
Math.Abs(buffer[2] - _bitmapData[i + 2]) < maxDif)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
Buffer.BlockCopy(bufferTransparent, 0, _bitmapData, i, 4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Buffer.BlockCopy(bufferTransparent, 0, _bitmapData, i, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Convert a x-color image to four colors, for e.g. dvd sub pictures.
|
||||
/// Colors CAN be in any order but should not...
|
||||
|
298
src/Logic/SubtitleFormats/FinalCutProTest2Xml.cs
Normal file
298
src/Logic/SubtitleFormats/FinalCutProTest2Xml.cs
Normal file
@ -0,0 +1,298 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
// - Mom, when you were my age what did you want to do?
|
||||
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
public class FinalCutProTest2Xml : SubtitleFormat
|
||||
{
|
||||
public override string Extension
|
||||
{
|
||||
get { return ".xml"; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "Final Cut Pro Test2 Xml"; }
|
||||
}
|
||||
|
||||
public override bool IsTimeBased
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override bool IsMine(List<string> lines, string fileName)
|
||||
{
|
||||
var subtitle = new Subtitle();
|
||||
LoadSubtitle(subtitle, lines, fileName);
|
||||
return subtitle.Paragraphs.Count > 0;
|
||||
}
|
||||
|
||||
public string GetFrameRateAsString()
|
||||
{
|
||||
if (Configuration.Settings.General.CurrentFrameRate < 24)
|
||||
return "24"; // ntsc 23.976
|
||||
if (Configuration.Settings.General.CurrentFrameRate < 25)
|
||||
return "24";
|
||||
if (Configuration.Settings.General.CurrentFrameRate < 29)
|
||||
return "25";
|
||||
if (Configuration.Settings.General.CurrentFrameRate < 29)
|
||||
return "25";
|
||||
if (Configuration.Settings.General.CurrentFrameRate < 30)
|
||||
return "30"; // ntsc 29.97
|
||||
if (Configuration.Settings.General.CurrentFrameRate < 40)
|
||||
return "30";
|
||||
if (Configuration.Settings.General.CurrentFrameRate < 40)
|
||||
return "30";
|
||||
if (Configuration.Settings.General.CurrentFrameRate < 60)
|
||||
return "60"; // ntsc 59.94
|
||||
return "60";
|
||||
}
|
||||
|
||||
public string GetNtsc()
|
||||
{
|
||||
if (Configuration.Settings.General.CurrentFrameRate < 24)
|
||||
return "TRUE"; // ntsc 23.976
|
||||
if (Configuration.Settings.General.CurrentFrameRate < 25)
|
||||
return "FALSE";
|
||||
return "TRUE";
|
||||
//if (Configuration.Settings.General.CurrentFrameRate < 29)
|
||||
// return "FALSE";
|
||||
//if (Configuration.Settings.General.CurrentFrameRate < 29)
|
||||
// return "FALSE";
|
||||
//if (Configuration.Settings.General.CurrentFrameRate < 30)
|
||||
// return "TRUE"; // ntsc 29.97
|
||||
//if (Configuration.Settings.General.CurrentFrameRate < 40)
|
||||
// return "TRUE";
|
||||
//if (Configuration.Settings.General.CurrentFrameRate < 40)
|
||||
// return "TRUE";
|
||||
//if (Configuration.Settings.General.CurrentFrameRate < 60)
|
||||
// return "TRUE"; // ntsc 59.94
|
||||
//return "FALSE";
|
||||
}
|
||||
|
||||
public override string ToText(Subtitle subtitle, string title)
|
||||
{
|
||||
int duration = 0;
|
||||
if (subtitle.Paragraphs.Count > 0)
|
||||
duration = (int)Math.Round(subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalSeconds * Configuration.Settings.General.CurrentFrameRate);
|
||||
string seString = "Subtitle Edit at " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
|
||||
string xmlStructure =
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + Environment.NewLine +
|
||||
"<xmeml version=\"5\">" + Environment.NewLine +
|
||||
" <sequence id=\"" + seString + "\">" + Environment.NewLine +
|
||||
" <uuid>EC466A7D-8B45-4682-9978-D15D630C882E</uuid><updatebehavior>add</updatebehavior><name>" + seString + "</name><duration>" + duration.ToString() + "</duration><rate><ntsc>>" + GetNtsc() + @"</ntsc><timebase>" + GetFrameRateAsString() + @"</timebase></rate><timecode><rate><ntsc>" + GetNtsc() + @"</ntsc><timebase>" + GetFrameRateAsString() + @"</timebase></rate><string>01:00:00:00</string><frame>90000</frame><source>source</source><displayformat>NDF</displayformat></timecode><in>-1</in><out>-1</out><media><video><format><samplecharacteristics><width>1920</width><height>1080</height><anamorphic>FALSE</anamorphic><pixelaspectratio>Square</pixelaspectratio><fielddominance>none</fielddominance><rate><ntsc>FALSE</ntsc><timebase>25</timebase></rate><colordepth>24</colordepth><codec><name>Apple ProRes 422</name><appspecificdata><appname>Final Cut Pro</appname><appmanufacturer>Apple Inc.</appmanufacturer><appversion>7.0</appversion><data><qtcodec><codecname>Apple ProRes 422</codecname><codectypename>Apple ProRes 422 (HQ)</codectypename><codectypecode>apch</codectypecode><codecvendorcode>appl</codecvendorcode><spatialquality>1024</spatialquality><temporalquality>0</temporalquality><keyframerate>0</keyframerate><datarate>0</datarate></qtcodec></data></appspecificdata></codec></samplecharacteristics><appspecificdata><appname>Final Cut Pro</appname><appmanufacturer>Apple Inc.</appmanufacturer><appversion>7.0</appversion><data><fcpimageprocessing><useyuv>TRUE</useyuv><usesuperwhite>FALSE</usesuperwhite><rendermode>Float10BPP</rendermode></fcpimageprocessing></data></appspecificdata></format><track><enabled>TRUE</enabled><locked>FALSE</locked></track>" + Environment.NewLine +
|
||||
" <track></track>" +
|
||||
"</video><audio><format><samplecharacteristics><depth>16</depth><samplerate>48000</samplerate></samplecharacteristics></format><outputs><group><index>1</index><numchannels>2</numchannels><downmix>0</downmix><channel><index>1</index></channel><channel><index>2</index></channel></group></outputs><in>-1</in><out>-1</out><track><enabled>TRUE</enabled><locked>FALSE</locked><outputchannelindex>1</outputchannelindex></track><track><enabled>TRUE</enabled><locked>FALSE</locked><outputchannelindex>2</outputchannelindex></track><track><enabled>TRUE</enabled><locked>FALSE</locked><outputchannelindex>1</outputchannelindex></track><track><enabled>TRUE</enabled><locked>FALSE</locked><outputchannelindex>2</outputchannelindex></track><filter><effect><name>Audio Levels</name><effectid>audiolevels</effectid><effectcategory>audiolevels</effectcategory><effecttype>audiolevels</effecttype><mediatype>audio</mediatype><parameter><name>Level</name><parameterid>level</parameterid><valuemin>0</valuemin><valuemax>3.98109</valuemax><value>1</value></parameter></effect></filter></audio></media></sequence></xmeml>";
|
||||
|
||||
|
||||
string xmlTrackStructure =
|
||||
"<generatoritem id=\"Text\"><name>Text</name><duration>3000</duration><rate><ntsc>FALSE</ntsc><timebase>25</timebase></rate><in>1375</in><out>1486</out><start>1504</start><end>1615</end><anamorphic>FALSE</anamorphic><alphatype>black</alphatype><logginginfo><scene/><shottake/><lognote/><good>FALSE</good></logginginfo><labels><label2/></labels><comments><mastercomment1/><mastercomment2/><mastercomment3/><mastercomment4/></comments><effect><name>Text</name><effectid>Text</effectid><effectcategory>Text</effectcategory><effecttype>generator</effecttype><mediatype>video</mediatype><parameter><parameterid>str</parameterid><name>Text</name><value><i>A finales de los años sesenta, una joven pareja, Guy y Rosemary,</i> </value></parameter><parameter><parameterid>fontname</parameterid><name>Font</name><value>Lucida Grande</value></parameter><parameter><parameterid>fontsize</parameterid><name>Size</name><valuemin>0</valuemin><valuemax>1000</valuemax><value>20</value></parameter><parameter><parameterid>fontstyle</parameterid><name>Style</name><valuemin>1</valuemin><valuemax>4</valuemax><valuelist><valueentry><name>Plain</name><value>1</value></valueentry><valueentry><name>Bold</name><value>2</value></valueentry><valueentry><name>Italic</name><value>3</value></valueentry><valueentry><name>Bold/Italic</name><value>4</value></valueentry></valuelist><value>1</value></parameter><parameter><parameterid>fontalign</parameterid><name>Alignment</name><valuemin>1</valuemin><valuemax>3</valuemax><valuelist><valueentry><name>Left</name><value>1</value></valueentry><valueentry><name>Center</name><value>2</value></valueentry><valueentry><name>Right</name><value>3</value></valueentry></valuelist><value>2</value></parameter><parameter><parameterid>fontcolor</parameterid><name>Font Color</name><value><alpha>255</alpha><red>255</red><green>255</green><blue>255</blue></value></parameter><parameter><parameterid>origin</parameterid><name>Origin</name><value><horiz>0</horiz><vert>0</vert></value></parameter><parameter><parameterid>fonttrack</parameterid><name>Tracking</name><valuemin>-200</valuemin><valuemax>200</valuemax><value>1</value></parameter><parameter><parameterid>leading</parameterid><name>Leading</name><valuemin>-100</valuemin><valuemax>100</valuemax><value>0</value></parameter><parameter><parameterid>aspect</parameterid><name>Aspect</name><valuemin>0.1</valuemin><valuemax>5</valuemax><value>1</value></parameter><parameter><parameterid>autokern</parameterid><name>Auto Kerning</name><value>TRUE</value></parameter><parameter><parameterid>subpixel</parameterid><name>Use Subpixel</name><value>TRUE</value></parameter></effect><filter><effect><name>Basic Motion</name><effectid>basic</effectid><effectcategory>motion</effectcategory><effecttype>motion</effecttype><mediatype>video</mediatype><parameter><parameterid>scale</parameterid><name>Scale</name><valuemin>0</valuemin><valuemax>1000</valuemax><value>100</value></parameter><parameter><parameterid>rotation</parameterid><name>Rotation</name><valuemin>-8640</valuemin><valuemax>8640</valuemax><value>0</value></parameter><parameter><parameterid>center</parameterid><name>Center</name><value><horiz>0.00470958</horiz><vert>0.396648</vert></value></parameter><parameter><parameterid>centerOffset</parameterid><name>Anchor Point</name><value><horiz>0</horiz><vert>0</vert></value></parameter></effect></filter><sourcetrack><mediatype>video</mediatype></sourcetrack><itemhistory><uuid>3506ED18-CB4D-41B8-A760-4D42356E4F32</uuid><uuid>1E6E96FD-94F6-4975-BDFE-7B360E909111</uuid></itemhistory></generatoritem>";
|
||||
|
||||
if (string.IsNullOrEmpty(title))
|
||||
title = "Subtitle Edit subtitle";
|
||||
|
||||
var xml = new XmlDocument();
|
||||
xml.LoadXml(xmlStructure);
|
||||
xml.DocumentElement.SelectSingleNode("sequence").Attributes["id"].Value = title;
|
||||
xml.DocumentElement.SelectSingleNode("sequence/name").InnerText = title;
|
||||
xml.DocumentElement.SelectSingleNode("sequence/uuid").InnerText = Guid.NewGuid().ToString().ToUpper();
|
||||
if (!string.IsNullOrEmpty(subtitle.Header))
|
||||
{
|
||||
var header = new XmlDocument();
|
||||
try
|
||||
{
|
||||
header.LoadXml(subtitle.Header);
|
||||
var node = header.DocumentElement.SelectSingleNode("sequence/uuid");
|
||||
if (node != null)
|
||||
xml.DocumentElement.SelectSingleNode("sequence/uuid").InnerText = node.InnerText;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
XmlNode trackNode = xml.DocumentElement.SelectSingleNode("sequence/media/video/track[2]");
|
||||
|
||||
string newLine = "_____@___";
|
||||
int number = 1;
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
XmlNode generatorItem = xml.CreateElement("generatoritem");
|
||||
string fontStyle = "1"; //1==plain
|
||||
string s = Utilities.RemoveHtmlFontTag(p.Text).Trim();
|
||||
if ((s.StartsWith("<i><b>") && s.EndsWith("</b></i>")) || (s.StartsWith("<b><i>") && s.EndsWith("</i></b>")))
|
||||
fontStyle = "4"; //4==bold/italic
|
||||
else if (s.StartsWith("<i>") && s.EndsWith("</i>"))
|
||||
fontStyle = "3"; //3==italic
|
||||
generatorItem.InnerXml = xmlTrackStructure.Replace("[NUMBER]", number.ToString()).Replace("[FONTSTYLE]", fontStyle);
|
||||
|
||||
double frameRate = Configuration.Settings.General.CurrentFrameRate;
|
||||
XmlNode start = generatorItem.SelectSingleNode("generatoritem/start");
|
||||
start.InnerText = ((int)Math.Round(p.StartTime.TotalSeconds*frameRate)).ToString();
|
||||
|
||||
XmlNode end = generatorItem.SelectSingleNode("generatoritem/end");
|
||||
end.InnerText = ((int)Math.Round(p.EndTime.TotalSeconds * frameRate)).ToString();
|
||||
|
||||
XmlNode text = generatorItem.SelectSingleNode("generatoritem/effect/parameter[parameterid='str']/value");
|
||||
text.InnerText = Utilities.RemoveHtmlTags(p.Text);
|
||||
text.InnerXml = text.InnerXml.Replace(Environment.NewLine, newLine);
|
||||
|
||||
trackNode.AppendChild(generatorItem.SelectSingleNode("generatoritem"));
|
||||
number++;
|
||||
}
|
||||
|
||||
string xmlAsText = ToUtf8XmlString(xml);
|
||||
xmlAsText = xmlAsText.Replace("xmeml[]", "xmeml");
|
||||
xmlAsText = xmlAsText.Replace(newLine, " ");
|
||||
return xmlAsText;
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
_errorCount = 0;
|
||||
var frameRate = Configuration.Settings.General.CurrentFrameRate;
|
||||
|
||||
var sb = new StringBuilder();
|
||||
lines.ForEach(line => sb.AppendLine(line));
|
||||
var xml = new XmlDocument();
|
||||
try
|
||||
{
|
||||
xml.LoadXml(sb.ToString());
|
||||
|
||||
XmlDocument header = new XmlDocument();
|
||||
header.LoadXml(sb.ToString());
|
||||
if (header.SelectSingleNode("sequence/media/video/track") != null)
|
||||
header.RemoveChild(header.SelectSingleNode("sequence/media/video/track"));
|
||||
subtitle.Header = header.OuterXml;
|
||||
|
||||
if (xml.DocumentElement.SelectSingleNode("sequence/rate") != null && xml.DocumentElement.SelectSingleNode("sequence/rate/timebase") != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
frameRate = double.Parse(xml.DocumentElement.SelectSingleNode("sequence/rate/timebase").InnerText);
|
||||
}
|
||||
catch
|
||||
{
|
||||
frameRate = Configuration.Settings.General.CurrentFrameRate;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (XmlNode node in xml.SelectNodes("xmeml/sequence/media/video/track"))
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (XmlNode generatorItemNode in node.SelectNodes("generatoritem"))
|
||||
{
|
||||
XmlNode rate = generatorItemNode.SelectSingleNode("rate");
|
||||
if (rate != null)
|
||||
{
|
||||
XmlNode timebase = rate.SelectSingleNode("timebase");
|
||||
if (timebase != null)
|
||||
frameRate = double.Parse(timebase.InnerText);
|
||||
}
|
||||
|
||||
double startFrame = 0;
|
||||
double endFrame = 0;
|
||||
XmlNode startNode = generatorItemNode.SelectSingleNode("start");
|
||||
if (startNode != null)
|
||||
startFrame = double.Parse(startNode.InnerText);
|
||||
|
||||
XmlNode endNode = generatorItemNode.SelectSingleNode("end");
|
||||
if (endNode != null)
|
||||
endFrame = double.Parse(endNode.InnerText);
|
||||
|
||||
string text = string.Empty;
|
||||
foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='str']"))
|
||||
{
|
||||
XmlNode valueNode = parameterNode.SelectSingleNode("value");
|
||||
if (valueNode != null)
|
||||
text += valueNode.InnerText;
|
||||
}
|
||||
|
||||
bool italic = false;
|
||||
bool bold = false;
|
||||
foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='style']"))
|
||||
{
|
||||
XmlNode valueNode = parameterNode.SelectSingleNode("value");
|
||||
var valueEntries = parameterNode.SelectNodes("valuelist/valueentry");
|
||||
if (valueNode != null)
|
||||
{
|
||||
int no;
|
||||
if (int.TryParse(valueNode.InnerText, out no))
|
||||
{
|
||||
no--;
|
||||
if (no < valueEntries.Count)
|
||||
{
|
||||
var styleNameNode = valueEntries[no].SelectSingleNode("name");
|
||||
if (styleNameNode != null)
|
||||
{
|
||||
string styleName = styleNameNode.InnerText;
|
||||
italic = styleName.ToLower().Trim() == "italic" || styleName.ToLower().Trim() == "bold/italic";
|
||||
bold = styleName.ToLower().Trim() == "bold" || styleName.ToLower().Trim() == "bold/italic";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!bold && !italic)
|
||||
{
|
||||
foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='fontstyle']"))
|
||||
{
|
||||
XmlNode valueNode = parameterNode.SelectSingleNode("value");
|
||||
var valueEntries = parameterNode.SelectNodes("valuelist/valueentry");
|
||||
if (valueNode != null)
|
||||
{
|
||||
int no;
|
||||
if (int.TryParse(valueNode.InnerText, out no))
|
||||
{
|
||||
no--;
|
||||
if (no < valueEntries.Count)
|
||||
{
|
||||
var styleNameNode = valueEntries[no].SelectSingleNode("name");
|
||||
if (styleNameNode != null)
|
||||
{
|
||||
string styleName = styleNameNode.InnerText;
|
||||
italic = styleName.ToLower().Trim() == "italic" || styleName.ToLower().Trim() == "bold/italic";
|
||||
bold = styleName.ToLower().Trim() == "bold" || styleName.ToLower().Trim() == "bold/italic";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (text.Length > 0)
|
||||
{
|
||||
if (!text.Contains(Environment.NewLine))
|
||||
text = text.Replace("\r", Environment.NewLine);
|
||||
if (bold)
|
||||
text = "<b>" + text + "</b>";
|
||||
if (italic)
|
||||
text = "<i>" + text + "</i>";
|
||||
subtitle.Paragraphs.Add(new Paragraph(text, Convert.ToDouble((startFrame / frameRate) * 1000), Convert.ToDouble((endFrame / frameRate) * 1000)));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
_errorCount++;
|
||||
}
|
||||
}
|
||||
subtitle.Renumber(1);
|
||||
}
|
||||
catch
|
||||
{
|
||||
_errorCount = 1;
|
||||
return;
|
||||
}
|
||||
Configuration.Settings.General.CurrentFrameRate = frameRate;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
new FinalCutProXml(),
|
||||
new FinalCutProXXml(),
|
||||
new FinalCutProTestXml(),
|
||||
new FinalCutProTest2Xml(),
|
||||
new FlashXml(),
|
||||
new Footage(),
|
||||
new GpacTtxt(),
|
||||
@ -165,6 +166,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
new UnknownSubtitle49(),
|
||||
new UnknownSubtitle50(),
|
||||
new UnknownSubtitle51(),
|
||||
new UnknownSubtitle52(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
135
src/Logic/SubtitleFormats/UnknownSubtitle52.cs
Normal file
135
src/Logic/SubtitleFormats/UnknownSubtitle52.cs
Normal file
@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
|
||||
public class UnknownSubtitle52 : SubtitleFormat
|
||||
{
|
||||
//#00001 10:00:02.00 10:00:04.13 00:00:02.13 #F CC00000D0 #C
|
||||
static readonly Regex RegexTimeCodes = new Regex(@"^\#\d\d\d\d\d\t\d\d:\d\d:\d\d\.\d\d\t\d\d:\d\d:\d\d\.\d\d\t\d\d:\d\d:\d\d\.\d\d\t.*$", RegexOptions.Compiled);
|
||||
|
||||
public override string Extension
|
||||
{
|
||||
get { return ".txt"; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "Unknown 52"; }
|
||||
}
|
||||
|
||||
public override bool IsTimeBased
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override bool IsMine(List<string> lines, string fileName)
|
||||
{
|
||||
if (lines.Count > 0 && lines[0] != null && lines[0].StartsWith("{\\rtf1"))
|
||||
return false;
|
||||
|
||||
var subtitle = new Subtitle();
|
||||
LoadSubtitle(subtitle, lines, fileName);
|
||||
return subtitle.Paragraphs.Count > _errorCount;
|
||||
}
|
||||
|
||||
public override string ToText(Subtitle subtitle, string title)
|
||||
{
|
||||
string paragraphWriteFormat = "#{0:00000}\t{1}\t{2}\t{3}\t#F\tCC00000D0\t#C " + Environment.NewLine + "{4}";
|
||||
const string timeFormat = "{0:00}:{1:00}:{2:00}.{3:00}";
|
||||
var sb = new StringBuilder();
|
||||
string header = @"FILE_INFO_BEGIN
|
||||
VIDEOFILE:
|
||||
ORIG_TITLE: [TITLE]
|
||||
PGM_TITLE:
|
||||
EP_TITLE: 03
|
||||
PROD:
|
||||
TRANSL: SDI Media
|
||||
CLIENT: FIC-HD
|
||||
COMMENT:
|
||||
TAPE#: TN10179565
|
||||
CRE_DATE:
|
||||
REP_DATE:
|
||||
TR_DATE:
|
||||
PROG_LEN:
|
||||
SOM: 09:59:35:00
|
||||
TRA_FONT:
|
||||
LANG_CO: English
|
||||
LIST_FONT: Arial Unicode MS 450
|
||||
TV_SYS: 625/50
|
||||
TV_FPS: EBU 625/50
|
||||
LINE_LEN: 43.2
|
||||
SW_VER: 2.25";
|
||||
if (subtitle.Header != null && subtitle.Header.Contains("FILE_INFO_BEGIN"))
|
||||
header = subtitle.Header;
|
||||
sb.AppendLine(header);
|
||||
int number = 1;
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
string startTime = string.Format(timeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds));
|
||||
string endTime = string.Format(timeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds));
|
||||
string duration = string.Format(timeFormat, p.Duration.Hours, p.Duration.Minutes, p.Duration.Seconds, MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds));
|
||||
sb.AppendLine(string.Format(paragraphWriteFormat, number, startTime, endTime, duration, Utilities.RemoveHtmlTags(p.Text)));
|
||||
number++;
|
||||
}
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
_errorCount = 0;
|
||||
Paragraph p = null;
|
||||
bool started = false;
|
||||
var header = new StringBuilder();
|
||||
var text = new StringBuilder();
|
||||
foreach (string line in lines)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (RegexTimeCodes.Match(line).Success)
|
||||
{
|
||||
started = true;
|
||||
if (p != null)
|
||||
p.Text = text.ToString().Trim();
|
||||
text = new StringBuilder();
|
||||
string start = line.Substring(7, 11);
|
||||
string end = line.Substring(19, 11);
|
||||
p = new Paragraph(GetTimeCode(start), GetTimeCode(end), string.Empty);
|
||||
subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
else if (!started)
|
||||
{
|
||||
header.AppendLine(line);
|
||||
}
|
||||
else if (p != null && p.Text.Length < 200)
|
||||
{
|
||||
text.AppendLine(line);
|
||||
}
|
||||
else
|
||||
{
|
||||
_errorCount++;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
_errorCount++;
|
||||
}
|
||||
}
|
||||
if (p != null)
|
||||
p.Text = text.ToString().Trim();
|
||||
subtitle.Header = header.ToString();
|
||||
subtitle.RemoveEmptyLines();
|
||||
}
|
||||
|
||||
private static TimeCode GetTimeCode(string timeString)
|
||||
{
|
||||
string[] timeParts = timeString.Split(":,.".ToCharArray());
|
||||
int milliseconds = FramesToMillisecondsMax999(int.Parse(timeParts[3]));
|
||||
var timeCode = new TimeCode(int.Parse(timeParts[0]), int.Parse(timeParts[1]), int.Parse(timeParts[2]), milliseconds);
|
||||
return timeCode;
|
||||
}
|
||||
}
|
||||
}
|
@ -326,6 +326,12 @@
|
||||
<Compile Include="Forms\GetTesseractDictionaries.Designer.cs">
|
||||
<DependentUpon>GetTesseractDictionaries.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\HardSubExtract.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\HardSubExtract.Designer.cs">
|
||||
<DependentUpon>HardSubExtract.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\Interjections.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -788,6 +794,7 @@
|
||||
<Compile Include="Logic\SubtitleFormats\CaraokeXml.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\Cavena890.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\CheetahCaption.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\FinalCutProTest2Xml.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\JsonType4.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\DCinemaSmpte.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\DCSubtitle.cs" />
|
||||
@ -897,6 +904,7 @@
|
||||
<Compile Include="Logic\SubtitleFormats\AbcIViewer.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle50.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle51.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle52.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle6.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle7.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\DigiBeta.cs" />
|
||||
@ -1117,6 +1125,9 @@
|
||||
<EmbeddedResource Include="Forms\GetTesseractDictionaries.resx">
|
||||
<DependentUpon>GetTesseractDictionaries.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\HardSubExtract.resx">
|
||||
<DependentUpon>HardSubExtract.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\Interjections.resx">
|
||||
<DependentUpon>Interjections.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
Loading…
Reference in New Issue
Block a user