Fixed invalid tags in DCinema SMPTE format - thx Wolfgang :)

Added new xml subtitle format


git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@2115 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2013-09-28 07:00:41 +00:00
parent 293782f711
commit 45456c5e4d
10 changed files with 880 additions and 688 deletions

View File

@ -30,200 +30,122 @@
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.numericUpDownFont2Diff = new System.Windows.Forms.NumericUpDown();
this.label5 = new System.Windows.Forms.Label();
this.numericUpDownFont1Diff = new System.Windows.Forms.NumericUpDown();
this.numericUpDownInterval = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.pictureBoxColor2 = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.pictureBoxColor1 = new System.Windows.Forms.PictureBox(); this.labelCustomRgb = new System.Windows.Forms.Label();
this.pictureBoxCustomColor = new System.Windows.Forms.PictureBox();
this.numericUpDownCustomMaxDiff = new System.Windows.Forms.NumericUpDown();
this.checkBoxCustomColor = new System.Windows.Forms.CheckBox();
this.checkBoxYellow = new System.Windows.Forms.CheckBox();
this.numericUpDownPixelsBottom = new System.Windows.Forms.NumericUpDown(); this.numericUpDownPixelsBottom = new System.Windows.Forms.NumericUpDown();
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
this.buttonStart = new System.Windows.Forms.Button();
this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.labelClickOnTextColor = new System.Windows.Forms.Label(); this.labelClickOnTextColor = new System.Windows.Forms.Label();
this.buttonStop = new System.Windows.Forms.Button();
this.openFileDialogVideo = new System.Windows.Forms.OpenFileDialog(); this.openFileDialogVideo = new System.Windows.Forms.OpenFileDialog();
this.buttonCancel = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOK = new System.Windows.Forms.Button(); this.buttonOK = new System.Windows.Forms.Button();
this.buttonShowImg = new System.Windows.Forms.Button();
this.labelStatus = new System.Windows.Forms.Label(); this.labelStatus = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.timerRefreshProgressbar = new System.Windows.Forms.Timer(this.components); this.timerRefreshProgressbar = new System.Windows.Forms.Timer(this.components);
this.label8 = new System.Windows.Forms.Label();
this.tbBlacks = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.tbFrameNum = new System.Windows.Forms.TextBox();
this.tbFileName = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.StartStop = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.colorDialog1 = new System.Windows.Forms.ColorDialog();
this.buttonStop = new System.Windows.Forms.Button();
this.mediaPlayer = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); this.mediaPlayer = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer();
this.button2 = new System.Windows.Forms.Button(); this.contextMenuStripScreenshot = new System.Windows.Forms.ContextMenuStrip(this.components);
this.saveImageAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownFont2Diff)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCustomColor)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownFont1Diff)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCustomMaxDiff)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownInterval)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxColor2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxColor1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsBottom)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsBottom)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.contextMenuStripScreenshot.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// groupBox1 // groupBox1
// //
this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.numericUpDownFont2Diff);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.numericUpDownFont1Diff);
this.groupBox1.Controls.Add(this.numericUpDownInterval);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.pictureBoxColor2);
this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.pictureBoxColor1); this.groupBox1.Controls.Add(this.labelCustomRgb);
this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Controls.Add(this.pictureBoxCustomColor);
this.groupBox1.Controls.Add(this.numericUpDownCustomMaxDiff);
this.groupBox1.Controls.Add(this.checkBoxCustomColor);
this.groupBox1.Controls.Add(this.checkBoxYellow);
this.groupBox1.Location = new System.Drawing.Point(12, 85);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(341, 225); this.groupBox1.Size = new System.Drawing.Size(341, 117);
this.groupBox1.TabIndex = 0; this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "Detection options"; this.groupBox1.Text = "Detection options";
// //
// button1
//
this.button1.Location = new System.Drawing.Point(183, 182);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 28;
this.button1.Text = "Test";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(13, 27);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(112, 13);
this.label7.TabIndex = 25;
this.label7.Text = "Hardcoded font colors";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(205, 89);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(86, 13);
this.label6.TabIndex = 24;
this.label6.Text = "color diff allowed";
//
// numericUpDownFont2Diff
//
this.numericUpDownFont2Diff.Location = new System.Drawing.Point(133, 87);
this.numericUpDownFont2Diff.Maximum = new decimal(new int[] {
40,
0,
0,
0});
this.numericUpDownFont2Diff.Name = "numericUpDownFont2Diff";
this.numericUpDownFont2Diff.Size = new System.Drawing.Size(66, 20);
this.numericUpDownFont2Diff.TabIndex = 23;
this.numericUpDownFont2Diff.Value = new decimal(new int[] {
15,
0,
0,
0});
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(205, 60);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(86, 13);
this.label5.TabIndex = 22;
this.label5.Text = "color diff allowed";
//
// numericUpDownFont1Diff
//
this.numericUpDownFont1Diff.Location = new System.Drawing.Point(133, 58);
this.numericUpDownFont1Diff.Maximum = new decimal(new int[] {
40,
0,
0,
0});
this.numericUpDownFont1Diff.Name = "numericUpDownFont1Diff";
this.numericUpDownFont1Diff.Size = new System.Drawing.Size(66, 20);
this.numericUpDownFont1Diff.TabIndex = 21;
this.numericUpDownFont1Diff.Value = new decimal(new int[] {
15,
0,
0,
0});
//
// numericUpDownInterval
//
this.numericUpDownInterval.Location = new System.Drawing.Point(16, 182);
this.numericUpDownInterval.Maximum = new decimal(new int[] {
2000,
0,
0,
0});
this.numericUpDownInterval.Name = "numericUpDownInterval";
this.numericUpDownInterval.Size = new System.Drawing.Size(59, 20);
this.numericUpDownInterval.TabIndex = 20;
this.numericUpDownInterval.Value = new decimal(new int[] {
200,
0,
0,
0});
//
// 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";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(43, 89);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(60, 13);
this.label2.TabIndex = 11;
this.label2.Text = "Font color2";
//
// pictureBoxColor2
//
this.pictureBoxColor2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxColor2.Location = new System.Drawing.Point(16, 84);
this.pictureBoxColor2.Name = "pictureBoxColor2";
this.pictureBoxColor2.Size = new System.Drawing.Size(21, 21);
this.pictureBoxColor2.TabIndex = 10;
this.pictureBoxColor2.TabStop = false;
this.pictureBoxColor2.Click += new System.EventHandler(this.pictureBoxColor2_Click);
//
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(9, 80);
this.label1.Location = new System.Drawing.Point(43, 60);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(60, 13); this.label1.Size = new System.Drawing.Size(101, 16);
this.label1.TabIndex = 9; this.label1.TabIndex = 31;
this.label1.Text = "Font color1"; this.label1.Text = "Allow diff per RGB";
// //
// pictureBoxColor1 // labelCustomRgb
// //
this.pictureBoxColor1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.labelCustomRgb.AutoSize = true;
this.pictureBoxColor1.Location = new System.Drawing.Point(16, 52); this.labelCustomRgb.Location = new System.Drawing.Point(177, 56);
this.pictureBoxColor1.Name = "pictureBoxColor1"; this.labelCustomRgb.Name = "labelCustomRgb";
this.pictureBoxColor1.Size = new System.Drawing.Size(21, 21); this.labelCustomRgb.Size = new System.Drawing.Size(30, 13);
this.pictureBoxColor1.TabIndex = 8; this.labelCustomRgb.TabIndex = 37;
this.pictureBoxColor1.TabStop = false; this.labelCustomRgb.Text = "RGB";
this.pictureBoxColor1.Click += new System.EventHandler(this.pictureBoxBackground_Click); //
// pictureBoxCustomColor
//
this.pictureBoxCustomColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxCustomColor.Location = new System.Drawing.Point(152, 53);
this.pictureBoxCustomColor.Name = "pictureBoxCustomColor";
this.pictureBoxCustomColor.Size = new System.Drawing.Size(21, 21);
this.pictureBoxCustomColor.TabIndex = 8;
this.pictureBoxCustomColor.TabStop = false;
this.pictureBoxCustomColor.Click += new System.EventHandler(this.pictureBoxCustomColor_Click);
//
// numericUpDownCustomMaxDiff
//
this.numericUpDownCustomMaxDiff.Location = new System.Drawing.Point(116, 76);
this.numericUpDownCustomMaxDiff.Name = "numericUpDownCustomMaxDiff";
this.numericUpDownCustomMaxDiff.Size = new System.Drawing.Size(38, 20);
this.numericUpDownCustomMaxDiff.TabIndex = 2;
this.numericUpDownCustomMaxDiff.Value = new decimal(new int[] {
14,
0,
0,
0});
//
// checkBoxCustomColor
//
this.checkBoxCustomColor.AutoSize = true;
this.checkBoxCustomColor.Location = new System.Drawing.Point(11, 55);
this.checkBoxCustomColor.Name = "checkBoxCustomColor";
this.checkBoxCustomColor.Size = new System.Drawing.Size(135, 17);
this.checkBoxCustomColor.TabIndex = 1;
this.checkBoxCustomColor.Text = "Check for custom color";
this.checkBoxCustomColor.UseVisualStyleBackColor = true;
//
// checkBoxYellow
//
this.checkBoxYellow.AutoSize = true;
this.checkBoxYellow.Checked = true;
this.checkBoxYellow.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxYellow.Location = new System.Drawing.Point(9, 19);
this.checkBoxYellow.Name = "checkBoxYellow";
this.checkBoxYellow.Size = new System.Drawing.Size(124, 17);
this.checkBoxYellow.TabIndex = 0;
this.checkBoxYellow.Text = "Check for yellow text";
this.checkBoxYellow.UseVisualStyleBackColor = true;
// //
// numericUpDownPixelsBottom // numericUpDownPixelsBottom
// //
@ -237,7 +159,7 @@
this.numericUpDownPixelsBottom.Size = new System.Drawing.Size(66, 20); this.numericUpDownPixelsBottom.Size = new System.Drawing.Size(66, 20);
this.numericUpDownPixelsBottom.TabIndex = 19; this.numericUpDownPixelsBottom.TabIndex = 19;
this.numericUpDownPixelsBottom.Value = new decimal(new int[] { this.numericUpDownPixelsBottom.Value = new decimal(new int[] {
100, 127,
0, 0,
0, 0,
0}); 0});
@ -252,24 +174,16 @@
this.label4.TabIndex = 18; this.label4.TabIndex = 18;
this.label4.Text = "Search number of pixels from bottom"; this.label4.Text = "Search number of pixels from bottom";
// //
// buttonStart
//
this.buttonStart.Location = new System.Drawing.Point(12, 243);
this.buttonStart.Name = "buttonStart";
this.buttonStart.Size = new System.Drawing.Size(118, 23);
this.buttonStart.TabIndex = 1;
this.buttonStart.Text = "Start detect";
this.buttonStart.UseVisualStyleBackColor = true;
this.buttonStart.Click += new System.EventHandler(this.buttonStartClick);
//
// pictureBox2 // pictureBox2
// //
this.pictureBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 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.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.pictureBox2.ContextMenuStrip = this.contextMenuStripScreenshot;
this.pictureBox2.Cursor = System.Windows.Forms.Cursors.Cross;
this.pictureBox2.Location = new System.Drawing.Point(11, 37); this.pictureBox2.Location = new System.Drawing.Point(11, 37);
this.pictureBox2.Name = "pictureBox2"; this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(867, 373); this.pictureBox2.Size = new System.Drawing.Size(843, 373);
this.pictureBox2.TabIndex = 4; this.pictureBox2.TabIndex = 4;
this.pictureBox2.TabStop = false; this.pictureBox2.TabStop = false;
this.pictureBox2.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox2_Paint); this.pictureBox2.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox2_Paint);
@ -286,21 +200,11 @@
this.labelClickOnTextColor.TabIndex = 19; this.labelClickOnTextColor.TabIndex = 19;
this.labelClickOnTextColor.Text = "Click on text color"; this.labelClickOnTextColor.Text = "Click on text color";
// //
// buttonStop
//
this.buttonStop.Location = new System.Drawing.Point(136, 243);
this.buttonStop.Name = "buttonStop";
this.buttonStop.Size = new System.Drawing.Size(75, 23);
this.buttonStop.TabIndex = 21;
this.buttonStop.Text = "Stop";
this.buttonStop.UseVisualStyleBackColor = true;
this.buttonStop.Click += new System.EventHandler(this.buttonStop_Click);
//
// buttonCancel // buttonCancel
// //
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(821, 695); this.buttonCancel.Location = new System.Drawing.Point(797, 695);
this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 21); this.buttonCancel.Size = new System.Drawing.Size(75, 21);
this.buttonCancel.TabIndex = 25; this.buttonCancel.TabIndex = 25;
@ -312,7 +216,7 @@
// //
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(740, 695); this.buttonOK.Location = new System.Drawing.Point(716, 695);
this.buttonOK.Name = "buttonOK"; this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 21); this.buttonOK.Size = new System.Drawing.Size(75, 21);
this.buttonOK.TabIndex = 24; this.buttonOK.TabIndex = 24;
@ -320,16 +224,6 @@
this.buttonOK.UseVisualStyleBackColor = true; this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
// //
// buttonShowImg
//
this.buttonShowImg.Location = new System.Drawing.Point(235, 243);
this.buttonShowImg.Name = "buttonShowImg";
this.buttonShowImg.Size = new System.Drawing.Size(118, 23);
this.buttonShowImg.TabIndex = 26;
this.buttonShowImg.Text = "Update subtitle area";
this.buttonShowImg.UseVisualStyleBackColor = true;
this.buttonShowImg.Click += new System.EventHandler(this.buttonShowImg_Click);
//
// labelStatus // labelStatus
// //
this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@ -345,21 +239,108 @@
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Controls.Add(this.button1);
this.groupBox2.Controls.Add(this.pictureBox2);
this.groupBox2.Controls.Add(this.numericUpDownPixelsBottom); this.groupBox2.Controls.Add(this.numericUpDownPixelsBottom);
this.groupBox2.Controls.Add(this.label4); this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.labelClickOnTextColor); this.groupBox2.Controls.Add(this.labelClickOnTextColor);
this.groupBox2.Controls.Add(this.pictureBox2);
this.groupBox2.Location = new System.Drawing.Point(12, 273); this.groupBox2.Location = new System.Drawing.Point(12, 273);
this.groupBox2.Name = "groupBox2"; this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(884, 416); this.groupBox2.Size = new System.Drawing.Size(860, 416);
this.groupBox2.TabIndex = 27; this.groupBox2.TabIndex = 27;
this.groupBox2.TabStop = false; this.groupBox2.TabStop = false;
this.groupBox2.Text = "Subtitle area (red rectangle)"; this.groupBox2.Text = "Subtitle area (red rectangle)";
// //
// button1
//
this.button1.Location = new System.Drawing.Point(357, 11);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(246, 26);
this.button1.TabIndex = 37;
this.button1.Text = "Take screenshot from video player";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// timerRefreshProgressbar // timerRefreshProgressbar
// //
this.timerRefreshProgressbar.Tick += new System.EventHandler(this.TimerRefreshProgressbarTick); this.timerRefreshProgressbar.Tick += new System.EventHandler(this.TimerRefreshProgressbarTick);
// //
// label8
//
this.label8.Location = new System.Drawing.Point(125, 236);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(96, 23);
this.label8.TabIndex = 34;
this.label8.Text = "# of subtitles";
//
// tbBlacks
//
this.tbBlacks.Location = new System.Drawing.Point(229, 236);
this.tbBlacks.Name = "tbBlacks";
this.tbBlacks.ReadOnly = true;
this.tbBlacks.Size = new System.Drawing.Size(48, 20);
this.tbBlacks.TabIndex = 33;
//
// label9
//
this.label9.Location = new System.Drawing.Point(125, 209);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(100, 23);
this.label9.TabIndex = 32;
this.label9.Text = "Scanning Frame #";
//
// tbFrameNum
//
this.tbFrameNum.Location = new System.Drawing.Point(229, 209);
this.tbFrameNum.Name = "tbFrameNum";
this.tbFrameNum.ReadOnly = true;
this.tbFrameNum.Size = new System.Drawing.Size(48, 20);
this.tbFrameNum.TabIndex = 31;
//
// tbFileName
//
this.tbFileName.Location = new System.Drawing.Point(6, 35);
this.tbFileName.Name = "tbFileName";
this.tbFileName.Size = new System.Drawing.Size(285, 20);
this.tbFileName.TabIndex = 30;
this.tbFileName.Text = "c:\\foo.mpg";
//
// label10
//
this.label10.Location = new System.Drawing.Point(6, 16);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(72, 16);
this.label10.TabIndex = 29;
this.label10.Text = "Source file";
//
// StartStop
//
this.StartStop.Location = new System.Drawing.Point(16, 209);
this.StartStop.Name = "StartStop";
this.StartStop.Size = new System.Drawing.Size(75, 26);
this.StartStop.TabIndex = 28;
this.StartStop.Text = "Start";
this.StartStop.Click += new System.EventHandler(this.StartStop_Click);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.label10);
this.groupBox3.Controls.Add(this.tbFileName);
this.groupBox3.Location = new System.Drawing.Point(12, 12);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(341, 67);
this.groupBox3.TabIndex = 35;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Input";
//
// buttonStop
//
this.buttonStop.Location = new System.Drawing.Point(18, 240);
this.buttonStop.Name = "buttonStop";
this.buttonStop.Size = new System.Drawing.Size(75, 26);
this.buttonStop.TabIndex = 36;
this.buttonStop.Text = "Stop";
this.buttonStop.Click += new System.EventHandler(this.buttonStop_Click);
//
// mediaPlayer // mediaPlayer
// //
this.mediaPlayer.AllowDrop = true; this.mediaPlayer.AllowDrop = true;
@ -374,7 +355,7 @@
this.mediaPlayer.ShowFullscreenButton = true; this.mediaPlayer.ShowFullscreenButton = true;
this.mediaPlayer.ShowMuteButton = true; this.mediaPlayer.ShowMuteButton = true;
this.mediaPlayer.ShowStopButton = true; this.mediaPlayer.ShowStopButton = true;
this.mediaPlayer.Size = new System.Drawing.Size(527, 247); this.mediaPlayer.Size = new System.Drawing.Size(503, 247);
this.mediaPlayer.SubtitleText = ""; this.mediaPlayer.SubtitleText = "";
this.mediaPlayer.TabIndex = 23; this.mediaPlayer.TabIndex = 23;
this.mediaPlayer.TextRightToLeft = System.Windows.Forms.RightToLeft.No; this.mediaPlayer.TextRightToLeft = System.Windows.Forms.RightToLeft.No;
@ -383,28 +364,36 @@
this.mediaPlayer.VideoWidth = 0; this.mediaPlayer.VideoWidth = 0;
this.mediaPlayer.Volume = 0D; this.mediaPlayer.Volume = 0D;
// //
// button2 // contextMenuStripScreenshot
// //
this.button2.Location = new System.Drawing.Point(264, 182); this.contextMenuStripScreenshot.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.button2.Name = "button2"; this.saveImageAsToolStripMenuItem});
this.button2.Size = new System.Drawing.Size(75, 23); this.contextMenuStripScreenshot.Name = "contextMenuStripScreenshot";
this.button2.TabIndex = 29; this.contextMenuStripScreenshot.Size = new System.Drawing.Size(158, 26);
this.button2.Text = "Test"; //
this.button2.UseVisualStyleBackColor = true; // saveImageAsToolStripMenuItem
this.button2.Click += new System.EventHandler(this.button2_Click); //
this.saveImageAsToolStripMenuItem.Name = "saveImageAsToolStripMenuItem";
this.saveImageAsToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.saveImageAsToolStripMenuItem.Text = "Save image as...";
this.saveImageAsToolStripMenuItem.Click += new System.EventHandler(this.saveImageAsToolStripMenuItem_Click);
// //
// HardSubExtract // HardSubExtract
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(908, 728); this.ClientSize = new System.Drawing.Size(884, 728);
this.Controls.Add(this.buttonStop);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.label8);
this.Controls.Add(this.StartStop);
this.Controls.Add(this.tbBlacks);
this.Controls.Add(this.label9);
this.Controls.Add(this.tbFrameNum);
this.Controls.Add(this.labelStatus); this.Controls.Add(this.labelStatus);
this.Controls.Add(this.buttonShowImg);
this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK); this.Controls.Add(this.buttonOK);
this.Controls.Add(this.mediaPlayer); this.Controls.Add(this.mediaPlayer);
this.Controls.Add(this.buttonStop);
this.Controls.Add(this.buttonStart);
this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox2);
this.KeyPreview = true; this.KeyPreview = true;
@ -414,19 +403,18 @@
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Import/OCR burned-in subtitles from video file"; this.Text = "Import/OCR burned-in subtitles from video file";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HardSubExtract_FormClosing);
this.Shown += new System.EventHandler(this.HardSubExtract_Shown); this.Shown += new System.EventHandler(this.HardSubExtract_Shown);
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout(); this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownFont2Diff)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCustomColor)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownFont1Diff)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCustomMaxDiff)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownInterval)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxColor2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxColor1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsBottom)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsBottom)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
this.groupBox2.ResumeLayout(false); this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout(); this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.contextMenuStripScreenshot.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -435,32 +423,36 @@
#endregion #endregion
private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.PictureBox pictureBoxColor2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.PictureBox pictureBoxColor1;
private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button buttonStart;
private System.Windows.Forms.PictureBox pictureBox2; private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.Label labelClickOnTextColor; private System.Windows.Forms.Label labelClickOnTextColor;
private System.Windows.Forms.NumericUpDown numericUpDownPixelsBottom; private System.Windows.Forms.NumericUpDown numericUpDownPixelsBottom;
private System.Windows.Forms.NumericUpDown numericUpDownInterval;
private System.Windows.Forms.Button buttonStop;
private Controls.VideoPlayerContainer mediaPlayer; private Controls.VideoPlayerContainer mediaPlayer;
private System.Windows.Forms.OpenFileDialog openFileDialogVideo; private System.Windows.Forms.OpenFileDialog openFileDialogVideo;
private System.Windows.Forms.Button buttonCancel; private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOK; private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.Button buttonShowImg;
private System.Windows.Forms.Label labelStatus; private System.Windows.Forms.Label labelStatus;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.NumericUpDown numericUpDownFont1Diff;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.NumericUpDown numericUpDownFont2Diff;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Timer timerRefreshProgressbar; private System.Windows.Forms.Timer timerRefreshProgressbar;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox tbBlacks;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox tbFrameNum;
private System.Windows.Forms.TextBox tbFileName;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Button StartStop;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.CheckBox checkBoxCustomColor;
private System.Windows.Forms.CheckBox checkBoxYellow;
private System.Windows.Forms.NumericUpDown numericUpDownCustomMaxDiff;
private System.Windows.Forms.PictureBox pictureBoxCustomColor;
private System.Windows.Forms.ColorDialog colorDialog1;
private System.Windows.Forms.Button buttonStop;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Label labelCustomRgb;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ContextMenuStrip contextMenuStripScreenshot;
private System.Windows.Forms.ToolStripMenuItem saveImageAsToolStripMenuItem;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
} }
} }

