mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Do not change PlayRes if exists when burn-in subs - thx MMT Gouenji - Tech :)
See https://www.nikse.dk/posts/Subtitle_Edit_3-6-6
This commit is contained in:
parent
b8872ad712
commit
9d84dbdd69
@ -171,6 +171,9 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
|
|
||||||
checkBoxRightToLeft.Checked = Configuration.Settings.General.RightToLeftMode && LanguageAutoDetect.CouldBeRightToLeftLanguage(_assaSubtitle);
|
checkBoxRightToLeft.Checked = Configuration.Settings.General.RightToLeftMode && LanguageAutoDetect.CouldBeRightToLeftLanguage(_assaSubtitle);
|
||||||
textBoxLog.Visible = false;
|
textBoxLog.Visible = false;
|
||||||
|
|
||||||
|
UiUtil.FixLargeFonts(this, buttonOK);
|
||||||
|
UiUtil.FixFonts(this, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonCancel_Click(object sender, EventArgs e)
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
@ -261,14 +264,13 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
FixRightToLeft(_assaSubtitle);
|
FixRightToLeft(_assaSubtitle);
|
||||||
|
|
||||||
var format = new AdvancedSubStationAlpha();
|
var format = new AdvancedSubStationAlpha();
|
||||||
var assaTempFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".ass");
|
var assaTempFileName = GetAssaFileName(_inputVideoFileName);
|
||||||
File.WriteAllText(assaTempFileName, format.ToText(_assaSubtitle, null));
|
FileUtil.WriteAllText(assaTempFileName, format.ToText(_assaSubtitle, null), new TextEncoding(Encoding.UTF8, "UTF8"));
|
||||||
|
|
||||||
groupBoxSettings.Enabled = false;
|
groupBoxSettings.Enabled = false;
|
||||||
labelPleaseWait.Visible = true;
|
labelPleaseWait.Visible = true;
|
||||||
if (_videoInfo.TotalFrames > 0)
|
if (_videoInfo.TotalFrames > 0)
|
||||||
{
|
{
|
||||||
progressBar1.Maximum = (int)_videoInfo.TotalFrames;
|
|
||||||
progressBar1.Visible = true;
|
progressBar1.Visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,6 +316,22 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetAssaFileName(string inputVideoFileName)
|
||||||
|
{
|
||||||
|
var path = Path.GetDirectoryName(inputVideoFileName);
|
||||||
|
for (var i =0; i< int.MaxValue; i++)
|
||||||
|
{
|
||||||
|
var guidLetters = Guid.NewGuid().ToString().RemoveChar('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-');
|
||||||
|
var fileName = Path.Combine(path, $"{guidLetters}.ass");
|
||||||
|
if (!File.Exists(fileName))
|
||||||
|
{
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Path.Combine(path, "qwerty12.ass");
|
||||||
|
}
|
||||||
|
|
||||||
private string SuggestNewVideoFileName()
|
private string SuggestNewVideoFileName()
|
||||||
{
|
{
|
||||||
var fileName = Path.GetFileNameWithoutExtension(_inputVideoFileName);
|
var fileName = Path.GetFileNameWithoutExtension(_inputVideoFileName);
|
||||||
@ -385,10 +403,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
var v = (int)_processedFrames;
|
var v = (int)_processedFrames;
|
||||||
if (v >= progressBar1.Minimum && v <= progressBar1.Maximum)
|
SetProgress(v);
|
||||||
{
|
|
||||||
progressBar1.Value = v;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -412,11 +427,22 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
var v = (int)_processedFrames;
|
var v = (int)_processedFrames;
|
||||||
if (v >= progressBar1.Minimum && v <= progressBar1.Maximum)
|
SetProgress(v);
|
||||||
{
|
|
||||||
progressBar1.Value = v;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetProgress(int v)
|
||||||
|
{
|
||||||
|
if (_totalFrames == 0)
|
||||||
|
{
|
||||||
|
progressBar1.Value = progressBar1.Maximum;
|
||||||
|
}
|
||||||
|
|
||||||
|
var pct = Math.Min(progressBar1.Maximum, (int)Math.Round(v * 100.0 / _totalFrames, MidpointRounding.AwayFromZero));
|
||||||
|
if (pct >= progressBar1.Minimum && pct <= progressBar1.Maximum && _totalFrames > 0)
|
||||||
|
{
|
||||||
|
progressBar1.Value = pct;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetAudioFileSizeInMb()
|
private int GetAudioFileSizeInMb()
|
||||||
@ -473,18 +499,15 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
|
|
||||||
while (!process.HasExited)
|
while (!process.HasExited)
|
||||||
{
|
{
|
||||||
System.Threading.Thread.Sleep(100);
|
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
|
System.Threading.Thread.Sleep(100);
|
||||||
if (_abort)
|
if (_abort)
|
||||||
{
|
{
|
||||||
process.Kill();
|
process.Kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
var v = (int)_processedFrames;
|
var v = (int)_processedFrames;
|
||||||
if (v >= progressBar1.Minimum && v <= progressBar1.Maximum)
|
SetProgress(v);
|
||||||
{
|
|
||||||
progressBar1.Value = v;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,7 +520,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
return VideoPreviewGenerator.GenerateHardcodedVideoFile(
|
return VideoPreviewGenerator.GenerateHardcodedVideoFile(
|
||||||
inputVideoFileName,
|
Path.GetFileName(inputVideoFileName),
|
||||||
assaTempFileName,
|
assaTempFileName,
|
||||||
outputVideoFileName,
|
outputVideoFileName,
|
||||||
(int)numericUpDownWidth.Value,
|
(int)numericUpDownWidth.Value,
|
||||||
@ -593,7 +616,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
log.AppendLine("Video info total frames: " + _videoInfo.TotalFrames);
|
log.AppendLine("Video info total frames: " + _videoInfo.TotalFrames);
|
||||||
log.AppendLine("Video info total seconds: " + _videoInfo.TotalSeconds);
|
log.AppendLine("Video info total seconds: " + _videoInfo.TotalSeconds);
|
||||||
log.AppendLine();
|
log.AppendLine();
|
||||||
log.AppendLine("ffmpeg " + GetFfmpegProcess(_inputVideoFileName, VideoFileName, "input.ass", null).StartInfo.Arguments);
|
log.AppendLine("ffmpeg " + GetFfmpegProcess(_inputVideoFileName, "output.mp4", "input.ass", null).StartInfo.Arguments);
|
||||||
textBoxLog.Text = log.ToString();
|
textBoxLog.Text = log.ToString();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -913,6 +936,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
var targetFileSizeMb = (int)Math.Round(new FileInfo(_inputVideoFileName).Length / 1024.0 / 1024);
|
var targetFileSizeMb = (int)Math.Round(new FileInfo(_inputVideoFileName).Length / 1024.0 / 1024);
|
||||||
numericUpDownTargetFileSize.Value = Math.Max(targetFileSizeMb, numericUpDownTargetFileSize.Minimum);
|
numericUpDownTargetFileSize.Value = Math.Max(targetFileSizeMb, numericUpDownTargetFileSize.Minimum);
|
||||||
_loading = false;
|
_loading = false;
|
||||||
|
UiUtil.FixFonts(groupBoxSettings, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBoxTargetFileSize_CheckedChanged(object sender, EventArgs e)
|
private void checkBoxTargetFileSize_CheckedChanged(object sender, EventArgs e)
|
||||||
@ -959,7 +983,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make temp assa file with font
|
// make temp assa file with font
|
||||||
var assaTempFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".ass");
|
var assaTempFileName = GetAssaFileName(tempVideoFileName);
|
||||||
var sub = new Subtitle();
|
var sub = new Subtitle();
|
||||||
sub.Header = _assaSubtitle.Header;
|
sub.Header = _assaSubtitle.Header;
|
||||||
sub.Paragraphs.Add(new Paragraph(GetPreviewParagraph()));
|
sub.Paragraphs.Add(new Paragraph(GetPreviewParagraph()));
|
||||||
@ -969,7 +993,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
SetStyleForNonAssa(sub);
|
SetStyleForNonAssa(sub);
|
||||||
}
|
}
|
||||||
FixRightToLeft(sub);
|
FixRightToLeft(sub);
|
||||||
File.WriteAllText(assaTempFileName, new AdvancedSubStationAlpha().ToText(sub, string.Empty));
|
FileUtil.WriteAllText(assaTempFileName, new AdvancedSubStationAlpha().ToText(sub, string.Empty), new TextEncoding(Encoding.UTF8, "UTF8"));
|
||||||
|
|
||||||
// hardcode subtitle
|
// hardcode subtitle
|
||||||
var outputVideoFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".mp4");
|
var outputVideoFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".mp4");
|
||||||
|
@ -33776,8 +33776,11 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
sub.Header = AdvancedSubStationAlpha.AddTagToHeader("Style", styleLine, "[V4+ Styles]", sub.Header);
|
sub.Header = AdvancedSubStationAlpha.AddTagToHeader("Style", styleLine, "[V4+ Styles]", sub.Header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!sub.Header.Contains("PlayResX:") || !sub.Header.Contains("PlayResY:"))
|
||||||
|
{
|
||||||
sub.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResX", "PlayResX: " + _videoInfo.Width.ToString(CultureInfo.InvariantCulture), "[Script Info]", sub.Header);
|
sub.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResX", "PlayResX: " + _videoInfo.Width.ToString(CultureInfo.InvariantCulture), "[Script Info]", sub.Header);
|
||||||
sub.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResY", "PlayResY: " + _videoInfo.Height.ToString(CultureInfo.InvariantCulture), "[Script Info]", sub.Header);
|
sub.Header = AdvancedSubStationAlpha.AddTagToHeader("PlayResY", "PlayResY: " + _videoInfo.Height.ToString(CultureInfo.InvariantCulture), "[Script Info]", sub.Header);
|
||||||
|
}
|
||||||
|
|
||||||
using (var form = new GenerateVideoWithHardSubs(sub, _videoFileName, _videoInfo, fontSize))
|
using (var form = new GenerateVideoWithHardSubs(sub, _videoFileName, _videoInfo, fontSize))
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Nikse.SubtitleEdit.Core.Common;
|
using Nikse.SubtitleEdit.Core.Common;
|
||||||
using Nikse.SubtitleEdit.Forms;
|
using Nikse.SubtitleEdit.Forms;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Specialized;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
@ -148,9 +149,7 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
};
|
};
|
||||||
|
|
||||||
processMakeVideo.StartInfo.Arguments = processMakeVideo.StartInfo.Arguments.Trim();
|
processMakeVideo.StartInfo.Arguments = processMakeVideo.StartInfo.Arguments.Trim();
|
||||||
|
|
||||||
SetupDataReceiveHandler(dataReceivedHandler, processMakeVideo);
|
SetupDataReceiveHandler(dataReceivedHandler, processMakeVideo);
|
||||||
|
|
||||||
return processMakeVideo;
|
return processMakeVideo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user