mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Work on #6725
This commit is contained in:
parent
66e3903536
commit
34862e4d2d
@ -882,6 +882,14 @@ Read more info (web)?</WhisperNotFound>
|
||||
<GetStartPosition>Get start position</GetStartPosition>
|
||||
<GetEndPosition>Get end position</GetEndPosition>
|
||||
</GenerateVideoWithBurnedInSubs>
|
||||
<GenerateVideoWithEmbeddedSubs>
|
||||
<Title>Generate video with embedded subtitles</Title>
|
||||
<InputVideoFile>Input video file</InputVideoFile>
|
||||
<SetLanguage>Set language...</SetLanguage>
|
||||
<ToggleForced>Toggle forced</ToggleForced>
|
||||
<ToggleDefault>Toggle default</ToggleDefault>
|
||||
<XGeneratedWithEmbeddedSubs>"{0}" generated with embedded subtitles</XGeneratedWithEmbeddedSubs>
|
||||
</GenerateVideoWithEmbeddedSubs>
|
||||
<GetDictionaries>
|
||||
<Title>Need dictionaries?</Title>
|
||||
<DescriptionLine1>Subtitle Edit's spell check is based on the NHunspell engine which</DescriptionLine1>
|
||||
@ -1283,7 +1291,7 @@ To use an API key, go to "Options -> Settings -> Tools" to enter your Goog
|
||||
<GenerateTextFromVideo>Generate text from video...</GenerateTextFromVideo>
|
||||
<GenerateBlankVideo>Generate blank video...</GenerateBlankVideo>
|
||||
<GenerateVideoWithBurnedInSub>Generate video with burned-in subtitle...</GenerateVideoWithBurnedInSub>
|
||||
<GenerateVideoWithEmbeddedSub>Generate video with embedded subtitles...</GenerateVideoWithEmbeddedSub>
|
||||
<GenerateVideoWithEmbeddedSubs>Generate video with embedded subtitles...</GenerateVideoWithEmbeddedSubs>
|
||||
<VideoAudioToTextX>Audio to text ({0})...</VideoAudioToTextX>
|
||||
<ImportChaptersFromVideo>Import chapters from video</ImportChaptersFromVideo>
|
||||
<GenerateImportShotChanges>Generate/import shot changes...</GenerateImportShotChanges>
|
||||
|
@ -8,6 +8,8 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
public static class SeLogger
|
||||
{
|
||||
|
||||
public static string ErrorFile => Path.Combine(Configuration.DataDirectory, "error_log.txt");
|
||||
|
||||
public static void Error(Exception exception, string message = null)
|
||||
{
|
||||
if (exception == null)
|
||||
@ -17,8 +19,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
|
||||
try
|
||||
{
|
||||
var filePath = Path.Combine(Configuration.DataDirectory, "error_log.txt");
|
||||
using (var writer = new StreamWriter(filePath, true, Encoding.UTF8))
|
||||
using (var writer = new StreamWriter(ErrorFile, true, Encoding.UTF8))
|
||||
{
|
||||
writer.WriteLine("-----------------------------------------------------------------------------");
|
||||
writer.WriteLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}");
|
||||
|
@ -418,6 +418,10 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
public bool GenVideoNonAssaBox { get; set; }
|
||||
public bool GenVideoNonAssaAlignRight { get; set; }
|
||||
public bool GenVideoNonAssaFixRtlUnicode { get; set; }
|
||||
|
||||
public string GenVideoEmbedOutputExt { get; set; }
|
||||
|
||||
|
||||
public bool VoskPostProcessing { get; set; }
|
||||
public string VoskModel { get; set; }
|
||||
public string WhisperChoice { get; set; }
|
||||
@ -6249,6 +6253,12 @@ $HorzAlign = Center
|
||||
settings.Tools.GenVideoNonAssaFixRtlUnicode = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("GenVideoEmbedOutputExt");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Tools.GenVideoEmbedOutputExt = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("VoskPostProcessing");
|
||||
if (subNode != null)
|
||||
{
|
||||
@ -10612,6 +10622,7 @@ $HorzAlign = Center
|
||||
textWriter.WriteElementString("GenVideoNonAssaBox", settings.Tools.GenVideoNonAssaBox.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("GenVideoNonAssaAlignRight", settings.Tools.GenVideoNonAssaAlignRight.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("GenVideoNonAssaFixRtlUnicode", settings.Tools.GenVideoNonAssaFixRtlUnicode.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("GenVideoEmbedOutputExt", settings.Tools.GenVideoEmbedOutputExt);
|
||||
textWriter.WriteElementString("VoskPostProcessing", settings.Tools.VoskPostProcessing.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("VoskModel", settings.Tools.VoskModel);
|
||||
textWriter.WriteElementString("WhisperChoice", settings.Tools.WhisperChoice);
|
||||
|
@ -1,5 +1,7 @@
|
||||
using Nikse.SubtitleEdit.Core.Common;
|
||||
using Nikse.SubtitleEdit.Core.SubtitleFormats;
|
||||
using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska;
|
||||
using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4;
|
||||
using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4.Boxes;
|
||||
using Nikse.SubtitleEdit.Logic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -10,9 +12,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska;
|
||||
using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4;
|
||||
using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4.Boxes;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
@ -36,9 +35,20 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
UiUtil.FixFonts(this);
|
||||
|
||||
_videoInfo = videoInfo;
|
||||
//TODO: Text = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.Title;
|
||||
_subtitle = new Subtitle(subtitle);
|
||||
_inputVideoFileName = inputVideoFileName;
|
||||
|
||||
Text = LanguageSettings.Current.GenerateVideoWithEmbeddedSubs.Title;
|
||||
labelInputVideoFile.Text = LanguageSettings.Current.GenerateVideoWithEmbeddedSubs.InputVideoFile;
|
||||
|
||||
buttonAddSubtitles.Text = LanguageSettings.Current.DvdSubRip.Add;
|
||||
ButtonRemoveSubtitles.Text = LanguageSettings.Current.SubStationAlphaStyles.Remove;
|
||||
buttonClear.Text = LanguageSettings.Current.SubStationAlphaStyles.RemoveAll;
|
||||
ButtonMoveSubUp.Text = LanguageSettings.Current.DvdSubRip.MoveUp;
|
||||
ButtonMoveSubDown.Text = LanguageSettings.Current.DvdSubRip.MoveDown;
|
||||
buttonToggleForced.Text = LanguageSettings.Current.GenerateVideoWithEmbeddedSubs.ToggleForced;
|
||||
buttonSetDefault.Text = LanguageSettings.Current.GenerateVideoWithEmbeddedSubs.ToggleDefault;
|
||||
buttonSetLanguage.Text = LanguageSettings.Current.GenerateVideoWithEmbeddedSubs.SetLanguage;
|
||||
buttonGenerate.Text = LanguageSettings.Current.Watermark.Generate;
|
||||
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
|
||||
|
||||
@ -59,6 +69,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
var fileName = Path.Combine(dir, nameOnly);
|
||||
AddListViewItem(fileName);
|
||||
|
||||
if (listViewSubtitles.Items.Count > 0)
|
||||
{
|
||||
listViewSubtitles.Items[0].Selected = true;
|
||||
listViewSubtitles.Items[0].Focused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,7 +261,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
using (var saveDialog = new SaveFileDialog
|
||||
{
|
||||
FileName = SuggestNewVideoFileName(),
|
||||
Filter = "Matroska|*.mkv|WebM|*.webm|MP4|*.mp4",
|
||||
Filter = GetTargetVideoFilter(),
|
||||
AddExtension = true
|
||||
})
|
||||
{
|
||||
@ -276,6 +292,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_log.AppendLine("Target file name: " + VideoFileName);
|
||||
|
||||
groupBoxSettings.Enabled = false;
|
||||
buttonGenerate.Enabled = false;
|
||||
|
||||
var stopWatch = Stopwatch.StartNew();
|
||||
|
||||
@ -292,9 +309,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (!File.Exists(VideoFileName) || new FileInfo(VideoFileName).Length == 0)
|
||||
{
|
||||
SeLogger.Error(Environment.NewLine + "Generate hard subbed video failed: " + Environment.NewLine + _log);
|
||||
MessageBox.Show("Test");
|
||||
//DialogResult = DialogResult.Cancel;
|
||||
SeLogger.Error(Environment.NewLine + "Generate embedded video failed: " + Environment.NewLine + _log);
|
||||
MessageBox.Show("Generate embedded video failed" + Environment.NewLine +
|
||||
"For more info see the error log: " + SeLogger.ErrorFile);
|
||||
buttonGenerate.Enabled = true;
|
||||
groupBoxSettings.Enabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -304,6 +323,21 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetTargetVideoFilter()
|
||||
{
|
||||
if (Configuration.Settings.Tools.GenVideoEmbedOutputExt == ".mp4")
|
||||
{
|
||||
return "MP4|*.mp4|Matroska|*.mkv|WebM|*.webm";
|
||||
}
|
||||
|
||||
if (Configuration.Settings.Tools.GenVideoEmbedOutputExt == ".webm")
|
||||
{
|
||||
return "WebM|*.webm|Matroska|*.mkv|MP4|*.mp4";
|
||||
}
|
||||
|
||||
return "Matroska|*.mkv|WebM|*.webm|MP4|*.mp4";
|
||||
}
|
||||
|
||||
private string SuggestNewVideoFileName()
|
||||
{
|
||||
var fileName = Path.GetFileNameWithoutExtension(_inputVideoFileName);
|
||||
@ -392,7 +426,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void GenerateVideoWithHardSubs_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
//Configuration.Settings.Tools.GenVideoFontName = comboBoxSubtitleFont.Text;
|
||||
if (!string.IsNullOrEmpty(VideoFileName))
|
||||
{
|
||||
Configuration.Settings.Tools.GenVideoEmbedOutputExt = Path.GetExtension(VideoFileName).ToLowerInvariant();
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateVideoWithHardSubs_Shown(object sender, EventArgs e)
|
||||
|
@ -1757,6 +1757,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
openSecondSubtitleToolStripMenuItem.Text = _language.Menu.Video.OpenSecondSubtitle;
|
||||
generateBlankVideoToolStripMenuItem.Text = _language.Menu.Video.GenerateBlankVideo;
|
||||
generateVideoWithHardcodedSubtitleToolStripMenuItem.Text = _language.Menu.Video.GenerateVideoWithBurnedInSub;
|
||||
generateVideoWithHardcodedSubtitleToolStripMenuItem.Text = _language.Menu.Video.GenerateVideoWithEmbeddedSubs;
|
||||
videoaudioToTextToolStripMenuItem.Text = string.Format(_language.Menu.Video.VideoAudioToTextX, "Vosk/Kaldi");
|
||||
audioToTextWhisperTolStripMenuItem.Text = string.Format(_language.Menu.Video.VideoAudioToTextX, "Whisper");
|
||||
|
||||
@ -34649,7 +34650,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
var encodingTime = new TimeCode(form.MillisecondsEncoding).ToString();
|
||||
using (var f = new ExportPngXmlDialogOpenFolder(string.Format(LanguageSettings.Current.GenerateVideoWithBurnedInSubs.XGeneratedWithBurnedInSubsInX, Path.GetFileName(form.VideoFileName), encodingTime), Path.GetDirectoryName(form.VideoFileName), form.VideoFileName))
|
||||
using (var f = new ExportPngXmlDialogOpenFolder(string.Format(LanguageSettings.Current.GenerateVideoWithEmbeddedSubs.XGeneratedWithEmbeddedSubs, Path.GetFileName(form.VideoFileName)), Path.GetDirectoryName(form.VideoFileName), form.VideoFileName))
|
||||
{
|
||||
f.ShowDialog(this);
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public LanguageStructure.FixCommonErrors FixCommonErrors;
|
||||
public LanguageStructure.GenerateBlankVideo GenerateBlankVideo;
|
||||
public LanguageStructure.GenerateVideoWithBurnedInSubs GenerateVideoWithBurnedInSubs;
|
||||
public LanguageStructure.GenerateVideoWithEmbeddedSubs GenerateVideoWithEmbeddedSubs;
|
||||
public LanguageStructure.GetDictionaries GetDictionaries;
|
||||
public LanguageStructure.GetTesseractDictionaries GetTesseractDictionaries;
|
||||
public LanguageStructure.GoogleTranslate GoogleTranslate;
|
||||
@ -1110,6 +1111,16 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
GetEndPosition = "Get end position",
|
||||
};
|
||||
|
||||
GenerateVideoWithEmbeddedSubs = new LanguageStructure.GenerateVideoWithEmbeddedSubs
|
||||
{
|
||||
Title = "Generate video with embedded subtitles",
|
||||
InputVideoFile = "Input video file",
|
||||
ToggleForced = "Toggle forced",
|
||||
ToggleDefault = "Toggle default",
|
||||
SetLanguage = "Set language...",
|
||||
XGeneratedWithEmbeddedSubs = "\"{0}\" generated with embedded subtitles",
|
||||
};
|
||||
|
||||
GetDictionaries = new LanguageStructure.GetDictionaries
|
||||
{
|
||||
Title = "Need dictionaries?",
|
||||
@ -1827,7 +1838,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
SmptTimeMode = "SMPTE timing (non integer frame rate)",
|
||||
GenerateTextFromVideo = "Generate text from video...",
|
||||
GenerateBlankVideo = "Generate blank video...",
|
||||
GenerateVideoWithEmbeddedSub = "Generate video with embedded subtitles...",
|
||||
GenerateVideoWithEmbeddedSubs = "Generate video with embedded subtitles...",
|
||||
GenerateVideoWithBurnedInSub = "Generate video with burned-in subtitle...",
|
||||
VideoAudioToTextX = "Audio to text ({0})...",
|
||||
ImportChaptersFromVideo = "Import chapters from video",
|
||||
|
@ -2338,6 +2338,24 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
case "GenerateVideoWithBurnedInSubs/GetEndPosition":
|
||||
language.GenerateVideoWithBurnedInSubs.GetEndPosition = reader.Value;
|
||||
break;
|
||||
case "GenerateVideoWithEmbeddedSubs/Title":
|
||||
language.GenerateVideoWithEmbeddedSubs.Title = reader.Value;
|
||||
break;
|
||||
case "GenerateVideoWithEmbeddedSubs/InputVideoFile":
|
||||
language.GenerateVideoWithEmbeddedSubs.InputVideoFile = reader.Value;
|
||||
break;
|
||||
case "GenerateVideoWithEmbeddedSubs/SetLanguage":
|
||||
language.GenerateVideoWithEmbeddedSubs.SetLanguage = reader.Value;
|
||||
break;
|
||||
case "GenerateVideoWithEmbeddedSubs/ToggleForced":
|
||||
language.GenerateVideoWithEmbeddedSubs.ToggleForced = reader.Value;
|
||||
break;
|
||||
case "GenerateVideoWithEmbeddedSubs/ToggleDefault":
|
||||
language.GenerateVideoWithEmbeddedSubs.ToggleDefault = reader.Value;
|
||||
break;
|
||||
case "GenerateVideoWithEmbeddedSubs/XGeneratedWithEmbeddedSubs":
|
||||
language.GenerateVideoWithEmbeddedSubs.XGeneratedWithEmbeddedSubs = reader.Value;
|
||||
break;
|
||||
case "GetDictionaries/Title":
|
||||
language.GetDictionaries.Title = reader.Value;
|
||||
break;
|
||||
@ -4270,8 +4288,8 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
case "Main/Menu/Video/GenerateVideoWithBurnedInSub":
|
||||
language.Main.Menu.Video.GenerateVideoWithBurnedInSub = reader.Value;
|
||||
break;
|
||||
case "Main/Menu/Video/GenerateVideoWithEmbeddedSub":
|
||||
language.Main.Menu.Video.GenerateVideoWithEmbeddedSub = reader.Value;
|
||||
case "Main/Menu/Video/GenerateVideoWithEmbeddedSubs":
|
||||
language.Main.Menu.Video.GenerateVideoWithEmbeddedSubs = reader.Value;
|
||||
break;
|
||||
case "Main/Menu/Video/VideoAudioToTextX":
|
||||
language.Main.Menu.Video.VideoAudioToTextX = reader.Value;
|
||||
|
@ -970,6 +970,16 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public string GetEndPosition { get; set; }
|
||||
}
|
||||
|
||||
public class GenerateVideoWithEmbeddedSubs
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string InputVideoFile { get; set; }
|
||||
public string SetLanguage { get; set; }
|
||||
public string ToggleForced { get; set; }
|
||||
public string ToggleDefault { get; set; }
|
||||
public string XGeneratedWithEmbeddedSubs { get; set; }
|
||||
}
|
||||
|
||||
public class GetDictionaries
|
||||
{
|
||||
public string Title { get; set; }
|
||||
@ -1677,7 +1687,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public string GenerateTextFromVideo { get; set; }
|
||||
public string GenerateBlankVideo { get; set; }
|
||||
public string GenerateVideoWithBurnedInSub { get; set; }
|
||||
public string GenerateVideoWithEmbeddedSub { get; set; }
|
||||
public string GenerateVideoWithEmbeddedSubs { get; set; }
|
||||
public string VideoAudioToTextX { get; set; }
|
||||
public string ImportChaptersFromVideo { get; set; }
|
||||
public string GenerateImportShotChanges { get; set; }
|
||||
|
@ -336,6 +336,10 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
subsFormat += $" -c:s:s:{count - 1} ass";
|
||||
}
|
||||
else if (softSub.SubtitleFormat.GetType() == typeof(SubStationAlpha))
|
||||
{
|
||||
subsFormat += $" -c:s:s:{count - 1} ssa";
|
||||
}
|
||||
else if (softSub.SubtitleFormat.GetType() == typeof(WebVTT) ||
|
||||
softSub.SubtitleFormat.GetType() == typeof(WebVTTFileWithLineNumber))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user