View File

@ -6,97 +6,24 @@ using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.VideoPlayers; using Nikse.SubtitleEdit.Logic.VideoPlayers;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Collections.Generic; using System.Collections.Generic;
//using Nikse.SubtitleEdit.Logic.DirectShow.Custom;
using Nikse.SubtitleEdit.Logic.SubtitleFormats;
namespace Nikse.SubtitleEdit.Forms namespace Nikse.SubtitleEdit.Forms
{ {
public partial class HardSubExtract : Form public partial class HardSubExtract : Form
{ {
// HardExtractCapture cam = null;
public class MyFrameBuffer
{
int size; // = 640 * 480 * 3 * 10; // 921600
public MyFrameBuffer(int bufferSize)
{
size = bufferSize;
}
IntPtr myMemory = IntPtr.Zero;
public IntPtr AllocateUnmanaged()
{
if (myMemory == IntPtr.Zero)
myMemory = Marshal.AllocHGlobal(size);
return myMemory;
}
public void FreeUnmanaged()
{
if (myMemory != IntPtr.Zero)
System.Runtime.InteropServices.Marshal.FreeHGlobal(myMemory);
}
public byte[] GetSafeCopy()
{
byte[] safeCopy = new byte[size];
Marshal.Copy(myMemory, safeCopy, 0, size);
return safeCopy;
}
}
public class CallbackContext
{
public MyFrameBuffer framebuf;
public System.Threading.Mutex mutex;
public CallbackContext(int size)
{
framebuf = new MyFrameBuffer(size);
mutex = new System.Threading.Mutex();
}
}
private string _videoFileName; private string _videoFileName;
private LibVlc11xDynamic _libVlc; private LibVlc11xDynamic _libVlc;
private VideoInfo _videoInfo; private VideoInfo _videoInfo;
private string _folderName;
long startMilliseconds = 0; long startMilliseconds = 0;
int colorChooser = -1;
Subtitle _subtitle; Subtitle _subtitle;
public Subtitle SubtitleFromOcr; public Subtitle SubtitleFromOcr;
NikseBitmap _lastImage; private System.Windows.Forms.Timer timer1;
double _lastImagePixelPercent;
bool _abort = false;
int frameCount = 1;
// private bool _done;
List<long> sceneChangeFrames = new List<long>();
// Callback instances
private Nikse.SubtitleEdit.Logic.VideoPlayers.LibVlc11xDynamic.LockCallbackDelegate m_cb_lock;// = new Core.Interops.Signatures.LibVlc.MediaPlayer.Video.LockCallbackDelegate(CB_Lock);
private Nikse.SubtitleEdit.Logic.VideoPlayers.LibVlc11xDynamic.UnlockCallbackDelegate m_cb_unlock;// = new Core.Interops.Signatures.LibVlc.MediaPlayer.Video.UnlockCallbackDelegate(CB_Unlock);
private Nikse.SubtitleEdit.Logic.VideoPlayers.LibVlc11xDynamic.DisplayCallbackDelegate m_cb_display;// = new Core.Interops.Signatures.LibVlc.MediaPlayer.Video.DisplayCallbackDelegate(CB_Display);
// Context ("opaque")
private CallbackContext m_cb_ctx;
// frame counter
private long frameCounter = 0;
int currentBestDiff = 0;
int maxDiffARGB = 25;
private const int lineChecksWidth = 50; private const int lineChecksWidth = 50;
private const int lineChecksHeight = 25; private const int lineChecksHeight = 25;
int maxDiffPixels = lineChecksWidth * lineChecksHeight / 4; public string OcrFileName = null;
double factorWidth;
double factorHeight;
public HardSubExtract(string videoFileName) public HardSubExtract(string videoFileName)
{ {
@ -105,16 +32,17 @@ namespace Nikse.SubtitleEdit.Forms
labelClickOnTextColor.Visible = false; labelClickOnTextColor.Visible = false;
SubtitleFromOcr = new Subtitle(); SubtitleFromOcr = new Subtitle();
labelStatus.Text = string.Empty; labelStatus.Text = string.Empty;
tbFileName.Text = videoFileName;
pictureBoxCustomColor.BackColor = Color.FromArgb(233, 233, 233);
SetCustumRGB();
} }
private void HardSubExtract_Shown(object sender, EventArgs e) private void HardSubExtract_Shown(object sender, EventArgs e)
{ {
_folderName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
System.IO.Directory.CreateDirectory(_folderName);
if (openFileDialogVideo.ShowDialog(this) == DialogResult.OK) if (openFileDialogVideo.ShowDialog(this) == DialogResult.OK)
{ {
_videoFileName = openFileDialogVideo.FileName; _videoFileName = openFileDialogVideo.FileName;
tbFileName.Text = openFileDialogVideo.FileName;
_videoInfo = Utilities.GetVideoInfo(_videoFileName, null); _videoInfo = Utilities.GetVideoInfo(_videoFileName, null);
var oldPlayer = Configuration.Settings.General.VideoPlayer; var oldPlayer = Configuration.Settings.General.VideoPlayer;
Configuration.Settings.General.VideoPlayer = "VLC"; Configuration.Settings.General.VideoPlayer = "VLC";
@ -122,8 +50,6 @@ namespace Nikse.SubtitleEdit.Forms
Configuration.Settings.General.VideoPlayer = oldPlayer; Configuration.Settings.General.VideoPlayer = oldPlayer;
_libVlc = mediaPlayer.VideoPlayer as LibVlc11xDynamic; _libVlc = mediaPlayer.VideoPlayer as LibVlc11xDynamic;
pictureBoxColor1.BackColor = Color.FromArgb(253, 253, 253);
pictureBoxColor2.BackColor = Color.FromArgb(250, 250, 250);
_subtitle = new Subtitle(); _subtitle = new Subtitle();
} }
else else
@ -136,45 +62,44 @@ namespace Nikse.SubtitleEdit.Forms
{ {
mediaPlayer.Stop(); mediaPlayer.Stop();
mediaPlayer.Volume = Configuration.Settings.General.VideoPlayerDefaultVolume; mediaPlayer.Volume = Configuration.Settings.General.VideoPlayerDefaultVolume;
pictureBox2.Image = GetSnapShot(startMilliseconds); // pictureBox2.Image = GetSnapShot(startMilliseconds);
mediaPlayer.Pause(); mediaPlayer.Pause();
timerRefreshProgressbar.Start(); timerRefreshProgressbar.Start();
pictureBox2.Refresh();
} }
private Bitmap GetSnapShot(long milliseconds) //private Bitmap GetSnapShot(long milliseconds)
{ //{
string fileName = Path.Combine(_folderName, Guid.NewGuid().ToString() + ".png"); // string fileName = Path.Combine(_folderName, Guid.NewGuid().ToString() + ".png");
_libVlc.CurrentPosition = milliseconds / 1000.0; // _libVlc.CurrentPosition = milliseconds / 1000.0;
_libVlc.TakeSnapshot(fileName, (uint)_videoInfo.Width, (uint)_videoInfo.Height); // _libVlc.TakeSnapshot(fileName, (uint)_videoInfo.Width, (uint)_videoInfo.Height);
int i=0; // int i=0;
while (i < 100 && !File.Exists(fileName)) // while (i < 100 && !File.Exists(fileName))
{ // {
System.Threading.Thread.Sleep(5); // System.Threading.Thread.Sleep(5);
Application.DoEvents(); // Application.DoEvents();
i++; // i++;
} // }
System.Threading.Thread.Sleep(5); // System.Threading.Thread.Sleep(5);
Application.DoEvents(); // Application.DoEvents();
Bitmap bmp = null; // Bitmap bmp = null;
try // try
{ // {
using (var ms = new MemoryStream(File.ReadAllBytes(fileName))) // using (var ms = new MemoryStream(File.ReadAllBytes(fileName)))
{ // {
bmp = ((Bitmap)Bitmap.FromStream(ms)); // avoid locking file // ms.Position = 0;
} // bmp = ((Bitmap)Bitmap.FromStream(ms)); // avoid locking file
File.Delete(fileName); // }
} // File.Delete(fileName);
catch // }
{ // catch
} // {
return bmp; // }
} // return bmp;
//}
private void pictureBoxBackground_Click(object sender, EventArgs e) private void pictureBoxBackground_Click(object sender, EventArgs e)
{ {
MessageBox.Show("Click on screenshot to get color 1");
labelClickOnTextColor.Visible = true;
colorChooser = 1;
} }
private void pictureBox2_MouseClick(object sender, MouseEventArgs e) private void pictureBox2_MouseClick(object sender, MouseEventArgs e)
@ -184,27 +109,12 @@ namespace Nikse.SubtitleEdit.Forms
Bitmap bmp = pictureBox2.Image as Bitmap; Bitmap bmp = pictureBox2.Image as Bitmap;
if (bmp != null) if (bmp != null)
{ {
if (colorChooser == 1) pictureBoxCustomColor.BackColor = bmp.GetPixel(e.X, e.Y);
{ SetCustumRGB();
pictureBoxColor1.BackColor = bmp.GetPixel(e.X, e.Y);
}
else if (colorChooser == 2)
{
pictureBoxColor2.BackColor = bmp.GetPixel(e.X, e.Y);
}
labelClickOnTextColor.Visible = false;
colorChooser = -1;
} }
} }
} }
private void pictureBoxColor2_Click(object sender, EventArgs e)
{
MessageBox.Show("Click on screenshot to get color 2");
labelClickOnTextColor.Visible = true;
colorChooser = 2;
}
private void pictureBox2_Paint(object sender, PaintEventArgs e) private void pictureBox2_Paint(object sender, PaintEventArgs e)
{ {
Bitmap bmp = pictureBox2.Image as Bitmap; Bitmap bmp = pictureBox2.Image as Bitmap;
@ -219,130 +129,6 @@ namespace Nikse.SubtitleEdit.Forms
} }
} }
static public Bitmap CopyBitmapSection(Bitmap srcBitmap, Rectangle section)
{
Bitmap bmp = new Bitmap(section.Width, section.Height);
Graphics g = Graphics.FromImage(bmp);
g.DrawImage(srcBitmap, 0, 0, section, GraphicsUnit.Pixel);
g.Dispose();
return bmp;
}
private void GetText(Bitmap bmp)
{
if (bmp == null)
return;
if (numericUpDownPixelsBottom.Value < bmp.Height)
{
int h = Convert.ToInt32(numericUpDownPixelsBottom.Value);
bmp = CopyBitmapSection(bmp, new Rectangle(0, bmp.Height - h, bmp.Width, h));
}
NikseBitmap nbmp = new NikseBitmap(bmp);
int diff = Convert.ToInt32(numericUpDownFont1Diff.Value);
int count = nbmp.MakeOneColorRemoverOthers(pictureBoxColor1.BackColor, pictureBoxColor2.BackColor, diff);
// int count = nbmp.RemoveAloneColors(); // remove noise
double percent = count * 100.0 / (nbmp.Width * nbmp.Height);
if (count > 10 && percent > 0.1)
{
nbmp.CropTransparentSidesAndBottom(2, true);
nbmp.CropSidesAndBottom(2, Color.Transparent, true);
bool isSameImage = false;
if (_lastImage != null && Math.Abs(_lastImagePixelPercent - percent) < 0.3)
{
Paragraph p = _subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1];
p.EndTime.TotalMilliseconds = startMilliseconds + 100;
isSameImage = true;
}
if (!isSameImage)
{
string name = Path.Combine(_folderName, _subtitle.Paragraphs.Count.ToString() + ".png");
Bitmap newBitmap = nbmp.GetBitmap();
newBitmap.Save(name, System.Drawing.Imaging.ImageFormat.Png);
newBitmap.Dispose();
_subtitle.Paragraphs.Add(new Paragraph(name, startMilliseconds, startMilliseconds + 100));
labelStatus.Text = string.Format("{0} possible subtitles found", _subtitle.Paragraphs.Count);
}
_lastImage = nbmp;
_lastImagePixelPercent = percent;
}
else
{
_lastImage = null;
}
}
private void buttonStartClick(object sender, EventArgs e)
{
_lastImage = null;
_abort = false;
var durationInMilliseconds = _libVlc.Duration * 1000.0;
startMilliseconds = Convert.ToInt64(_libVlc.CurrentPosition * 1000.0);
buttonOK.Enabled = false;
buttonCancel.Enabled = false;
_subtitle.Paragraphs.Clear();
while (!_abort && startMilliseconds < durationInMilliseconds)
{
Bitmap bmp = GetSnapShot(startMilliseconds);
if (bmp != null)
{
GetText(bmp);
bmp.Dispose();
}
startMilliseconds += Convert.ToInt32(numericUpDownInterval.Value);
}
//if (!_abort)
GoOcr();
buttonOK.Enabled = false;
buttonCancel.Enabled = false;
}
private void GoOcr()
{
var formSubOcr = new VobSubOcr();
formSubOcr.Initialize(_subtitle, Configuration.Settings.VobSubOcr, false);
if (formSubOcr.ShowDialog(this) == DialogResult.OK)
{
SubtitleFromOcr = formSubOcr.SubtitleFromOcr;
}
}
private void buttonStop_Click(object sender, EventArgs e)
{
_abort = true;
}
private void buttonOK_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void HardSubExtract_FormClosing(object sender, FormClosingEventArgs e)
{
try
{
if (System.IO.Directory.Exists(_folderName))
System.IO.Directory.Delete(_folderName);
}
catch
{
}
}
private void buttonShowImg_Click(object sender, EventArgs e)
{
pictureBox2.Image = GetSnapShot(Convert.ToInt64(_libVlc.CurrentPosition * 1000.0));
}
private void TimerRefreshProgressbarTick(object sender, EventArgs e) private void TimerRefreshProgressbarTick(object sender, EventArgs e)
{ {
if (mediaPlayer != null) if (mediaPlayer != null)
@ -356,224 +142,177 @@ namespace Nikse.SubtitleEdit.Forms
pictureBox2.Invalidate(); pictureBox2.Invalidate();
} }
//static void* lock(void* userData, void** p_pixels) { private void StartStop_Click(object sender, EventArgs e)
// char* buffer = (char* )userData;
// *p_pixels = buffer;
// cout << "lock no: " << frameCount << endl;
// return NULL;
//}
//static void unlock(void* userData, void* picture, void *const * p_pixels) {
// cout << "unlock no: " << frameCount++ << endl;
//}
// libvlc_instance_t* vlcInstance=libvlc_new(0, NULL);
// libvlc_media_t* media = libvlc_media_new_path(vlcInstance, fname.c_str());
// libvlc_media_player_t* mediaPlayer = libvlc_media_player_new_from_media(media);
// libvlc_media_release(media);
// int wd = 2096, ht = 1132;
// buf = new char[wd*ht*4];
// libvlc_video_set_callbacks(mediaPlayer, lock, unlock, NULL, buf);
// libvlc_video_set_format(mediaPlayer, "RV32", wd, ht, 4*wd);
// libvlc_media_player_play (mediaPlayer);
void OnpLock(IntPtr opaque, ref IntPtr plane)
{ {
//PixelData* px = (PixelData*)opaque; //Cursor.Current = Cursors.WaitCursor;
//*plane = px->pPixelData; //buttonStop.Visible = true;
//return null; //StartStop.Enabled = false;
} //cam = new HardExtractCapture(tbFileName.Text, (int)numericUpDownPixelsBottom.Value, checkBoxCustomColor.Checked, checkBoxYellow.Checked, pictureBoxCustomColor.BackColor, (int)numericUpDownCustomMaxDiff.Value);
void OnpUnlock(IntPtr opaque, IntPtr picture, ref IntPtr plane) //// Start displaying statistics
{ //this.timer1 = new System.Windows.Forms.Timer(this.components);
frameCount++; //this.timer1.Interval = 1000;
} //this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//timer1.Enabled = true;
//cam.Start();
//cam.WaitUntilDone();
//timer1.Enabled = false;
unsafe void OnpDisplay(void* opaque, void* picture) //// Final update
{ //tbFrameNum.Text = cam.count.ToString();
//lock (m_lock) //tbBlacks.Text = cam.blacks.ToString();
//string fileNameNoExt = Path.GetTempFileName();
//Cursor.Current = Cursors.Default;
//var sub = new Subtitle();
//for (int i = 0; i < cam.Images.Count; i++)
//{ //{
// try // if (cam.StartTimes.Count > i)
// { // {
// PixelData* px = (PixelData*)opaque; // Paragraph p = new Paragraph();
// MemoryHeap.CopyMemory(m_pBuffer, px->pPixelData, px->size); // p.StartTime.TotalSeconds = cam.StartTimes[i];
// if (cam.EndTimes.Count > i)
// m_frameRate++;
// if (m_callback != null)
// { // {
// using (Bitmap frame = GetBitmap()) // p.EndTime.TotalSeconds = cam.EndTimes[i];
// {
// m_callback(frame);
// }
// }
// }
// catch (Exception ex)
// {
// if (m_excHandler != null)
// {
// m_excHandler(ex);
// } // }
// else // else
// { // {
// throw ex; // p.EndTime.TotalSeconds = p.StartTime.TotalSeconds + 2.5;
// } // }
// p.Text = fileNameNoExt + string.Format("{0:0000}", i) + ".bmp";
// sub.Paragraphs.Add(p);
// var bmp = cam.Images[i].GetBitmap();
// bmp.Save(p.Text);
// bmp.Dispose();
// } // }
//} //}
} //sub.Renumber(1);
//if (sub.Paragraphs.Count > 0)
public void VlcLock(IntPtr opaque, ref IntPtr planes)
{
m_cb_ctx.mutex.WaitOne();
// log("CB_Lock");
planes = m_cb_ctx.framebuf.AllocateUnmanaged();
}
public void VlcUnlock(IntPtr opaque, IntPtr picture, ref IntPtr planes)
{
// log("CB_Unlock");
m_cb_ctx.mutex.ReleaseMutex();
// labelStatus.Text = frameCounter.ToString();
// _done = true;
}
public void VlcDisplay(IntPtr opaque, IntPtr picture)
{
// _done = true;
return;
//log("CB_Display");
//frameCounter++;
//int w = _videoInfo.Width;
//int h = _videoInfo.Height;
//byte[] frame = m_cb_ctx.framebuf.GetSafeCopy(); // get copy of the frame data
//Bitmap bmp = new Bitmap(w, h);
// convert to bmp
//for (int y = 0; y < h; y++)
//{ //{
// for (int x = 0; x < w; x++) // OcrFileName = fileNameNoExt + ".srt";
// System.IO.File.WriteAllText(OcrFileName, sub.ToText(new SubRip()));
//}
//lock (this)
//{
// cam.Dispose();
// cam = null;
//}
//buttonStop.Visible = false;
//StartStop.Enabled = true;
}
private void timer1_Tick(object sender, System.EventArgs e)
{
//if (cam != null)
//{
// tbFrameNum.Text = cam.count.ToString();
// tbBlacks.Text = cam.blacks.ToString();
// if (cam.Images.Count > 0)
// { // {
// int pos = (y * w + x) * 3; // var old = pictureBox2.Image as Bitmap;
// Color color = Color.FromArgb(frame[pos], frame[pos + 1], frame[pos + 2]); // pictureBox2.Image = cam.Images[cam.Images.Count - 1].GetBitmap();
// bmp.SetPixel(x, y, color); // if (old != null)
// old.Dispose();
// } // }
//} //}
//bmp.Save(@"D:\Download\callbacks\frame" + frameCounter.ToString() + ".bmp");
} }
public IntPtr GetIntPtrOfObject(object o) private void pictureBoxCustomColor_Click(object sender, EventArgs e)
{ {
// extract the IntPtr "pointing" the context object colorDialog1.Color = pictureBoxCustomColor.BackColor;
// http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.gchandle.tointptr.aspx if (colorDialog1.ShowDialog(this) == DialogResult.OK)
{
GCHandle handle = GCHandle.Alloc(o); pictureBoxCustomColor.BackColor = colorDialog1.Color;
IntPtr opaque = GCHandle.ToIntPtr(handle); SetCustumRGB();
//handle.Free(); // TODO: ok? }
return opaque;
} }
private void buttonOK_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void buttonStop_Click(object sender, EventArgs e)
{
//if (cam != null)
// cam.Cancel = true;
//buttonStop.Visible = false;
//StartStop.Enabled = true;
}
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
m_cb_lock = new Nikse.SubtitleEdit.Logic.VideoPlayers.LibVlc11xDynamic.LockCallbackDelegate(VlcLock); try
m_cb_unlock = new Nikse.SubtitleEdit.Logic.VideoPlayers.LibVlc11xDynamic.UnlockCallbackDelegate(VlcUnlock);
m_cb_display = new Nikse.SubtitleEdit.Logic.VideoPlayers.LibVlc11xDynamic.DisplayCallbackDelegate(VlcDisplay);
uint w = (uint)_videoInfo.Width;
uint h = (uint)_videoInfo.Height;
m_cb_ctx = new CallbackContext(_videoInfo.Width * _videoInfo.Height * 3 * 10);
IntPtr opaque = GetIntPtrOfObject(m_cb_ctx);
string videoFile = _videoFileName; // @"D:\Download\a.mkv";
frameCounter = 0;
// _libVlc = new LibVlc11xDynamic();
// _libVlc.InitializeAndStartFrameGrabbing(videoFile, w, h, m_cb_lock, m_cb_unlock, m_cb_display, opaque);
_libVlc.Play();
_libVlc.Pause();
_libVlc.CurrentPosition = 0;
Application.DoEvents();
long ticks = DateTime.Now.Ticks;
Bitmap prev = null;
Bitmap current = null;
int numberOfFrames = (int)_videoInfo.TotalFrames;
for (int i = 0; i < numberOfFrames; i++)
{ {
//_done = false; var fileName = Path.Combine(System.IO.Path.GetTempPath(), Guid.NewGuid().ToString() + ".bmp");
_libVlc.GetNextFrame();
//int vlcState = _libVlc.VlcState;
//while (vlcState != 0 && vlcState != 4)
//{
// Application.DoEvents();
// vlcState = _libVlc.VlcState;
//}
//while (!_done)
//{
// Application.DoEvents();
//}
frameCounter++;
string fileName = @"D:\Download\callbacks\frame" + frameCounter.ToString() + ".png";
_libVlc.TakeSnapshot(fileName, (uint)_videoInfo.Width, (uint)_videoInfo.Height); _libVlc.TakeSnapshot(fileName, (uint)_videoInfo.Width, (uint)_videoInfo.Height);
Application.DoEvents(); System.Threading.Thread.Sleep(100);
if (File.Exists(fileName)) if (System.IO.File.Exists(fileName))
{ {
current = new Bitmap(fileName); Bitmap bmp = null;
if (prev != null) using (var ms = new MemoryStream(File.ReadAllBytes(fileName)))
{ {
CheckForSceneChanges(prev, current, frameCounter); ms.Position = 0;
prev.Dispose(); bmp = ((Bitmap)Bitmap.FromStream(ms)); // avoid locking file
} }
prev = current; if (bmp != null)
} pictureBox2.Image = bmp;
} System.Threading.Thread.Sleep(50);
MessageBox.Show((DateTime.Now.Ticks - ticks).ToString()); File.Delete(fileName);
} }
private void CheckForSceneChanges(Bitmap prev, Bitmap current, long frameNumber)
{
int diff = 0;
factorWidth = prev.Width / lineChecksWidth;
factorHeight = prev.Height / lineChecksHeight;
for (int yCounter = 0; yCounter < lineChecksHeight; yCounter++)
{
int y = (int)Math.Round(yCounter * factorHeight);
for (int xCounter = 0; xCounter < lineChecksWidth; xCounter++)
{
int x = (int)Math.Round(xCounter * factorWidth);
Color prevColor = prev.GetPixel(x, y);
Color curColor = current.GetPixel(x, y);
if (Math.Abs(prevColor.A - curColor.A) > maxDiffARGB ||
Math.Abs(prevColor.R - curColor.R) > maxDiffARGB ||
Math.Abs(prevColor.G - curColor.G) > maxDiffARGB ||
Math.Abs(prevColor.B - curColor.B) > maxDiffARGB)
{
diff++;
//if (diff > maxDiffPixels)
//{
// sceneChangeFrames.Add(frameNumber);
// labelStatus.Text = frameNumber.ToString() + " " + _libVlc.CurrentPosition.ToString() + " " + diff.ToString();
// labelStatus.Refresh();
// Application.DoEvents();
// return;
//}
} }
} catch
}
if (diff > maxDiffPixels)
{ {
sceneChangeFrames.Add(frameNumber);
} }
if (diff > currentBestDiff)
currentBestDiff = diff;
labelStatus.Text = frameNumber.ToString() + " " + _libVlc.CurrentPosition.ToString() + " " + diff.ToString() + " all time best diff:" + currentBestDiff;
} }
private void button2_Click(object sender, EventArgs e) private void SetCustumRGB()
{ {
MessageBox.Show(frameCounter.ToString()); labelCustomRgb.Text = string.Format("(Red={0},Green={1},Blue={2})", pictureBoxCustomColor.BackColor.R, pictureBoxCustomColor.BackColor.G, pictureBoxCustomColor.BackColor.B);
_libVlc.Stop(); }
private void saveImageAsToolStripMenuItem_Click(object sender, EventArgs e)
{
saveFileDialog1.Title = Configuration.Settings.Language.VobSubOcr.SaveSubtitleImageAs;
saveFileDialog1.AddExtension = true;
saveFileDialog1.FileName = "Image";
saveFileDialog1.Filter = "PNG image|*.png|BMP image|*.bmp|GIF image|*.gif|TIFF image|*.tiff";
saveFileDialog1.FilterIndex = 0;
DialogResult result = saveFileDialog1.ShowDialog(this);
if (result == DialogResult.OK)
{
Bitmap bmp = pictureBox2.Image as Bitmap;
if (bmp == null)
{
MessageBox.Show("No image!");
return;
}
try
{
if (saveFileDialog1.FilterIndex == 0)
bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png);
else if (saveFileDialog1.FilterIndex == 1)
bmp.Save(saveFileDialog1.FileName);
else if (saveFileDialog1.FilterIndex == 2)
bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Gif);
else
bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Tiff);
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}
} }
} }

