mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 04:33:04 +01:00
Minor refact
This commit is contained in:
parent
6a0cb5bdf4
commit
3b5a9da89e
@ -8,12 +8,17 @@ namespace Nikse.SubtitleEdit.Core
|
||||
public static class SceneChangeHelper
|
||||
{
|
||||
|
||||
public static string GetSceneChangesFileName(string videoFileName)
|
||||
private static string GetSceneChangesFileName(string videoFileName)
|
||||
{
|
||||
var fileName = WavePeakGenerator.GetPeakWaveFileName(videoFileName);
|
||||
return Path.GetFileNameWithoutExtension(fileName) + ".scenechanges";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load scene changes from file
|
||||
/// </summary>
|
||||
/// <param name="videoFileName">Video file name</param>
|
||||
/// <returns>List of scene changes in seconds</returns>
|
||||
public static List<double> FromDisk(string videoFileName)
|
||||
{
|
||||
var list = new List<double>();
|
||||
@ -31,7 +36,12 @@ namespace Nikse.SubtitleEdit.Core
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void SaveSceneChangesInSeconds(string videoFileName, List<double> list)
|
||||
/// <summary>
|
||||
/// Saves scene changes
|
||||
/// </summary>
|
||||
/// <param name="videoFileName">Video file name</param>
|
||||
/// <param name="list">List of scene changes in seconds</param>
|
||||
public static void SaveSceneChanges(string videoFileName, List<double> list)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var d in list)
|
||||
@ -41,7 +51,11 @@ namespace Nikse.SubtitleEdit.Core
|
||||
File.WriteAllText(GetSceneChangesFileName(videoFileName), sb.ToString().Trim());
|
||||
}
|
||||
|
||||
public static void DeleteSceneChangesInSeconds(string videoFileName)
|
||||
/// <summary>
|
||||
/// Delete scene changes file associated with video file
|
||||
/// </summary>
|
||||
/// <param name="videoFileName">Video file name</param>
|
||||
public static void DeleteSceneChanges(string videoFileName)
|
||||
{
|
||||
var sceneChangesFileName = GetSceneChangesFileName(videoFileName);
|
||||
if (File.Exists(sceneChangesFileName))
|
||||
@ -49,4 +63,4 @@ namespace Nikse.SubtitleEdit.Core
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -9482,7 +9482,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (buffer != null && buffer.Length > 2)
|
||||
{
|
||||
clusterStream.Write(buffer, 0, buffer.Length);
|
||||
if (ContainsBlueEndSegment(buffer))
|
||||
if (ContainsBluRayStartSegment(buffer))
|
||||
{
|
||||
if (subtitles.Count > 0 && subtitles[subtitles.Count - 1].StartTime == subtitles[subtitles.Count - 1].EndTime)
|
||||
{
|
||||
@ -9558,16 +9558,16 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ContainsBlueEndSegment(byte[] buffer)
|
||||
private bool ContainsBluRayStartSegment(byte[] buffer)
|
||||
{
|
||||
const int epochStart = 0x80;
|
||||
var position = 0;
|
||||
int length = 0;
|
||||
while (position + 3 <= buffer.Length)
|
||||
{
|
||||
var segmentType = buffer[position];
|
||||
if (segmentType == 0x80)
|
||||
if (segmentType == epochStart)
|
||||
return true;
|
||||
length = BluRaySupParser.BigEndianInt16(buffer, position + 1) + 3;
|
||||
int length = BluRaySupParser.BigEndianInt16(buffer, position + 1) + 3;
|
||||
position += length;
|
||||
}
|
||||
return false;
|
||||
@ -19669,7 +19669,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (form.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
audioVisualizer.SceneChanges = form.SceneChangesInSeconds;
|
||||
SceneChangeHelper.SaveSceneChangesInSeconds(_videoFileName, audioVisualizer.SceneChanges);
|
||||
SceneChangeHelper.SaveSceneChanges(_videoFileName, audioVisualizer.SceneChanges);
|
||||
ShowStatus(string.Format(_language.XSceneChangesImported, form.SceneChangesInSeconds.Count));
|
||||
}
|
||||
}
|
||||
@ -19680,7 +19680,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (audioVisualizer != null && audioVisualizer.SceneChanges != null)
|
||||
{
|
||||
audioVisualizer.SceneChanges = new List<double>();
|
||||
SceneChangeHelper.DeleteSceneChangesInSeconds(_videoFileName);
|
||||
SceneChangeHelper.DeleteSceneChanges(_videoFileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user