Remember scene changes

This commit is contained in:
Nikolaj Olsson 2016-08-04 22:41:37 +02:00
parent 0433598025
commit 6a0cb5bdf4
3 changed files with 58 additions and 0 deletions

View File

@ -180,6 +180,7 @@
<Compile Include="RealFFT.cs" />
<Compile Include="RegistryUtil.cs" />
<Compile Include="RichTextToPlainText.cs" />
<Compile Include="SceneChangeHelper.cs" />
<Compile Include="Settings.cs" />
<Compile Include="Interfaces\IDoSpell.cs" />
<Compile Include="SpellCheck\SpellCheckWord.cs" />

View File

@ -0,0 +1,52 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
namespace Nikse.SubtitleEdit.Core
{
public static class SceneChangeHelper
{
public static string GetSceneChangesFileName(string videoFileName)
{
var fileName = WavePeakGenerator.GetPeakWaveFileName(videoFileName);
return Path.GetFileNameWithoutExtension(fileName) + ".scenechanges";
}
public static List<double> FromDisk(string videoFileName)
{
var list = new List<double>();
var sceneChangesFileName = GetSceneChangesFileName(videoFileName);
if (!File.Exists(sceneChangesFileName))
return list;
foreach (var line in File.ReadLines(sceneChangesFileName))
{
if (!string.IsNullOrWhiteSpace(line))
{
list.Add(double.Parse(line, CultureInfo.InvariantCulture));
}
}
return list;
}
public static void SaveSceneChangesInSeconds(string videoFileName, List<double> list)
{
var sb = new StringBuilder();
foreach (var d in list)
{
sb.AppendLine(d.ToString(CultureInfo.InvariantCulture));
}
File.WriteAllText(GetSceneChangesFileName(videoFileName), sb.ToString().Trim());
}
public static void DeleteSceneChangesInSeconds(string videoFileName)
{
var sceneChangesFileName = GetSceneChangesFileName(videoFileName);
if (File.Exists(sceneChangesFileName))
File.Delete(sceneChangesFileName);
}
}
}

View File

@ -13183,6 +13183,7 @@ namespace Nikse.SubtitleEdit.Forms
{
audioVisualizer.WavePeaks = WavePeakData.FromDisk(peakWaveFileName);
audioVisualizer.Spectrogram = SpectrogramData.FromDisk(spectrogramFolder);
audioVisualizer.SceneChanges = SceneChangeHelper.FromDisk(_videoFileName);
toolStripComboBoxWaveform_SelectedIndexChanged(null, null);
SetWaveformPosition(0, 0, 0);
timerWaveform.Start();
@ -19668,6 +19669,7 @@ namespace Nikse.SubtitleEdit.Forms
if (form.ShowDialog(this) == DialogResult.OK)
{
audioVisualizer.SceneChanges = form.SceneChangesInSeconds;
SceneChangeHelper.SaveSceneChangesInSeconds(_videoFileName, audioVisualizer.SceneChanges);
ShowStatus(string.Format(_language.XSceneChangesImported, form.SceneChangesInSeconds.Count));
}
}
@ -19676,7 +19678,10 @@ namespace Nikse.SubtitleEdit.Forms
private void toolStripMenuItemRemoveSceneChanges_Click(object sender, EventArgs e)
{
if (audioVisualizer != null && audioVisualizer.SceneChanges != null)
{
audioVisualizer.SceneChanges = new List<double>();
SceneChangeHelper.DeleteSceneChangesInSeconds(_videoFileName);
}
}
private void toolStripMenuItemDurationBridgeGaps_Click(object sender, EventArgs e)