View File

@ -117,10 +117,19 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="contextMenuStripScreenshot.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>489, 17</value>
</metadata>
<metadata name="openFileDialogVideo.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="openFileDialogVideo.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="timerRefreshProgressbar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="timerRefreshProgressbar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>182, 17</value> <value>182, 17</value>
</metadata> </metadata>
<metadata name="colorDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>368, 17</value>
</metadata>
<metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>698, 17</value>
</metadata>
</root> </root>

View File

@ -17825,13 +17825,13 @@ namespace Nikse.SubtitleEdit.Forms
{ {
var form = new HardSubExtract(_videoFileName); var form = new HardSubExtract(_videoFileName);
if (form.ShowDialog(this) == DialogResult.OK) if (form.ShowDialog(this) == DialogResult.OK)
{
if (!string.IsNullOrEmpty(form.OcrFileName))
{ {
MakeHistoryForUndo(_language.BeforeAutoBalanceSelectedLines); //TODO: Fix text MakeHistoryForUndo(_language.BeforeAutoBalanceSelectedLines); //TODO: Fix text
_subtitle = form.SubtitleFromOcr; OpenSubtitle(form.OcrFileName, null);
_subtitleAlternate = new Subtitle(); }
_subtitleAlternateFileName = null;
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
SubtitleListview1.SelectIndexAndEnsureVisible(0);
} }
} }

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Xml; using System.Xml;
using System.Xml.Schema;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{ {
@ -100,7 +101,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
} }
string xmlStructure = string xmlStructure =
"<dcst:SubtitleReel Version=\"1.0\" xmlns:dcst=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" + Environment.NewLine + "<dcst:SubtitleReel xmlns:dcst=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" + Environment.NewLine +
" <dcst:Id>urn:uuid:7be835a3-cfb4-43d0-bb4b-f0b4c95e962e</dcst:Id>" + Environment.NewLine + " <dcst:Id>urn:uuid:7be835a3-cfb4-43d0-bb4b-f0b4c95e962e</dcst:Id>" + Environment.NewLine +
" <dcst:ContentTitleText></dcst:ContentTitleText> " + Environment.NewLine + " <dcst:ContentTitleText></dcst:ContentTitleText> " + Environment.NewLine +
" <dcst:AnnotationText>This is a subtitle file</dcst:AnnotationText>" + Environment.NewLine + " <dcst:AnnotationText>This is a subtitle file</dcst:AnnotationText>" + Environment.NewLine +
@ -232,11 +233,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{ {
XmlNode textNode = xml.CreateElement("dcst:Text", "dcst"); XmlNode textNode = xml.CreateElement("dcst:Text", "dcst");
XmlAttribute vPosition = xml.CreateAttribute("VPosition"); XmlAttribute vPosition = xml.CreateAttribute("Vposition");
vPosition.InnerText = vPos.ToString(); vPosition.InnerText = vPos.ToString();
textNode.Attributes.Append(vPosition); textNode.Attributes.Append(vPosition);
XmlAttribute vAlign = xml.CreateAttribute("VAlign"); XmlAttribute vAlign = xml.CreateAttribute("Valign");
if (alignVTop) if (alignVTop)
vAlign.InnerText = "top"; vAlign.InnerText = "top";
else if (alignVCenter) else if (alignVCenter)
@ -245,7 +246,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
vAlign.InnerText = "bottom"; vAlign.InnerText = "bottom";
textNode.Attributes.Append(vAlign); textNode.Attributes.Append(vAlign); textNode.Attributes.Append(vAlign); textNode.Attributes.Append(vAlign);
XmlAttribute hAlign = xml.CreateAttribute("HAlign"); XmlAttribute hAlign = xml.CreateAttribute("Halign");
if (alignLeft) if (alignLeft)
hAlign.InnerText = "left"; hAlign.InnerText = "left";
else if (alignRight) else if (alignRight)
@ -255,7 +256,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
textNode.Attributes.Append(hAlign); textNode.Attributes.Append(hAlign);
XmlAttribute direction = xml.CreateAttribute("Direction"); XmlAttribute direction = xml.CreateAttribute("Direction");
direction.InnerText = "horizontal"; direction.InnerText = "ltr";
textNode.Attributes.Append(direction); textNode.Attributes.Append(direction);
int i = 0; int i = 0;
@ -437,9 +438,37 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
no++; no++;
} }
} }
string result = ToUtf8XmlString(xml).Replace("encoding=\"utf-8\"", "encoding=\"UTF-8\"").Replace(" xmlns:dcst=\"dcst\"", string.Empty);
return ToUtf8XmlString(xml).Replace("encoding=\"utf-8\"", "encoding=\"UTF-8\"").Replace(" xmlns:dcst=\"dcst\"", string.Empty); string res = "Nikse.SubtitleEdit.Resources.SMPTE-428-7-2007-DCST.xsd";
System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
Stream strm = asm.GetManifestResourceStream(res);
if (strm != null)
{
try
{
var xmld = new XmlDocument();
xmld.LoadXml(result);
var xr = XmlReader.Create(strm);
xmld.Schemas.Add(null, xr);
xmld.Validate(ValidationCallBack);
xr.Close();
strm.Close();
} }
catch (Exception exception)
{
System.Windows.Forms.MessageBox.Show("SMPTE-428-7-2007-DCST.xsd:" + exception.Message);
}
}
return result;
}
private void ValidationCallBack(object sender, ValidationEventArgs e)
{
throw new Exception(e.Message);
}
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName) public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{ {

View File

@ -196,6 +196,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
new UnknownSubtitle64(), new UnknownSubtitle64(),
new UnknownSubtitle65(), new UnknownSubtitle65(),
new UnknownSubtitle66(), new UnknownSubtitle66(),
new UnknownSubtitle67(),
}; };
string path = Configuration.PluginsDirectory; string path = Configuration.PluginsDirectory;

