mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Add "image prefix" for export to fcp image - thx Peter :)
This commit is contained in:
parent
33b1ffe4e2
commit
0053838963
@ -650,6 +650,7 @@ Note: Do check free disk space.</WaveFileMalformed>
|
||||
<SimpleRendering>Simple rendering</SimpleRendering>
|
||||
<AntiAliasingWithTransparency>Anti-aliasing with transparency</AntiAliasingWithTransparency>
|
||||
<Text3D>3D</Text3D>
|
||||
<ImagePrefix>Image prefix</ImagePrefix>
|
||||
<SideBySide3D>Half-side-by-side</SideBySide3D>
|
||||
<HalfTopBottom3D>Half-Top/Bottom</HalfTopBottom3D>
|
||||
<Depth>Depth</Depth>
|
||||
@ -2411,6 +2412,7 @@ can edit in same subtitle file (collaboration)</Information>
|
||||
<MergeDialog>Merge dialog (insert dashes)</MergeDialog>
|
||||
<MergeDialogWithNext>Merge dialog with next (insert dashes)</MergeDialogWithNext>
|
||||
<MergeDialogWithPrevious>Merge dialog with previous (insert dashes)</MergeDialogWithPrevious>
|
||||
<AutoBalanceSelectedLines>Auto balance selected lines</AutoBalanceSelectedLines>
|
||||
<GoToNext>Go to next line</GoToNext>
|
||||
<GoToNextPlayTranslate>Go to next line (and play in 'Translate mode')</GoToNextPlayTranslate>
|
||||
<GoToNextCursorAtEnd>Go to next line and set cursor at end</GoToNextCursorAtEnd>
|
||||
|
76
src/ui/Forms/ExportPngXml.Designer.cs
generated
76
src/ui/Forms/ExportPngXml.Designer.cs
generated
@ -37,6 +37,9 @@
|
||||
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
|
||||
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||
this.groupBoxImageSettings = new System.Windows.Forms.GroupBox();
|
||||
this.labelImagePrefix = new System.Windows.Forms.Label();
|
||||
this.textBoxImagePrefix = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxResolution = new System.Windows.Forms.ComboBox();
|
||||
this.labelResize = new System.Windows.Forms.Label();
|
||||
this.comboBoxResizePercentage = new System.Windows.Forms.ComboBox();
|
||||
this.comboBoxBottomMarginUnit = new System.Windows.Forms.ComboBox();
|
||||
@ -69,7 +72,6 @@
|
||||
this.comboBoxImageFormat = new System.Windows.Forms.ComboBox();
|
||||
this.checkBoxBold = new System.Windows.Forms.CheckBox();
|
||||
this.labelResolution = new System.Windows.Forms.Label();
|
||||
this.comboBoxResolution = new System.Windows.Forms.ComboBox();
|
||||
this.comboBoxHAlign = new System.Windows.Forms.ComboBox();
|
||||
this.labelHorizontalAlign = new System.Windows.Forms.Label();
|
||||
this.checkBoxSimpleRender = new System.Windows.Forms.CheckBox();
|
||||
@ -176,6 +178,8 @@
|
||||
//
|
||||
this.groupBoxImageSettings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBoxImageSettings.Controls.Add(this.labelImagePrefix);
|
||||
this.groupBoxImageSettings.Controls.Add(this.textBoxImagePrefix);
|
||||
this.groupBoxImageSettings.Controls.Add(this.comboBoxResolution);
|
||||
this.groupBoxImageSettings.Controls.Add(this.labelResize);
|
||||
this.groupBoxImageSettings.Controls.Add(this.comboBoxResizePercentage);
|
||||
@ -232,6 +236,48 @@
|
||||
this.groupBoxImageSettings.TabStop = false;
|
||||
this.groupBoxImageSettings.Text = "Image settings";
|
||||
//
|
||||
// labelImagePrefix
|
||||
//
|
||||
this.labelImagePrefix.AutoSize = true;
|
||||
this.labelImagePrefix.Location = new System.Drawing.Point(284, 165);
|
||||
this.labelImagePrefix.Name = "labelImagePrefix";
|
||||
this.labelImagePrefix.Size = new System.Drawing.Size(64, 13);
|
||||
this.labelImagePrefix.TabIndex = 64;
|
||||
this.labelImagePrefix.Text = "Image prefix";
|
||||
//
|
||||
// textBoxImagePrefix
|
||||
//
|
||||
this.textBoxImagePrefix.Location = new System.Drawing.Point(354, 162);
|
||||
this.textBoxImagePrefix.Name = "textBoxImagePrefix";
|
||||
this.textBoxImagePrefix.Size = new System.Drawing.Size(317, 20);
|
||||
this.textBoxImagePrefix.TabIndex = 63;
|
||||
//
|
||||
// comboBoxResolution
|
||||
//
|
||||
this.comboBoxResolution.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxResolution.DropDownWidth = 160;
|
||||
this.comboBoxResolution.FormattingEnabled = true;
|
||||
this.comboBoxResolution.Items.AddRange(new object[] {
|
||||
"4K (4096x2160)",
|
||||
"UHD (3840x2160)",
|
||||
"2K (2048x1080)",
|
||||
"DCI 2K Scope (2048x858)",
|
||||
"DCI 2K Flat (1998x1080)",
|
||||
"1080p (1920x1080)",
|
||||
"1440x1080",
|
||||
"720p (1280x720)",
|
||||
"960x720",
|
||||
"480p (848x480)",
|
||||
"PAL (720x576)",
|
||||
"NTSC (720x480)",
|
||||
"640x352",
|
||||
"640x272"});
|
||||
this.comboBoxResolution.Location = new System.Drawing.Point(112, 78);
|
||||
this.comboBoxResolution.Name = "comboBoxResolution";
|
||||
this.comboBoxResolution.Size = new System.Drawing.Size(123, 21);
|
||||
this.comboBoxResolution.TabIndex = 5;
|
||||
this.comboBoxResolution.SelectedIndexChanged += new System.EventHandler(this.comboBoxResolution_SelectedIndexChanged);
|
||||
//
|
||||
// labelResize
|
||||
//
|
||||
this.labelResize.AutoSize = true;
|
||||
@ -615,32 +661,6 @@
|
||||
this.labelResolution.TabIndex = 4;
|
||||
this.labelResolution.Text = "Video res";
|
||||
//
|
||||
// comboBoxResolution
|
||||
//
|
||||
this.comboBoxResolution.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxResolution.DropDownWidth = 160;
|
||||
this.comboBoxResolution.FormattingEnabled = true;
|
||||
this.comboBoxResolution.Items.AddRange(new object[] {
|
||||
"4K (4096x2160)",
|
||||
"UHD (3840x2160)",
|
||||
"2K (2048x1080)",
|
||||
"DCI 2K Scope (2048x858)",
|
||||
"DCI 2K Flat (1998x1080)",
|
||||
"1080p (1920x1080)",
|
||||
"1440x1080",
|
||||
"720p (1280x720)",
|
||||
"960x720",
|
||||
"480p (848x480)",
|
||||
"PAL (720x576)",
|
||||
"NTSC (720x480)",
|
||||
"640x352",
|
||||
"640x272"});
|
||||
this.comboBoxResolution.Location = new System.Drawing.Point(112, 78);
|
||||
this.comboBoxResolution.Name = "comboBoxResolution";
|
||||
this.comboBoxResolution.Size = new System.Drawing.Size(123, 21);
|
||||
this.comboBoxResolution.TabIndex = 5;
|
||||
this.comboBoxResolution.SelectedIndexChanged += new System.EventHandler(this.comboBoxResolution_SelectedIndexChanged);
|
||||
//
|
||||
// comboBoxHAlign
|
||||
//
|
||||
this.comboBoxHAlign.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
@ -1172,5 +1192,7 @@
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparatorAdjust;
|
||||
private System.Windows.Forms.ToolStripMenuItem adjustDisplayTimeToolStripMenuItem;
|
||||
private System.Windows.Forms.CheckBox checkBoxFcpFullPathUrl;
|
||||
private System.Windows.Forms.Label labelImagePrefix;
|
||||
private System.Windows.Forms.TextBox textBoxImagePrefix;
|
||||
}
|
||||
}
|
@ -152,7 +152,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return 25;
|
||||
}
|
||||
|
||||
string s = comboBoxFrameRate.SelectedItem.ToString();
|
||||
var s = comboBoxFrameRate.SelectedItem.ToString();
|
||||
s = s.Replace(",", ".").Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, ".").Trim();
|
||||
if (double.TryParse(s, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var d))
|
||||
{
|
||||
@ -205,7 +205,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
string text = p.P.Text;
|
||||
var text = p.P.Text;
|
||||
if (format.GetType() == typeof(SubStationAlpha) && text.Length > 5)
|
||||
{
|
||||
text = p.P.Text.Substring(0, 6);
|
||||
@ -318,8 +318,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
nbmp.ReplaceTransparentWith(param.FullFrameBackgroundColor);
|
||||
using (var bmp = nbmp.GetBitmap())
|
||||
{
|
||||
int top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin);
|
||||
int left = (param.ScreenWidth - param.Bitmap.Width) / 2;
|
||||
var top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin);
|
||||
var left = (param.ScreenWidth - param.Bitmap.Width) / 2;
|
||||
|
||||
var b = new NikseBitmap(param.ScreenWidth, param.ScreenHeight);
|
||||
{
|
||||
@ -556,6 +556,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
singleFile = true;
|
||||
}
|
||||
else if (_exportType == ExportFormats.Fcp)
|
||||
|
||||
{
|
||||
saveFileDialog1.Title = LanguageSettings.Current.ExportPngXml.SaveFcpAs;
|
||||
saveFileDialog1.DefaultExt = "*.xml";
|
||||
@ -940,21 +941,21 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
internal void WriteFcpFile(int width, int height, StringBuilder sb, string fileName)
|
||||
{
|
||||
string fileNameNoPath = Path.GetFileName(fileName);
|
||||
string fileNameNoExt = Path.GetFileNameWithoutExtension(fileNameNoPath);
|
||||
var fileNameNoPath = Path.GetFileName(fileName);
|
||||
var fileNameNoExt = Path.GetFileNameWithoutExtension(fileNameNoPath);
|
||||
|
||||
int duration = 0;
|
||||
var duration = 0;
|
||||
if (_subtitle.Paragraphs.Count > 0)
|
||||
{
|
||||
duration = (int)Math.Round(_subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1].EndTime.TotalSeconds * 25.0);
|
||||
}
|
||||
|
||||
string s = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine +
|
||||
var s = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine +
|
||||
"<!DOCTYPE xmeml[]>" + Environment.NewLine +
|
||||
"<xmeml version=\"4\">" + Environment.NewLine +
|
||||
" <sequence id=\"" + System.Security.SecurityElement.Escape(fileNameNoExt) + "\">" + Environment.NewLine +
|
||||
" <sequence id=\"" + System.Security.SecurityElement.Escape(GetFcpPrefix()) + "\">" + Environment.NewLine +
|
||||
" <updatebehavior>add</updatebehavior>" + Environment.NewLine +
|
||||
" <name>" + System.Security.SecurityElement.Escape(fileNameNoExt) + @"</name>
|
||||
" <name>" + System.Security.SecurityElement.Escape(GetFcpPrefix()) + @"</name>
|
||||
<duration>" + duration.ToString(CultureInfo.InvariantCulture) + @"</duration>
|
||||
<rate>
|
||||
<ntsc>FALSE</ntsc>
|
||||
@ -1547,7 +1548,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
{
|
||||
if (!param.Saved)
|
||||
{
|
||||
imagesSavedCount = WriteFcpParagraph(sb, imagesSavedCount, param, i, saveFileDialog1.FileName);
|
||||
imagesSavedCount = WriteFcpParagraph(sb, imagesSavedCount, param, i, GetFcpPrefix(), saveFileDialog1.FileName);
|
||||
|
||||
param.Saved = true;
|
||||
}
|
||||
@ -1798,20 +1799,32 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
return imagesSavedCount;
|
||||
}
|
||||
|
||||
internal int WriteFcpParagraph(StringBuilder sb, int imagesSavedCount, MakeBitmapParameter param, int i, string fileName)
|
||||
private string GetFcpPrefix()
|
||||
{
|
||||
string numberString = string.Format(Path.GetFileNameWithoutExtension(Path.GetFileName(fileName)) + "{0:0000}", i).RemoveChar(' ');
|
||||
var prefix = textBoxImagePrefix.Text.Trim();
|
||||
if (string.IsNullOrEmpty(prefix))
|
||||
{
|
||||
prefix = Guid.NewGuid().ToString();
|
||||
textBoxImagePrefix.Text = prefix;
|
||||
}
|
||||
|
||||
return prefix;
|
||||
}
|
||||
|
||||
internal int WriteFcpParagraph(StringBuilder sb, int imagesSavedCount, MakeBitmapParameter param, int i, string imagePrefix, string fileName)
|
||||
{
|
||||
var numberString = string.Format(imagePrefix + "{0:0000}", i).RemoveChar(' ');
|
||||
var fileNameShort = numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant();
|
||||
var targetImageFileName = Path.Combine(Path.GetDirectoryName(fileName), fileNameShort);
|
||||
string fileNameNoPath = Path.GetFileName(fileNameShort);
|
||||
string fileNameNoExt = Path.GetFileNameWithoutExtension(fileNameNoPath);
|
||||
string pathUrl = "file://localhost/" + targetImageFileName.Replace("\\", "/").Replace(" ", "%20");
|
||||
var fileNameNoPath = Path.GetFileName(fileNameShort);
|
||||
var fileNameNoExt = Path.GetFileNameWithoutExtension(fileNameNoPath);
|
||||
var pathUrl = "file://localhost/" + targetImageFileName.Replace("\\", "/").Replace(" ", "%20");
|
||||
if (!checkBoxFcpFullPathUrl.Checked)
|
||||
{
|
||||
pathUrl = fileNameShort;
|
||||
}
|
||||
|
||||
string template = " <clipitem id=\"" + System.Security.SecurityElement.Escape(fileNameNoPath) + "\">" + Environment.NewLine +
|
||||
var template = " <clipitem id=\"" + System.Security.SecurityElement.Escape(fileNameNoPath) + "\">" + Environment.NewLine +
|
||||
@" <name>" + System.Security.SecurityElement.Escape(fileNameNoPath) + @"</name>
|
||||
<duration>[DURATION]</duration>
|
||||
<rate>
|
||||
@ -3967,6 +3980,10 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
_fileName = fileName;
|
||||
_format = format;
|
||||
_formatName = _format != null ? _format.Name : string.Empty;
|
||||
|
||||
textBoxImagePrefix.Visible = false;
|
||||
labelImagePrefix.Visible = false;
|
||||
|
||||
if (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat)
|
||||
{
|
||||
CalculateHeights(subtitle);
|
||||
@ -3995,6 +4012,22 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
else if (exportType == ExportFormats.Fcp)
|
||||
{
|
||||
Text = "Final Cut Pro";
|
||||
textBoxImagePrefix.Visible = true;
|
||||
labelImagePrefix.Visible = true;
|
||||
var imagePrefix = Guid.NewGuid().ToString();
|
||||
if (!string.IsNullOrEmpty(_videoFileName))
|
||||
{
|
||||
imagePrefix = _videoFileName;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(subtitle?.FileName))
|
||||
{
|
||||
imagePrefix = subtitle.FileName;
|
||||
}
|
||||
|
||||
imagePrefix = Path.GetFileNameWithoutExtension(imagePrefix);
|
||||
imagePrefix = Path.GetFileName(imagePrefix);
|
||||
|
||||
textBoxImagePrefix.Text = imagePrefix;
|
||||
}
|
||||
else if (exportType == ExportFormats.Dost)
|
||||
{
|
||||
@ -4146,13 +4179,15 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
comboBox3D.SelectedIndex = 0;
|
||||
|
||||
labelDepth.Text = LanguageSettings.Current.ExportPngXml.Depth;
|
||||
|
||||
numericUpDownDepth3D.Left = labelDepth.Left + labelDepth.Width + 3;
|
||||
|
||||
label3D.Text = LanguageSettings.Current.ExportPngXml.Text3D;
|
||||
|
||||
comboBox3D.Left = label3D.Left + label3D.Width + 3;
|
||||
|
||||
labelImagePrefix.Text = LanguageSettings.Current.ExportPngXml.ImagePrefix;
|
||||
textBoxImagePrefix.Left = labelImagePrefix.Left + labelImagePrefix.Width + 3;
|
||||
textBoxImagePrefix.Width = comboBoxFrameRate.Right - textBoxImagePrefix.Left;
|
||||
|
||||
buttonBorderColor.Text = LanguageSettings.Current.ExportPngXml.BorderColor;
|
||||
labelBorderWidth.Text = LanguageSettings.Current.ExportPngXml.BorderStyle;
|
||||
labelImageFormat.Text = LanguageSettings.Current.ExportPngXml.ImageFormat;
|
||||
|
@ -118,18 +118,18 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>565, 17</value>
|
||||
<value>440, 24</value>
|
||||
</metadata>
|
||||
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>307, 17</value>
|
||||
<value>189, 20</value>
|
||||
</metadata>
|
||||
<metadata name="timerPreview.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>443, 17</value>
|
||||
<value>316, 18</value>
|
||||
</metadata>
|
||||
<metadata name="contextMenuStripListView.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>720, 17</value>
|
||||
<value>587, 22</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1828,7 +1828,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
||||
{
|
||||
mp.Bitmap = ExportPngXml.GenerateImageFromTextWithStyle(mp);
|
||||
}
|
||||
form.WriteFcpParagraph(sb, imagesSavedCount, mp, index, outputFileName);
|
||||
form.WriteFcpParagraph(sb, imagesSavedCount, mp, index, Path.GetFileNameWithoutExtension(Path.GetFileName(outputFileName)), outputFileName);
|
||||
|
||||
if (index % 50 == 0)
|
||||
{
|
||||
|
@ -852,6 +852,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
SimpleRendering = "Simple rendering",
|
||||
AntiAliasingWithTransparency = "Anti-aliasing with transparency",
|
||||
Text3D = "3D",
|
||||
ImagePrefix = "Image prefix",
|
||||
SideBySide3D = "Half-side-by-side",
|
||||
HalfTopBottom3D = "Half-Top/Bottom",
|
||||
Depth = "Depth",
|
||||
|
@ -1696,6 +1696,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
case "ExportPngXml/Text3D":
|
||||
language.ExportPngXml.Text3D = reader.Value;
|
||||
break;
|
||||
case "ExportPngXml/ImagePrefix":
|
||||
language.ExportPngXml.ImagePrefix = reader.Value;
|
||||
break;
|
||||
case "ExportPngXml/SideBySide3D":
|
||||
language.ExportPngXml.SideBySide3D = reader.Value;
|
||||
break;
|
||||
@ -6586,6 +6589,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
case "Settings/MergeDialogWithPrevious":
|
||||
language.Settings.MergeDialogWithPrevious = reader.Value;
|
||||
break;
|
||||
case "Settings/AutoBalanceSelectedLines":
|
||||
language.Settings.AutoBalanceSelectedLines = reader.Value;
|
||||
break;
|
||||
case "Settings/GoToNext":
|
||||
language.Settings.GoToNext = reader.Value;
|
||||
break;
|
||||
|
@ -724,6 +724,7 @@
|
||||
public string SimpleRendering { get; set; }
|
||||
public string AntiAliasingWithTransparency { get; set; }
|
||||
public string Text3D { get; set; }
|
||||
public string ImagePrefix { get; set; }
|
||||
public string SideBySide3D { get; set; }
|
||||
public string HalfTopBottom3D { get; set; }
|
||||
public string Depth { get; set; }
|
||||
|
Loading…
Reference in New Issue
Block a user