mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-23 03:33:18 +01:00
Also add "Beautify time codes" to command line
This commit is contained in:
parent
11e52914a0
commit
b4e84bd4ab
@ -2666,32 +2666,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
if (p.BeautifyTimeCodes.Enabled)
|
||||
{
|
||||
var frameRate = Configuration.Settings.General.DefaultFrameRate;
|
||||
var timeCodes = new List<double>();
|
||||
var shotChanges = new List<double>();
|
||||
|
||||
var videoFile = TryToFindVideoFile(p.FileName);
|
||||
if (videoFile != null)
|
||||
{
|
||||
var videoInfo = UiUtil.GetVideoInfo(videoFile);
|
||||
if (videoInfo.FramesPerSecond > 0)
|
||||
{
|
||||
frameRate = videoInfo.FramesPerSecond;
|
||||
}
|
||||
|
||||
if (p.BeautifyTimeCodes.UseExactTimeCodes)
|
||||
{
|
||||
timeCodes = TimeCodesFileHelper.FromDisk(videoFile);
|
||||
}
|
||||
|
||||
if (p.BeautifyTimeCodes.SnapToShotChanges)
|
||||
{
|
||||
shotChanges = ShotChangeHelper.FromDisk(videoFile);
|
||||
}
|
||||
}
|
||||
|
||||
new TimeCodesBeautifier(p.Subtitle, frameRate, timeCodes, shotChanges).Beautify();
|
||||
{
|
||||
BeautifyTimeCodes(p.Subtitle, p.FileName, p.BeautifyTimeCodes.UseExactTimeCodes, p.BeautifyTimeCodes.SnapToShotChanges);
|
||||
}
|
||||
|
||||
// always re-number
|
||||
@ -2795,7 +2771,36 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private static string TryToFindVideoFile(string fileName)
|
||||
public static void BeautifyTimeCodes(Subtitle subtitle, string fileName, bool useExactTimeCodes, bool snapToShotChanges)
|
||||
{
|
||||
var frameRate = Configuration.Settings.General.DefaultFrameRate;
|
||||
var timeCodes = new List<double>();
|
||||
var shotChanges = new List<double>();
|
||||
|
||||
var videoFile = TryToFindVideoFile(fileName);
|
||||
if (videoFile != null)
|
||||
{
|
||||
var videoInfo = UiUtil.GetVideoInfo(videoFile);
|
||||
if (videoInfo.FramesPerSecond > 0)
|
||||
{
|
||||
frameRate = videoInfo.FramesPerSecond;
|
||||
}
|
||||
|
||||
if (useExactTimeCodes)
|
||||
{
|
||||
timeCodes = TimeCodesFileHelper.FromDisk(videoFile);
|
||||
}
|
||||
|
||||
if (snapToShotChanges)
|
||||
{
|
||||
shotChanges = ShotChangeHelper.FromDisk(videoFile);
|
||||
}
|
||||
}
|
||||
|
||||
new TimeCodesBeautifier(subtitle, frameRate, timeCodes, shotChanges).Beautify();
|
||||
}
|
||||
|
||||
public static string TryToFindVideoFile(string fileName)
|
||||
{
|
||||
string fileNameNoExtension = Utilities.GetPathAndFileNameWithoutExtension(fileName);
|
||||
string movieFileName = null;
|
||||
@ -2822,7 +2827,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return null;
|
||||
}
|
||||
|
||||
private static List<double> GetShotChangesOrEmpty(string fileName)
|
||||
public static List<double> GetShotChangesOrEmpty(string fileName)
|
||||
{
|
||||
var videoFile = TryToFindVideoFile(fileName);
|
||||
if (videoFile != null)
|
||||
|
@ -171,6 +171,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
||||
_stdOutWriter.WriteLine(" /" + BatchAction.ConvertColorsToDialog);
|
||||
_stdOutWriter.WriteLine(" /" + BatchAction.RedoCasing);
|
||||
_stdOutWriter.WriteLine(" /" + BatchAction.BalanceLines);
|
||||
_stdOutWriter.WriteLine(" /" + BatchAction.BeautifyTimeCodes);
|
||||
_stdOutWriter.WriteLine();
|
||||
_stdOutWriter.WriteLine(" Example: SubtitleEdit /convert *.srt sami");
|
||||
_stdOutWriter.WriteLine(" Show this usage message: SubtitleEdit /help");
|
||||
@ -2275,6 +2276,9 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
||||
p.Text = Utilities.RemoveUnicodeControlChars(p.Text);
|
||||
}
|
||||
break;
|
||||
case BatchAction.BeautifyTimeCodes:
|
||||
BatchConvert.BeautifyTimeCodes(sub, sub.FileName, Configuration.Settings.BeautifyTimeCodes.ExtractExactTimeCodes, Configuration.Settings.BeautifyTimeCodes.SnapToShotChanges);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user