View File

@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
public class UnknownSubtitle67: SubtitleFormat
{
public override string Extension
{
get { return ".xml"; }
}
public override string Name
{
get { return "Unknown 67"; }
}
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 override string ToText(Subtitle subtitle, string title)
{
string xmlStructure =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + Environment.NewLine +
"<Data autoStart=\"true\" contentPath=\"\" />";
var xml = new XmlDocument();
xml.LoadXml(xmlStructure);
foreach (Paragraph p in subtitle.Paragraphs)
{
XmlNode paragraph = xml.CreateElement("Cue");
XmlAttribute start = xml.CreateAttribute("value");
start.InnerText = string.Format("{0}", p.StartTime.TotalMilliseconds);
paragraph.Attributes.Append(start);
XmlAttribute duration = xml.CreateAttribute("lineBreakBefore");
duration.InnerText = "true";
paragraph.Attributes.Append(duration);
paragraph.InnerText = p.Text;
xml.DocumentElement.AppendChild(paragraph);
}
return ToUtf8XmlString(xml);
}
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
string allText = sb.ToString();
if (!allText.Contains("<Cue") && allText.Contains("value="))
return;
var xml = new XmlDocument();
try
{
xml.LoadXml(allText);
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine(exception.Message);
_errorCount = 1;
return;
}
foreach (XmlNode node in xml.DocumentElement.SelectNodes("Cue"))
{
try
{
string start = node.Attributes["value"].InnerText;
if (!string.IsNullOrEmpty(start))
start = start.Replace(",", ".");
string text = node.InnerText;
subtitle.Paragraphs.Add(new Paragraph(text, Convert.ToDouble(start, System.Globalization.CultureInfo.InvariantCulture), 0));
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
_errorCount++;
}
}
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text);
if (i < subtitle.Paragraphs.Count - 1)
{
Paragraph next = subtitle.Paragraphs[i+1];
if (p.EndTime.TotalMilliseconds > next.StartTime.TotalMilliseconds)
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MininumMillisecondsBetweenLines;
}
}
subtitle.Renumber(1);
}
}
}

