From 72a9e50be342156465cf217bed4b91f55264ba3a Mon Sep 17 00:00:00 2001 From: niksedk Date: Sun, 16 Jul 2023 18:35:04 +0200 Subject: [PATCH] Change ffprope location to ffmpeg folder --- SubtitleEdit.sln.DotSettings | 1 + src/ui/Controls/CuesPreviewView.cs | 43 ++++++++----------- .../BeautifyTimeCodes/BeautifyTimeCodes.cs | 31 ++++++++----- .../BeautifyTimeCodesProfile.Designer.cs | 2 +- .../BeautifyTimeCodesProfile.cs | 2 +- ...BeautifyTimeCodesProfileSimple.Designer.cs | 2 +- .../BeautifyTimeCodesProfileSimple.cs | 2 +- src/ui/Logic/TimeCodesGenerator.cs | 5 ++- 8 files changed, 48 insertions(+), 40 deletions(-) diff --git a/SubtitleEdit.sln.DotSettings b/SubtitleEdit.sln.DotSettings index fb114b125..ac54a4699 100644 --- a/SubtitleEdit.sln.DotSettings +++ b/SubtitleEdit.sln.DotSettings @@ -23,5 +23,6 @@ True True True + True True True \ No newline at end of file diff --git a/src/ui/Controls/CuesPreviewView.cs b/src/ui/Controls/CuesPreviewView.cs index 76bcc3115..5cddf4490 100644 --- a/src/ui/Controls/CuesPreviewView.cs +++ b/src/ui/Controls/CuesPreviewView.cs @@ -12,11 +12,11 @@ namespace Nikse.SubtitleEdit.Controls private string _previewText = "Subtitle text."; private bool _showShotChange = true; - private int _leftGap = 0; + private int _leftGap; private int _leftRedZone = 7; private int _leftGreenZone = 12; - private int _rightGap = 0; + private int _rightGap; private int _rightRedZone = 7; private int _rightGreenZone = 12; @@ -74,19 +74,14 @@ namespace Nikse.SubtitleEdit.Controls set { _rightGreenZone = value; Invalidate(); } } - public CuesPreviewView() - { - - } - protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); using (var brush = new SolidBrush(Color.White)) { - float width = this.Size.Width; - float height = this.Size.Height; + float width = Size.Width; + float height = Size.Height; // Background brush.Color = Color.Gray; @@ -94,31 +89,31 @@ namespace Nikse.SubtitleEdit.Controls // Green zones brush.Color = Color.Green; - e.Graphics.FillRectangle(brush, (width / 2) - FramesToPixels(this.LeftGreenZone), 0, FramesToPixels(this.LeftGreenZone), height); - e.Graphics.FillRectangle(brush, width / 2, 0, FramesToPixels(this.RightGreenZone), height); + e.Graphics.FillRectangle(brush, (width / 2) - FramesToPixels(LeftGreenZone), 0, FramesToPixels(LeftGreenZone), height); + e.Graphics.FillRectangle(brush, width / 2, 0, FramesToPixels(RightGreenZone), height); // Red zone brush.Color = Color.Firebrick; - e.Graphics.FillRectangle(brush, (width / 2) - FramesToPixels(this.LeftRedZone), 0, FramesToPixels(this.LeftRedZone), height); - e.Graphics.FillRectangle(brush, width / 2, 0, FramesToPixels(this.RightRedZone), height); + e.Graphics.FillRectangle(brush, (width / 2) - FramesToPixels(LeftRedZone), 0, FramesToPixels(LeftRedZone), height); + e.Graphics.FillRectangle(brush, width / 2, 0, FramesToPixels(RightRedZone), height); // Subtitle brush.Color = Color.FromArgb(153, 0, 0, 0); - e.Graphics.FillRectangle(brush, 0, 0, (width / 2) - FramesToPixels(this.LeftGap), height); - e.Graphics.FillRectangle(brush, (width / 2) + FramesToPixels(this.RightGap), 0, (width / 2) - FramesToPixels(this.RightGap), height); + e.Graphics.FillRectangle(brush, 0, 0, (width / 2) - FramesToPixels(LeftGap), height); + e.Graphics.FillRectangle(brush, (width / 2) + FramesToPixels(RightGap), 0, (width / 2) - FramesToPixels(RightGap), height); brush.Color = Color.White; - if (this.LeftGap <= 12) + if (LeftGap <= 12) { - e.Graphics.DrawString(GetSubtitleLabel(1000, GetLeftOutCue()), UiUtil.GetDefaultFont(), brush, new RectangleF(5, 5, (width / 2) - FramesToPixels(this.LeftGap) - 10, height - 10)); + e.Graphics.DrawString(GetSubtitleLabel(1000, GetLeftOutCue()), UiUtil.GetDefaultFont(), brush, new RectangleF(5, 5, (width / 2) - FramesToPixels(LeftGap) - 10, height - 10)); } - if (this.RightGap <= 12) + if (RightGap <= 12) { - e.Graphics.DrawString(GetSubtitleLabel(GetRightInCue(), 5000), UiUtil.GetDefaultFont(), brush, new RectangleF((width / 2) + FramesToPixels(this.RightGap) + 5, 5, (width / 2) - FramesToPixels(this.RightGap) - 10, height - 10)); + e.Graphics.DrawString(GetSubtitleLabel(GetRightInCue(), 5000), UiUtil.GetDefaultFont(), brush, new RectangleF((width / 2) + FramesToPixels(RightGap) + 5, 5, (width / 2) - FramesToPixels(RightGap) - 10, height - 10)); } // Shot change - if (this.ShowShotChange) + if (ShowShotChange) { brush.Color = Color.PaleGreen; e.Graphics.FillRectangle(brush, (width / 2) - (1.5f), 0, 3f, height); @@ -128,24 +123,24 @@ namespace Nikse.SubtitleEdit.Controls private float FramesToPixels(float frames) { - return (Size.Width / (this.FrameRate * 3)) * frames; + return (Size.Width / (FrameRate * 3)) * frames; } private double GetLeftOutCue() { - return 3000 - (this.LeftGap * (1000 / this.FrameRate)); + return 3000 - (LeftGap * (1000 / FrameRate)); } private double GetRightInCue() { - return 3000 + (this.RightGap * (1000 / this.FrameRate)); + return 3000 + (RightGap * (1000 / FrameRate)); } private string GetSubtitleLabel(double start, double end) { var timeCodeStart = new TimeCode(start); var timeCodeEnd = new TimeCode(end); - return timeCodeStart.ToString() + " --> " + timeCodeEnd.ToString() + Environment.NewLine + this.PreviewText; + return timeCodeStart + " --> " + timeCodeEnd + Environment.NewLine + PreviewText; } } } \ No newline at end of file diff --git a/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodes.cs b/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodes.cs index f9ee86a95..a871a1288 100644 --- a/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodes.cs +++ b/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodes.cs @@ -10,7 +10,7 @@ using Nikse.SubtitleEdit.Logic; namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes { - public partial class BeautifyTimeCodes : Form + public sealed partial class BeautifyTimeCodes : Form { private readonly Subtitle _subtitle; private readonly VideoInfo _videoInfo; @@ -80,13 +80,24 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes if (_videoFileName != null) { // Load time codes - this._timeCodes = TimeCodesFileHelper.FromDisk(videoFileName); - this._shotChanges = shotChanges; + _timeCodes = TimeCodesFileHelper.FromDisk(videoFileName); + _shotChanges = shotChanges; // Check if ffprobe is available - var ffProbePath = Path.GetDirectoryName(Configuration.Settings.General.FFmpegLocation) + Path.DirectorySeparatorChar + "ffprobe" + Path.GetExtension(Configuration.Settings.General.FFmpegLocation); - var isffProbeAvailable = !string.IsNullOrEmpty(ffProbePath) && File.Exists(ffProbePath); - if (!isffProbeAvailable) + var isFfProbeAvailable = false; + if (!string.IsNullOrEmpty(Configuration.Settings.General.FFmpegLocation)) + { + var ffProbePath = Path.Combine(Path.GetDirectoryName(Configuration.Settings.General.FFmpegLocation), "ffprobe.exe"); + if (Configuration.IsRunningOnWindows) + { + isFfProbeAvailable = File.Exists(ffProbePath); + } + else + { + isFfProbeAvailable = true; + } + } + if (!isFfProbeAvailable) { checkBoxExtractExactTimeCodes.Enabled = false; checkBoxExtractExactTimeCodes.Checked = false; @@ -234,8 +245,8 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes { if (form.ShowDialog(this) == DialogResult.OK) { - this._shotChanges = form.ShotChangesInSeconds; - this.ShotChangesInSeconds = form.ShotChangesInSeconds; + _shotChanges = form.ShotChangesInSeconds; + ShotChangesInSeconds = form.ShotChangesInSeconds; ShotChangeHelper.SaveShotChanges(_videoFileName, form.ShotChangesInSeconds); RefreshControls(); } @@ -268,12 +279,12 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes FixedSubtitle = new Subtitle(_subtitle); TimeCodesBeautifier timeCodesBeautifier = new TimeCodesBeautifier( - FixedSubtitle, + FixedSubtitle, _frameRate, checkBoxExtractExactTimeCodes.Checked ? _timeCodes : new List(), // ditto checkBoxSnapToShotChanges.Checked ? _shotChanges : new List() ); - timeCodesBeautifier.ProgressChanged += delegate(double progress) + timeCodesBeautifier.ProgressChanged += delegate (double progress) { progressBar.Value = Convert.ToInt32(progress * 100); Application.DoEvents(); diff --git a/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfile.Designer.cs b/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfile.Designer.cs index a4b32f9e2..b441b410f 100644 --- a/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfile.Designer.cs +++ b/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfile.Designer.cs @@ -1,7 +1,7 @@  namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes { - partial class BeautifyTimeCodesProfile + sealed partial class BeautifyTimeCodesProfile { /// /// Required designer variable. diff --git a/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfile.cs b/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfile.cs index 382cd979f..a8a5a7693 100644 --- a/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfile.cs +++ b/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfile.cs @@ -5,7 +5,7 @@ using Nikse.SubtitleEdit.Logic; namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes { - public partial class BeautifyTimeCodesProfile : Form + public sealed partial class BeautifyTimeCodesProfile : Form { private readonly double _frameRate; diff --git a/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfileSimple.Designer.cs b/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfileSimple.Designer.cs index 45d71fb77..80105f1b2 100644 --- a/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfileSimple.Designer.cs +++ b/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfileSimple.Designer.cs @@ -1,6 +1,6 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes { - partial class BeautifyTimeCodesProfileSimple + sealed partial class BeautifyTimeCodesProfileSimple { /// /// Required designer variable. diff --git a/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfileSimple.cs b/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfileSimple.cs index 2b65c2d02..7f9ce0375 100644 --- a/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfileSimple.cs +++ b/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfileSimple.cs @@ -7,7 +7,7 @@ using Nikse.SubtitleEdit.Core.SubtitleFormats; namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes { - public partial class BeautifyTimeCodesProfileSimple : Form + public sealed partial class BeautifyTimeCodesProfileSimple : Form { private readonly double _frameRate; diff --git a/src/ui/Logic/TimeCodesGenerator.cs b/src/ui/Logic/TimeCodesGenerator.cs index 93a52da31..e60e7017a 100644 --- a/src/ui/Logic/TimeCodesGenerator.cs +++ b/src/ui/Logic/TimeCodesGenerator.cs @@ -36,8 +36,9 @@ namespace Nikse.SubtitleEdit.Logic { _timeCodes = new List(); } - var ffProbePath = Path.GetDirectoryName(Configuration.Settings.General.FFmpegLocation) + Path.DirectorySeparatorChar + "ffprobe" + Path.GetExtension(Configuration.Settings.General.FFmpegLocation); - if (!Configuration.IsRunningOnWindows && (string.IsNullOrEmpty(ffProbePath) || !File.Exists(ffProbePath))) + + var ffProbePath = Path.Combine(Path.GetDirectoryName(Configuration.Settings.General.FFmpegLocation), "ffprobe.exe"); + if (!Configuration.IsRunningOnWindows && !File.Exists(ffProbePath)) { ffProbePath = "ffprobe"; }