mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Work on #6725
This commit is contained in:
parent
3e0c3c224d
commit
9af4524a07
@ -142,11 +142,11 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (node.Attributes != null)
|
if (node.Attributes?["Title"] != null)
|
||||||
{
|
{
|
||||||
string text = node.Attributes.GetNamedItem("Title").InnerText.Trim();
|
var text = node.Attributes.GetNamedItem("Title").InnerText.Trim();
|
||||||
string start = node.Attributes.GetNamedItem("StartTimecode").InnerText;
|
var start = node.Attributes.GetNamedItem("StartTimecode").InnerText;
|
||||||
string end = node.Attributes.GetNamedItem("EndTimecode").InnerText;
|
var end = node.Attributes.GetNamedItem("EndTimecode").InnerText;
|
||||||
subtitle.Paragraphs.Add(new Paragraph(DecodeTimeCodeFrames(start, splitChars), DecodeTimeCodeFrames(end, splitChars), text));
|
subtitle.Paragraphs.Add(new Paragraph(DecodeTimeCodeFrames(start, splitChars), DecodeTimeCodeFrames(end, splitChars), text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
45
src/ui/Forms/GenerateVideoWithSoftSubs.Designer.cs
generated
45
src/ui/Forms/GenerateVideoWithSoftSubs.Designer.cs
generated
@ -78,14 +78,9 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
this.nTSC720x480ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.nTSC720x480ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.x352ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.x352ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.x272ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.x272ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.contextMenuStripForm = new System.Windows.Forms.ContextMenuStrip(this.components);
|
|
||||||
this.closeWindowAfterGenerateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.defaultSaveInMatroskamkvToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.defaultSaveInMp4ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.groupBoxSettings.SuspendLayout();
|
this.groupBoxSettings.SuspendLayout();
|
||||||
this.contextMenuSubtitles.SuspendLayout();
|
this.contextMenuSubtitles.SuspendLayout();
|
||||||
this.contextMenuStripRes.SuspendLayout();
|
this.contextMenuStripRes.SuspendLayout();
|
||||||
this.contextMenuStripForm.SuspendLayout();
|
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// buttonGenerate
|
// buttonGenerate
|
||||||
@ -510,46 +505,11 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
this.x272ToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
|
this.x272ToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
|
||||||
this.x272ToolStripMenuItem.Text = "640x272";
|
this.x272ToolStripMenuItem.Text = "640x272";
|
||||||
//
|
//
|
||||||
// contextMenuStripForm
|
|
||||||
//
|
|
||||||
this.contextMenuStripForm.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.closeWindowAfterGenerateToolStripMenuItem,
|
|
||||||
this.defaultSaveInMatroskamkvToolStripMenuItem,
|
|
||||||
this.defaultSaveInMp4ToolStripMenuItem});
|
|
||||||
this.contextMenuStripForm.Name = "contextMenuStripForm";
|
|
||||||
this.contextMenuStripForm.Size = new System.Drawing.Size(238, 70);
|
|
||||||
//
|
|
||||||
// closeWindowAfterGenerateToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.closeWindowAfterGenerateToolStripMenuItem.Checked = true;
|
|
||||||
this.closeWindowAfterGenerateToolStripMenuItem.CheckOnClick = true;
|
|
||||||
this.closeWindowAfterGenerateToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
|
||||||
this.closeWindowAfterGenerateToolStripMenuItem.Name = "closeWindowAfterGenerateToolStripMenuItem";
|
|
||||||
this.closeWindowAfterGenerateToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
|
|
||||||
this.closeWindowAfterGenerateToolStripMenuItem.Text = "Close window after generate";
|
|
||||||
//
|
|
||||||
// defaultSaveInMatroskamkvToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.defaultSaveInMatroskamkvToolStripMenuItem.Checked = true;
|
|
||||||
this.defaultSaveInMatroskamkvToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
|
||||||
this.defaultSaveInMatroskamkvToolStripMenuItem.Name = "defaultSaveInMatroskamkvToolStripMenuItem";
|
|
||||||
this.defaultSaveInMatroskamkvToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
|
|
||||||
this.defaultSaveInMatroskamkvToolStripMenuItem.Text = "Default save in Matroska (mkv)";
|
|
||||||
this.defaultSaveInMatroskamkvToolStripMenuItem.Click += new System.EventHandler(this.defaultSaveInMatroskamkvToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// defaultSaveInMp4ToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.defaultSaveInMp4ToolStripMenuItem.Name = "defaultSaveInMp4ToolStripMenuItem";
|
|
||||||
this.defaultSaveInMp4ToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
|
|
||||||
this.defaultSaveInMp4ToolStripMenuItem.Text = "Default save in mp4";
|
|
||||||
this.defaultSaveInMp4ToolStripMenuItem.Click += new System.EventHandler(this.defaultSaveInMp4ToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// GenerateVideoWithSoftSubs
|
// GenerateVideoWithSoftSubs
|
||||||
//
|
//
|
||||||
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(869, 439);
|
this.ClientSize = new System.Drawing.Size(869, 439);
|
||||||
this.ContextMenuStrip = this.contextMenuStripForm;
|
|
||||||
this.Controls.Add(this.groupBoxSettings);
|
this.Controls.Add(this.groupBoxSettings);
|
||||||
this.Controls.Add(this.buttonGenerate);
|
this.Controls.Add(this.buttonGenerate);
|
||||||
this.Controls.Add(this.buttonCancel);
|
this.Controls.Add(this.buttonCancel);
|
||||||
@ -569,7 +529,6 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
this.groupBoxSettings.PerformLayout();
|
this.groupBoxSettings.PerformLayout();
|
||||||
this.contextMenuSubtitles.ResumeLayout(false);
|
this.contextMenuSubtitles.ResumeLayout(false);
|
||||||
this.contextMenuStripRes.ResumeLayout(false);
|
this.contextMenuStripRes.ResumeLayout(false);
|
||||||
this.contextMenuStripForm.ResumeLayout(false);
|
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
@ -622,11 +581,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
private System.Windows.Forms.Button buttonSetDefault;
|
private System.Windows.Forms.Button buttonSetDefault;
|
||||||
private System.Windows.Forms.ToolStripMenuItem toggleForcedToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem toggleForcedToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem toggleDefaultToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem toggleDefaultToolStripMenuItem;
|
||||||
private System.Windows.Forms.ContextMenuStrip contextMenuStripForm;
|
|
||||||
private System.Windows.Forms.ToolStripMenuItem closeWindowAfterGenerateToolStripMenuItem;
|
|
||||||
private System.Windows.Forms.Button buttonSetLanguage;
|
private System.Windows.Forms.Button buttonSetLanguage;
|
||||||
private System.Windows.Forms.ToolStripMenuItem setLanguageToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem setLanguageToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem defaultSaveInMatroskamkvToolStripMenuItem;
|
|
||||||
private System.Windows.Forms.ToolStripMenuItem defaultSaveInMp4ToolStripMenuItem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -355,11 +355,6 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
groupBoxSettings.Enabled = true;
|
groupBoxSettings.Enabled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (closeWindowAfterGenerateToolStripMenuItem.Checked)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetTargetVideoFilter()
|
private static string GetTargetVideoFilter()
|
||||||
@ -381,8 +376,9 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
{
|
{
|
||||||
var fileName = Path.GetFileNameWithoutExtension(_inputVideoFileName);
|
var fileName = Path.GetFileNameWithoutExtension(_inputVideoFileName);
|
||||||
fileName += ".embed";
|
fileName += ".embed";
|
||||||
fileName += defaultSaveInMatroskamkvToolStripMenuItem.Checked ? ".mkv" : ".mp4";
|
fileName = fileName.Replace(".", "_");
|
||||||
return fileName.Replace(".", "_");
|
fileName += Configuration.Settings.Tools.GenVideoEmbedOutputExt == ".mp4" ? ".mp4" : ".mkv";
|
||||||
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunEmbedding()
|
private void RunEmbedding()
|
||||||
@ -757,17 +753,5 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
buttonSetDefault.Enabled = count == 1;
|
buttonSetDefault.Enabled = count == 1;
|
||||||
buttonSetLanguage.Enabled = count > 0;
|
buttonSetLanguage.Enabled = count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void defaultSaveInMatroskamkvToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
defaultSaveInMatroskamkvToolStripMenuItem.Checked = true;
|
|
||||||
defaultSaveInMp4ToolStripMenuItem.Checked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void defaultSaveInMp4ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
defaultSaveInMatroskamkvToolStripMenuItem.Checked = false;
|
|
||||||
defaultSaveInMp4ToolStripMenuItem.Checked = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,4 @@
|
|||||||
<metadata name="contextMenuStripRes.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="contextMenuStripRes.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>104, 17</value>
|
<value>104, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="contextMenuStripForm.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>442, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</root>
|
@ -276,17 +276,15 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
var subsMeta = string.Empty;
|
var subsMeta = string.Empty;
|
||||||
var subsFormat = string.Empty;
|
var subsFormat = string.Empty;
|
||||||
|
|
||||||
//TODO: check number of audio + video tracks!
|
|
||||||
var ffmpegInfo = FfmpegMediaInfo.Parse(inputVideoFileName);
|
var ffmpegInfo = FfmpegMediaInfo.Parse(inputVideoFileName);
|
||||||
var videoTrackCount = ffmpegInfo.Tracks.Count(p => p.TrackType == FfmpegTrackType.Video);
|
|
||||||
var audioTrackCount = ffmpegInfo.Tracks.Count(p => p.TrackType == FfmpegTrackType.Audio);
|
var audioTrackCount = ffmpegInfo.Tracks.Count(p => p.TrackType == FfmpegTrackType.Audio);
|
||||||
|
|
||||||
var isMp4 = outputVideoFileName.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase);
|
var isMp4 = outputVideoFileName.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
var count = 0;
|
var count = 1;
|
||||||
|
var number = 0;
|
||||||
foreach (var softSub in softSubs)
|
foreach (var softSub in softSubs)
|
||||||
{
|
{
|
||||||
count++;
|
|
||||||
subsInput += $" -i \"{softSub.FileName}\"";
|
subsInput += $" -i \"{softSub.FileName}\"";
|
||||||
subsMap += $" -map {count}";
|
subsMap += $" -map {count}";
|
||||||
|
|
||||||
@ -296,7 +294,7 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
var threeLetterCode = Iso639Dash2LanguageCode.GetThreeLetterCodeFromTwoLetterCode(lang);
|
var threeLetterCode = Iso639Dash2LanguageCode.GetThreeLetterCodeFromTwoLetterCode(lang);
|
||||||
if (lang.Length == 3)
|
if (lang.Length == 3)
|
||||||
{
|
{
|
||||||
threeLetterCode = softSub.Language;
|
threeLetterCode = lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
var languageName = Iso639Dash2LanguageCode.List.FirstOrDefault(p => p.ThreeLetterCode == threeLetterCode)?.EnglishName;
|
var languageName = Iso639Dash2LanguageCode.List.FirstOrDefault(p => p.ThreeLetterCode == threeLetterCode)?.EnglishName;
|
||||||
@ -307,25 +305,25 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(threeLetterCode) && !string.IsNullOrEmpty(languageName))
|
if (!string.IsNullOrEmpty(threeLetterCode) && !string.IsNullOrEmpty(languageName))
|
||||||
{
|
{
|
||||||
subsMeta += $" -metadata:s:s:{count - 1} language=\"{threeLetterCode}\"";
|
subsMeta += $" -metadata:s:s:{number} language=\"{threeLetterCode}\"";
|
||||||
subsMeta += $" -metadata:s:s:{count - 1} title=\"{languageName}\"";
|
subsMeta += $" -metadata:s:s:{number} title=\"{languageName}\"";
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrEmpty(softSub.Language))
|
else if (!string.IsNullOrEmpty(softSub.Language))
|
||||||
{
|
{
|
||||||
subsMeta += $" -metadata:s:s:{count - 1} language=\"{softSub.Language}\"";
|
subsMeta += $" -metadata:s:s:{number} language=\"{softSub.Language}\"";
|
||||||
subsMeta += $" -metadata:s:s:{count - 1} title=\"{softSub.Language}\"";
|
subsMeta += $" -metadata:s:s:{number} title=\"{softSub.Language}\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (softSub.IsDefault)
|
if (softSub.IsDefault)
|
||||||
{
|
{
|
||||||
subsMeta += $" -disposition:s:s:{count - 1} default";
|
subsMeta += $" -disposition:s:s:{number} default";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (softSub.IsForced)
|
if (softSub.IsForced)
|
||||||
{
|
{
|
||||||
subsMeta += $" -disposition:s:s:{count - 1} forced";
|
subsMeta += $" -disposition:s:s:{number} forced";
|
||||||
subsMeta += $" -metadata:s:s:{count - 1} forced=1";
|
subsMeta += $" -metadata:s:s:{number} forced=1";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMp4)
|
if (isMp4)
|
||||||
@ -334,25 +332,28 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
}
|
}
|
||||||
else if (softSub.SubtitleFormat == null && softSub.Format == "Blu-ray sup")
|
else if (softSub.SubtitleFormat == null && softSub.Format == "Blu-ray sup")
|
||||||
{
|
{
|
||||||
subsFormat += $" -c:s:s:{count - 1} copy"; // should be "pgs" or "pgssub" or ?
|
subsFormat += $" -c:s:s:{number} copy"; // should be "pgs" or "pgssub" or ?
|
||||||
}
|
}
|
||||||
else if (softSub.SubtitleFormat?.GetType() == typeof(SubRip))
|
else if (softSub.SubtitleFormat?.GetType() == typeof(SubRip))
|
||||||
{
|
{
|
||||||
subsFormat += $" -c:s:s:{count - 1} srt";
|
subsFormat += $" -c:s:s:{number} srt";
|
||||||
}
|
}
|
||||||
else if (softSub.SubtitleFormat?.GetType() == typeof(AdvancedSubStationAlpha))
|
else if (softSub.SubtitleFormat?.GetType() == typeof(AdvancedSubStationAlpha))
|
||||||
{
|
{
|
||||||
subsFormat += $" -c:s:s:{count - 1} ass";
|
subsFormat += $" -c:s:s:{number} ass";
|
||||||
}
|
}
|
||||||
else if (softSub.SubtitleFormat?.GetType() == typeof(SubStationAlpha))
|
else if (softSub.SubtitleFormat?.GetType() == typeof(SubStationAlpha))
|
||||||
{
|
{
|
||||||
subsFormat += $" -c:s:s:{count - 1} ssa";
|
subsFormat += $" -c:s:s:{number} ssa";
|
||||||
}
|
}
|
||||||
else if (softSub.SubtitleFormat?.GetType() == typeof(WebVTT) ||
|
else if (softSub.SubtitleFormat?.GetType() == typeof(WebVTT) ||
|
||||||
softSub.SubtitleFormat?.GetType() == typeof(WebVTTFileWithLineNumber))
|
softSub.SubtitleFormat?.GetType() == typeof(WebVTTFileWithLineNumber))
|
||||||
{
|
{
|
||||||
subsFormat += $" -c:s:s:{count - 1} webvtt";
|
subsFormat += $" -c:s:s:{number} webvtt";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
|
number++;
|
||||||
}
|
}
|
||||||
|
|
||||||
subsInput = " " + subsInput.Trim();
|
subsInput = " " + subsInput.Trim();
|
||||||
@ -384,7 +385,7 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
StartInfo =
|
StartInfo =
|
||||||
{
|
{
|
||||||
FileName = GetFfmpegLocation(),
|
FileName = GetFfmpegLocation(),
|
||||||
Arguments = $"-i \"{inputVideoFileName}\"{subsInput} -map 0:v -map 0:a{subsMap} -c:v copy -c:a copy{subsFormat}{subsMeta} \"{outputVideoFileName}\"".TrimStart(),
|
Arguments = $"-i \"{inputVideoFileName}\"{subsInput} -map 0 -c copy{subsMap}{subsFormat}{subsMeta} \"{outputVideoFileName}\"".TrimStart(),
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user