View File

@ -0,0 +1,305 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:dcst="http://www.smpte-ra.org/schemas/428-7/2007/DCST" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.smpte-ra.org/schemas/428-7/2007/DCST" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- SubtitleReel -->
<xs:element name="SubtitleReel" type="dcst:SubtitleReelType"/>
<xs:complexType name="SubtitleReelType">
<xs:sequence>
<xs:element name="Id" type="dcst:UUID"/>
<xs:element name="ContentTitleText" type="dcst:UserText"/>
<xs:element name="AnnotationText" type="dcst:UserText" minOccurs="0"/>
<xs:element name="IssueDate" type="xs:dateTime"/>
<xs:element name="ReelNumber" type="xs:positiveInteger" minOccurs="0"/>
<xs:element name="Language" type="xs:language" minOccurs="0"/>
<xs:element name="EditRate" type="dcst:RationalType"/>
<xs:element name="TimeCodeRate" type="xs:positiveInteger"/>
<xs:element name="StartTime" type="dcst:TimeCodeType" minOccurs="0"/>
<xs:element name="LoadFont" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:attribute name="ID" type="xs:string" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="SubtitleList">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Subtitle" type="dcst:SubtitleType"/>
<xs:element name="Font">
<xs:complexType mixed="true">
<xs:complexContent mixed="true">
<xs:extension base="dcst:FontType">
<xs:sequence>
<xs:element name="Subtitle" type="dcst:SubtitleType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<!-- Subtitle Type -->
<xs:complexType name="SubtitleType">
<xs:choice maxOccurs="unbounded">
<xs:element name="Text" type="dcst:TextType"/>
<xs:element name="Image" type="dcst:ImageType"/>
<xs:element name="Font">
<xs:complexType mixed="true">
<xs:complexContent mixed="true">
<xs:extension base="dcst:FontType">
<xs:sequence>
<xs:element name="Text" type="dcst:TextType"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="SpotNumber" type="xs:string" use="optional"/>
<xs:attribute name="TimeIn" type="dcst:TimeCodeType" use="required"/>
<xs:attribute name="TimeOut" type="dcst:TimeCodeType" use="required"/>
<xs:attribute name="FadeUpTime" type="dcst:TimeCodeType" use="optional"/>
<xs:attribute name="FadeDownTime" type="dcst:TimeCodeType" use="optional"/>
</xs:complexType>
<!-- Image Type -->
<xs:complexType name="ImageType" mixed="false">
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:attribute name="Halign" use="optional" default="center">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="center"/>
<xs:enumeration value="left"/>
<xs:enumeration value="right"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Hposition" use="optional" default="0">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="-100"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Valign" use="optional" default="center">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="center"/>
<xs:enumeration value="bottom"/>
<xs:enumeration value="top"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Vposition" use="optional" default="0">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="-100"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- Font Type -->
<xs:complexType name="FontType" mixed="true">
<xs:attribute name="Script" use="optional" default="normal">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="normal"/>
<xs:enumeration value="super"/>
<xs:enumeration value="sub"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Effect" use="optional" default="none">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="none"/>
<xs:enumeration value="border"/>
<xs:enumeration value="shadow"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Italic" use="optional" default="no">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Underline" use="optional" default="no">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Weight" use="optional" default="normal">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="bold"/>
<xs:enumeration value="normal"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="ID" type="xs:string" use="optional"/>
<xs:attribute name="Color" use="optional">
<xs:simpleType>
<xs:restriction base="xs:hexBinary">
<xs:length value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="EffectColor" use="optional">
<xs:simpleType>
<xs:restriction base="xs:hexBinary">
<xs:length value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Size" use="optional" default="42">
<xs:simpleType>
<xs:restriction base="xs:positiveInteger"/>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<!-- Text Type -->
<xs:complexType name="TextType" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Font" type="dcst:FontType"/>
<xs:element name="Ruby" type="dcst:RubyType"/>
<xs:element name="Space" type="dcst:SpaceType"/>
<xs:element name="HGroup" type="xs:string"/>
<xs:element name="Rotate" type="dcst:RotateType"/>
</xs:choice>
<xs:attribute name="Halign" use="optional" default="center">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="center"/>
<xs:enumeration value="left"/>
<xs:enumeration value="right"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Hposition" use="optional" default="0">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="-100"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Valign" use="optional" default="center">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="center"/>
<xs:enumeration value="bottom"/>
<xs:enumeration value="top"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Vposition" use="optional" default="0">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="-100"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Direction" use="optional" default="ltr">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="ltr"/>
<xs:enumeration value="rtl"/>
<xs:enumeration value="ttb"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<!-- Rational Type -->
<xs:simpleType name="RationalType">
<xs:restriction>
<xs:simpleType>
<xs:list itemType="xs:long"/>
</xs:simpleType>
<xs:length value="2"/>
</xs:restriction>
</xs:simpleType>
<!-- TimeCode Type -->
<xs:simpleType name="TimeCodeType">
<xs:restriction base="xs:string">
<xs:pattern value="[0-2][0-9]:[0-5][0-9]:[0-5][0-9]:[0-2][0-9]"/>
</xs:restriction>
</xs:simpleType>
<!-- Ruby Type -->
<xs:complexType name="RubyType">
<xs:sequence>
<xs:element name="Rb" type="xs:string"/>
<xs:element name="Rt">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Size" type="xs:decimal" use="optional" default="0.5"/>
<xs:attribute name="Position" use="optional" default="before">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="before"/>
<xs:enumeration value="after"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Spacing" type="xs:decimal" use="optional" default="0.5"/>
<xs:attribute name="Offset" type="xs:decimal" use="optional" default="0.5"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<!-- Rotate Type -->
<xs:complexType name="RotateType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Direction" use="optional" default="none">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="none"/>
<xs:enumeration value="left"/>
<xs:enumeration value="right"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- Space Type -->
<xs:complexType name="SpaceType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Size" type="xs:decimal" use="optional" default="1.0"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- UUID Type -->
<xs:simpleType name="UUID">
<xs:restriction base="xs:anyURI">
<xs:pattern value="urn:uuid:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"/>
</xs:restriction>
</xs:simpleType>
<!-- UserText Type -->
<xs:complexType name="UserText">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="language" type="xs:language" use="optional" default="en"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>

