mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-28 15:02:35 +01:00
parent
eca3fafe96
commit
4f5209b5c1
@ -30,7 +30,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
public string VideoFileName { get; private set; }
|
||||
public long MillisecondsEncoding { get; private set; }
|
||||
|
||||
public GenerateVideoWithHardSubs(Subtitle assaSubtitle, string inputVideoFileName, VideoInfo videoInfo, int? fontSize)
|
||||
public GenerateVideoWithHardSubs(Subtitle assaSubtitle, string inputVideoFileName, VideoInfo videoInfo, int? fontSize, bool setStartEndCut)
|
||||
{
|
||||
UiUtil.PreInitialize(this);
|
||||
InitializeComponent();
|
||||
@ -197,6 +197,28 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
numericUpDownCutToHours.Value = timeSpan.Hours;
|
||||
numericUpDownCutToMinutes.Value = timeSpan.Minutes;
|
||||
numericUpDownCutToSeconds.Value = timeSpan.Seconds;
|
||||
|
||||
if (setStartEndCut && assaSubtitle != null && assaSubtitle.Paragraphs.Count > 0 &&
|
||||
!assaSubtitle.Paragraphs.First().StartTime.IsMaxTime &&
|
||||
!assaSubtitle.Paragraphs.Last().EndTime.IsMaxTime)
|
||||
{
|
||||
timeSpan = assaSubtitle.Paragraphs.First().StartTime.TimeSpan;
|
||||
numericUpDownCutFromHours.Value = timeSpan.Hours;
|
||||
numericUpDownCutFromMinutes.Value = timeSpan.Minutes;
|
||||
numericUpDownCutFromSeconds.Value = timeSpan.Seconds;
|
||||
|
||||
timeSpan = assaSubtitle.Paragraphs.Last().EndTime.TimeSpan;
|
||||
if (timeSpan.Milliseconds > 0)
|
||||
{
|
||||
timeSpan = timeSpan.Add(TimeSpan.FromSeconds(1));
|
||||
}
|
||||
numericUpDownCutToHours.Value = timeSpan.Hours;
|
||||
numericUpDownCutToMinutes.Value = timeSpan.Minutes;
|
||||
numericUpDownCutToSeconds.Value = timeSpan.Seconds;
|
||||
|
||||
checkBoxCut.Checked = true;
|
||||
}
|
||||
|
||||
checkBoxCut_CheckedChanged(null, null);
|
||||
}
|
||||
else
|
||||
|
@ -8580,6 +8580,52 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
toolStripMenuItemSelectedLines.DropDownItems.RemoveAt(0);
|
||||
}
|
||||
|
||||
var selectLinesBurnIn = new ToolStripMenuItem(_language.Menu.Video.GenerateVideoWithBurnedInSub);
|
||||
UiUtil.FixFonts(selectLinesBurnIn);
|
||||
selectLinesBurnIn.Tag = "(REMOVE)";
|
||||
if (SubtitleListview1.SelectedItems.Count > 0 && !string.IsNullOrEmpty(_videoFileName) &&
|
||||
_videoInfo != null && _videoInfo.Width > 0)
|
||||
{
|
||||
toolStripMenuItemSelectedLines.DropDownItems.Insert(0, selectLinesBurnIn);
|
||||
selectLinesBurnIn.Click += (senderNew, eNew) =>
|
||||
{
|
||||
if (VideoFileNameIsUrl)
|
||||
{
|
||||
MessageBox.Show(LanguageSettings.Current.General.OnlineVideoFeatureNotAvailable);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(_videoFileName) || _videoInfo == null || _videoInfo.Width == 0 || _videoInfo.Height == 0)
|
||||
{
|
||||
MessageBox.Show(LanguageSettings.Current.General.NoVideoLoaded);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!RequireFfmpegOk())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var sub = new Subtitle(_subtitle, false);
|
||||
var fontSize = PrepareBurn(sub);
|
||||
|
||||
using (var form = new GenerateVideoWithHardSubs(sub, _videoFileName, _videoInfo, fontSize, true))
|
||||
{
|
||||
var result = form.ShowDialog(this);
|
||||
if (result != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
f.ShowDialog(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var selectLinesMultipleReplace = new ToolStripMenuItem(LanguageSettings.Current.Main.Menu.Edit.MultipleReplace);
|
||||
UiUtil.FixFonts(selectLinesMultipleReplace);
|
||||
selectLinesMultipleReplace.Tag = "(REMOVE)";
|
||||
@ -33926,11 +33972,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void generateVideoWithHardcodedSubtitleToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_subtitle == null || _subtitle.Paragraphs.Count == 0)
|
||||
{
|
||||
MessageBox.Show(_language.NoSubtitlesFound);
|
||||
return;
|
||||
}
|
||||
//if (_subtitle == null || _subtitle.Paragraphs.Count == 0)
|
||||
//{
|
||||
// MessageBox.Show(_language.NoSubtitlesFound);
|
||||
// return;
|
||||
//}
|
||||
|
||||
if (VideoFileNameIsUrl)
|
||||
{
|
||||
@ -33950,6 +33996,26 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
var sub = new Subtitle(_subtitle, false);
|
||||
var fontSize = PrepareBurn(sub);
|
||||
|
||||
using (var form = new GenerateVideoWithHardSubs(sub, _videoFileName, _videoInfo, fontSize, false))
|
||||
{
|
||||
var result = form.ShowDialog(this);
|
||||
if (result != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
f.ShowDialog(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int? PrepareBurn(Subtitle sub)
|
||||
{
|
||||
int? fontSize = null;
|
||||
if (string.IsNullOrEmpty(sub.Header) || !IsAssa())
|
||||
{
|
||||
@ -33967,20 +34033,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
sub.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResY", "PlayResY: " + _videoInfo.Height.ToString(CultureInfo.InvariantCulture), "[Script Info]", sub.Header);
|
||||
}
|
||||
|
||||
using (var form = new GenerateVideoWithHardSubs(sub, _videoFileName, _videoInfo, fontSize))
|
||||
{
|
||||
var result = form.ShowDialog(this);
|
||||
if (result != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
f.ShowDialog(this);
|
||||
}
|
||||
}
|
||||
return fontSize;
|
||||
}
|
||||
|
||||
private int GetOptimalSubtitleFontSize(int height)
|
||||
|
Loading…
Reference in New Issue
Block a user