Change ffprope location to ffmpeg folder

This commit is contained in:
niksedk 2023-07-16 18:35:04 +02:00
parent ff3f40ba48
commit 72a9e50be3
8 changed files with 48 additions and 40 deletions

View File

@ -23,5 +23,6 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=assa/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Downloader/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ffprobe/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Matroska/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Nikse/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -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;
}
}
}

View File

@ -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();
}
@ -273,7 +284,7 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
checkBoxExtractExactTimeCodes.Checked ? _timeCodes : new List<double>(), // ditto
checkBoxSnapToShotChanges.Checked ? _shotChanges : new List<double>()
);
timeCodesBeautifier.ProgressChanged += delegate(double progress)
timeCodesBeautifier.ProgressChanged += delegate (double progress)
{
progressBar.Value = Convert.ToInt32(progress * 100);
Application.DoEvents();

View File

@ -1,7 +1,7 @@

namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
{
partial class BeautifyTimeCodesProfile
sealed partial class BeautifyTimeCodesProfile
{
/// <summary>
/// Required designer variable.

View File

@ -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;

View File

@ -1,6 +1,6 @@
namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
{
partial class BeautifyTimeCodesProfileSimple
sealed partial class BeautifyTimeCodesProfileSimple
{
/// <summary>
/// Required designer variable.

View File

@ -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;

View File

@ -36,8 +36,9 @@ namespace Nikse.SubtitleEdit.Logic
{
_timeCodes = new List<double>();
}
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";
}