View File

@ -847,6 +847,7 @@
<Compile Include="Logic\SubtitleFormats\CaraokeXml.cs" /> <Compile Include="Logic\SubtitleFormats\CaraokeXml.cs" />
<Compile Include="Logic\SubtitleFormats\Cavena890.cs" /> <Compile Include="Logic\SubtitleFormats\Cavena890.cs" />
<Compile Include="Logic\SubtitleFormats\CheetahCaption.cs" /> <Compile Include="Logic\SubtitleFormats\CheetahCaption.cs" />
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle67.cs" />
<Compile Include="Logic\SubtitleFormats\SwiftTextLineNumber .cs" /> <Compile Include="Logic\SubtitleFormats\SwiftTextLineNumber .cs" />
<Compile Include="Logic\SubtitleFormats\Titra.cs" /> <Compile Include="Logic\SubtitleFormats\Titra.cs" />
<Compile Include="Logic\SubtitleFormats\WebVTTFileWithLineNumber.cs" /> <Compile Include="Logic\SubtitleFormats\WebVTTFileWithLineNumber.cs" />
@ -1440,6 +1441,9 @@
<EmbeddedResource Include="Resources\HunspellDictionaries.xml.zip" /> <EmbeddedResource Include="Resources\HunspellDictionaries.xml.zip" />
<EmbeddedResource Include="Resources\TesseractDictionaries.xml.zip" /> <EmbeddedResource Include="Resources\TesseractDictionaries.xml.zip" />
<EmbeddedResource Include="Resources\nOCR_TesseractHelper.xml.zip" /> <EmbeddedResource Include="Resources\nOCR_TesseractHelper.xml.zip" />
<EmbeddedResource Include="Resources\SMPTE-428-7-2007-DCST.xsd">
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="Web References\MicrosoftTranslationService\GetTranslationsResponse.datasource"> <None Include="Web References\MicrosoftTranslationService\GetTranslationsResponse.datasource">
<DependentUpon>Reference.map</DependentUpon> <DependentUpon>Reference.map</DependentUpon>
</None> </None>

View File

@ -2,8 +2,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012 # Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubtitleEdit", "SubtitleEdit.csproj", "{511A5B59-1C35-4719-8536-23B19AF9B21A}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubtitleEdit", "SubtitleEdit.csproj", "{511A5B59-1C35-4719-8536-23B19AF9B21A}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{766101A0-80D5-4560-BFF7-73F1559B4C47}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{766101A0-80D5-4560-BFF7-73F1559B4C47}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
Local.testsettings = Local.testsettings Local.testsettings = Local.testsettings
@ -28,10 +26,6 @@ Global
{511A5B59-1C35-4719-8536-23B19AF9B21A}.Debug|Any CPU.Build.0 = Debug|Any CPU {511A5B59-1C35-4719-8536-23B19AF9B21A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{511A5B59-1C35-4719-8536-23B19AF9B21A}.Release|Any CPU.ActiveCfg = Release|Any CPU {511A5B59-1C35-4719-8536-23B19AF9B21A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{511A5B59-1C35-4719-8536-23B19AF9B21A}.Release|Any CPU.Build.0 = Release|Any CPU {511A5B59-1C35-4719-8536-23B19AF9B21A}.Release|Any CPU.Build.0 = Release|Any CPU
{7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE