Allow resize when burning video w assa subs - thx Leon :)

This commit is contained in:
niksedk 2021-09-11 20:04:04 +02:00
parent af54f3aa38
commit 11af12ebb6
2 changed files with 41 additions and 3 deletions

View File

@ -16,12 +16,16 @@
* Add more settings for "Generate video w burned-in subs" - thx Leon/David
* Improve SSA styling/preview - thxfiolek2000
* Allow .ismt files up to 50 mb - thx Essam3152
* Allow some malformed WebVTT - thx manuelrn/larsk2
* Make BD Sup configuable regarding open action - ocr/edit - thx peter-qgd
* FIXED:
* Fix "Title bar text" when translating - thx Andrebavila
* Fix culture name for French translation - thx jpsdr
* Fix waveform multiple select error - thx darbor87
* Fix issue with "Merge short lines" in "batch convert" - thx fhtdtdj
* Fix waveform multiple select crash - thx darbor87
* Fix broken "Duplicate line" shortcut - thx Kelvets/OmrSi
* Fix crash in reading .ismt - thx DarkHorse-APP2
3.6.2 (24th August 2021)

View File

@ -14,7 +14,7 @@ namespace Nikse.SubtitleEdit.Forms
public sealed partial class GenerateVideoWithHardSubs : Form
{
private bool _abort;
private readonly Subtitle _assaSubtitle;
private Subtitle _assaSubtitle;
private readonly VideoInfo _videoInfo;
private readonly string _inputVideoFileName;
private static readonly Regex FrameFinderRegex = new Regex(@"[Ff]rame=\s*\d+", RegexOptions.Compiled);
@ -97,8 +97,6 @@ namespace Nikse.SubtitleEdit.Forms
{
numericUpDownFontSize.Visible = false;
labelFontSize.Visible = false;
numericUpDownWidth.Enabled = false;
numericUpDownHeight.Enabled = false;
labelInfo.Text = LanguageSettings.Current.GenerateVideoWithBurnedInSubs.InfoAssaOn;
}
@ -180,6 +178,42 @@ namespace Nikse.SubtitleEdit.Forms
var styleLine = style.ToRawAss();
_assaSubtitle.Header = AdvancedSubStationAlpha.AddTagToHeader("Style", styleLine, "[V4+ Styles]", _assaSubtitle.Header);
}
else
{
_assaSubtitle = new Subtitle(_assaSubtitle);
if (numericUpDownWidth.Value != _videoInfo.Width || numericUpDownHeight.Value != _videoInfo.Height)
{
var sourceWidth = _videoInfo.Width;
var sourceHeight = _videoInfo.Height;
var targetWidth = numericUpDownWidth.Value;
var targetHeight = numericUpDownHeight.Value;
var styles = AdvancedSubStationAlpha.GetSsaStylesFromHeader(_assaSubtitle.Header);
foreach (var style in styles)
{
style.MarginLeft = AssaResampler.Resample(sourceWidth, targetWidth, style.MarginLeft);
style.MarginRight = AssaResampler.Resample(sourceWidth, targetWidth, style.MarginRight);
style.MarginVertical = AssaResampler.Resample(sourceHeight, targetHeight, style.MarginVertical);
style.FontSize = AssaResampler.Resample(sourceHeight, targetHeight, style.FontSize);
style.OutlineWidth = (decimal)AssaResampler.Resample(sourceHeight, targetHeight, (float)style.OutlineWidth);
style.ShadowWidth = (decimal)AssaResampler.Resample(sourceHeight, targetHeight, (float)style.ShadowWidth);
style.Spacing = (decimal)AssaResampler.Resample(sourceWidth, targetWidth, (float)style.Spacing);
}
_assaSubtitle.Header = AdvancedSubStationAlpha.GetHeaderAndStylesFromAdvancedSubStationAlpha(_assaSubtitle.Header, styles);
_assaSubtitle.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResX", "PlayResX: " + targetWidth.ToString(CultureInfo.InvariantCulture), "[Script Info]", _assaSubtitle.Header);
_assaSubtitle.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResY", "PlayResY: " + targetHeight.ToString(CultureInfo.InvariantCulture), "[Script Info]", _assaSubtitle.Header);
foreach (var p in _assaSubtitle.Paragraphs)
{
p.Text = AssaResampler.ResampleOverrideTagsFont(sourceWidth, targetWidth, sourceHeight, targetHeight, p.Text);
p.Text = AssaResampler.ResampleOverrideTagsPosition(sourceWidth, targetWidth, sourceHeight, targetHeight, p.Text);
p.Text = AssaResampler.ResampleOverrideTagsDrawing(sourceWidth, targetWidth, sourceHeight, targetHeight, p.Text, null);
}
}
}
if (Configuration.Settings.General.RightToLeftMode && LanguageAutoDetect.CouldBeRightToLeftLanguage(_assaSubtitle))
{