mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Remember scene changes
This commit is contained in:
parent
0433598025
commit
6a0cb5bdf4
@ -180,6 +180,7 @@
|
|||||||
<Compile Include="RealFFT.cs" />
|
<Compile Include="RealFFT.cs" />
|
||||||
<Compile Include="RegistryUtil.cs" />
|
<Compile Include="RegistryUtil.cs" />
|
||||||
<Compile Include="RichTextToPlainText.cs" />
|
<Compile Include="RichTextToPlainText.cs" />
|
||||||
|
<Compile Include="SceneChangeHelper.cs" />
|
||||||
<Compile Include="Settings.cs" />
|
<Compile Include="Settings.cs" />
|
||||||
<Compile Include="Interfaces\IDoSpell.cs" />
|
<Compile Include="Interfaces\IDoSpell.cs" />
|
||||||
<Compile Include="SpellCheck\SpellCheckWord.cs" />
|
<Compile Include="SpellCheck\SpellCheckWord.cs" />
|
||||||
|
52
libse/SceneChangeHelper.cs
Normal file
52
libse/SceneChangeHelper.cs
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -13183,6 +13183,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
{
|
{
|
||||||
audioVisualizer.WavePeaks = WavePeakData.FromDisk(peakWaveFileName);
|
audioVisualizer.WavePeaks = WavePeakData.FromDisk(peakWaveFileName);
|
||||||
audioVisualizer.Spectrogram = SpectrogramData.FromDisk(spectrogramFolder);
|
audioVisualizer.Spectrogram = SpectrogramData.FromDisk(spectrogramFolder);
|
||||||
|
audioVisualizer.SceneChanges = SceneChangeHelper.FromDisk(_videoFileName);
|
||||||
toolStripComboBoxWaveform_SelectedIndexChanged(null, null);
|
toolStripComboBoxWaveform_SelectedIndexChanged(null, null);
|
||||||
SetWaveformPosition(0, 0, 0);
|
SetWaveformPosition(0, 0, 0);
|
||||||
timerWaveform.Start();
|
timerWaveform.Start();
|
||||||
@ -19668,6 +19669,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
if (form.ShowDialog(this) == DialogResult.OK)
|
if (form.ShowDialog(this) == DialogResult.OK)
|
||||||
{
|
{
|
||||||
audioVisualizer.SceneChanges = form.SceneChangesInSeconds;
|
audioVisualizer.SceneChanges = form.SceneChangesInSeconds;
|
||||||
|
SceneChangeHelper.SaveSceneChangesInSeconds(_videoFileName, audioVisualizer.SceneChanges);
|
||||||
ShowStatus(string.Format(_language.XSceneChangesImported, form.SceneChangesInSeconds.Count));
|
ShowStatus(string.Format(_language.XSceneChangesImported, form.SceneChangesInSeconds.Count));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -19676,7 +19678,10 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
private void toolStripMenuItemRemoveSceneChanges_Click(object sender, EventArgs e)
|
private void toolStripMenuItemRemoveSceneChanges_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (audioVisualizer != null && audioVisualizer.SceneChanges != null)
|
if (audioVisualizer != null && audioVisualizer.SceneChanges != null)
|
||||||
|
{
|
||||||
audioVisualizer.SceneChanges = new List<double>();
|
audioVisualizer.SceneChanges = new List<double>();
|
||||||
|
SceneChangeHelper.DeleteSceneChangesInSeconds(_videoFileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toolStripMenuItemDurationBridgeGaps_Click(object sender, EventArgs e)
|
private void toolStripMenuItemDurationBridgeGaps_Click(object sender, EventArgs e)
|
||||||
|
Loading…
Reference in New Issue
Block a user