mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Add deletefirst/deletelast to cmd line convert - thx rRobis :)
Related to #8391
This commit is contained in:
parent
ea458fb1b9
commit
ae922cac6b
@ -30,7 +30,7 @@
|
|||||||
* Fix unwanted text boxes background color change - thx Leon
|
* Fix unwanted text boxes background color change - thx Leon
|
||||||
* Fix Whisper on selection in waveform in "translation mode" - thx rRobis
|
* Fix Whisper on selection in waveform in "translation mode" - thx rRobis
|
||||||
* Fix image export shadow when border is zero - thx pixelhunterX
|
* Fix image export shadow when border is zero - thx pixelhunterX
|
||||||
* Fix crash in traslate with empty API key - thx lambdacore12
|
* Fix crash in translate with empty API key - thx lambdacore12
|
||||||
|
|
||||||
|
|
||||||
4.0.5 (13th April 2024)
|
4.0.5 (13th April 2024)
|
||||||
|
@ -1761,7 +1761,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
|
|
||||||
var preExt = TsToBluRaySup.GetFileNameEnding(programMapTableParser, id);
|
var preExt = TsToBluRaySup.GetFileNameEnding(programMapTableParser, id);
|
||||||
var dummy = 0;
|
var dummy = 0;
|
||||||
CommandLineConverter.BatchConvertSave(toFormat, TimeSpan.Zero, string.Empty, targetEncoding, outputFolder, string.Empty, 0, ref dummy, ref dummy, SubtitleFormat.AllSubtitleFormats.ToList(), fileName, parameter.Subtitle, new SubRip(), null, overwrite, 0, targetFrameRate, null, new List<CommandLineConverter.BatchAction>(), null, true, null, null, null, preExt);
|
CommandLineConverter.BatchConvertSave(toFormat, TimeSpan.Zero, string.Empty, string.Empty, string.Empty, targetEncoding, outputFolder, string.Empty, 0, ref dummy, ref dummy, SubtitleFormat.AllSubtitleFormats.ToList(), fileName, parameter.Subtitle, new SubRip(), null, overwrite, 0, targetFrameRate, null, new List<CommandLineConverter.BatchAction>(), null, true, null, null, null, preExt);
|
||||||
tsConvertedCount++;
|
tsConvertedCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1813,7 +1813,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
binaryParagraphs);
|
binaryParagraphs);
|
||||||
ApplyFixesStep2(parameter, Configuration.Settings.Tools.BatchConvertFixRtlMode);
|
ApplyFixesStep2(parameter, Configuration.Settings.Tools.BatchConvertFixRtlMode);
|
||||||
|
|
||||||
CommandLineConverter.BatchConvertSave(toFormat, TimeSpan.Zero, string.Empty, targetEncoding, outputFolder, string.Empty, 0, ref dummy, ref dummy, SubtitleFormat.AllSubtitleFormats.ToList(), fileName, parameter.Subtitle, new SubRip(), null, overwrite, 0, targetFrameRate, null, new List<CommandLineConverter.BatchAction>(), null, true, null, null, null, preExt);
|
CommandLineConverter.BatchConvertSave(toFormat, TimeSpan.Zero, string.Empty, string.Empty, string.Empty, targetEncoding, outputFolder, string.Empty, 0, ref dummy, ref dummy, SubtitleFormat.AllSubtitleFormats.ToList(), fileName, parameter.Subtitle, new SubRip(), null, overwrite, 0, targetFrameRate, null, new List<CommandLineConverter.BatchAction>(), null, true, null, null, null, preExt);
|
||||||
tsConvertedCount++;
|
tsConvertedCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3025,7 +3025,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
{
|
{
|
||||||
dir = Path.GetDirectoryName(p.FileName);
|
dir = Path.GetDirectoryName(p.FileName);
|
||||||
}
|
}
|
||||||
var success = CommandLineConverter.BatchConvertSave(targetFormat, TimeSpan.Zero, string.Empty, GetCurrentEncoding(p.FileName), dir, p.TargetFileName, _count, ref _converted, ref _errors, _allFormats, p.FileName, p.Subtitle, p.SourceFormat, binaryParagraphs, overwrite, -1, null, null, null, null, false, progressCallback, null, null, null, null, null, null, _preprocessingSettings, _cancellationTokenSource.Token);
|
var success = CommandLineConverter.BatchConvertSave(targetFormat, TimeSpan.Zero, string.Empty, string.Empty, string.Empty, GetCurrentEncoding(p.FileName), dir, p.TargetFileName, _count, ref _converted, ref _errors, _allFormats, p.FileName, p.Subtitle, p.SourceFormat, binaryParagraphs, overwrite, -1, null, null, null, null, false, progressCallback, null, null, null, null, null, null, _preprocessingSettings, _cancellationTokenSource.Token);
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
p.Item.SubItems[3].Text = LanguageSettings.Current.BatchConvert.Converted;
|
p.Item.SubItems[3].Text = LanguageSettings.Current.BatchConvert.Converted;
|
||||||
|
@ -137,6 +137,8 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
_stdOutWriter.WriteLine(" optional-parameters:");
|
_stdOutWriter.WriteLine(" optional-parameters:");
|
||||||
_stdOutWriter.WriteLine(" /adjustduration:<ms>");
|
_stdOutWriter.WriteLine(" /adjustduration:<ms>");
|
||||||
_stdOutWriter.WriteLine(" /assa-style-file:<file name>");
|
_stdOutWriter.WriteLine(" /assa-style-file:<file name>");
|
||||||
|
_stdOutWriter.WriteLine(" /deletefirst:<count>");
|
||||||
|
_stdOutWriter.WriteLine(" /deletelast:<count>");
|
||||||
_stdOutWriter.WriteLine(" /deletecontains:<word>");
|
_stdOutWriter.WriteLine(" /deletecontains:<word>");
|
||||||
_stdOutWriter.WriteLine(" /ebuheaderfile:<file name>");
|
_stdOutWriter.WriteLine(" /ebuheaderfile:<file name>");
|
||||||
_stdOutWriter.WriteLine(" /encoding:<encoding name>");
|
_stdOutWriter.WriteLine(" /encoding:<encoding name>");
|
||||||
@ -252,6 +254,8 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
}
|
}
|
||||||
|
|
||||||
var unconsumedArguments = arguments.Skip(4).Select(s => s.Trim()).Where(s => s.Length > 0).ToList();
|
var unconsumedArguments = arguments.Skip(4).Select(s => s.Trim()).Where(s => s.Length > 0).ToList();
|
||||||
|
var deleteFirst = GetDeleteFirst(unconsumedArguments);
|
||||||
|
var deleteLast = GetDeleteLast(unconsumedArguments);
|
||||||
var deleteContains = GetDeleteContains(unconsumedArguments);
|
var deleteContains = GetDeleteContains(unconsumedArguments);
|
||||||
var offset = GetOffset(unconsumedArguments);
|
var offset = GetOffset(unconsumedArguments);
|
||||||
var resolution = GetResolution(unconsumedArguments);
|
var resolution = GetResolution(unconsumedArguments);
|
||||||
@ -587,7 +591,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
mkvFileNames.Add(newFileName);
|
mkvFileNames.Add(newFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
BatchConvertSave(targetFormat, offset, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, newFileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
BatchConvertSave(targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, newFileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
else if (track.CodecId.Equals("S_HDMV/PGS", StringComparison.OrdinalIgnoreCase))
|
else if (track.CodecId.Equals("S_HDMV/PGS", StringComparison.OrdinalIgnoreCase))
|
||||||
@ -618,7 +622,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
_stdOutWriter?.WriteLine();
|
_stdOutWriter?.WriteLine();
|
||||||
sub = vobSubOcr.SubtitleFromOcr;
|
sub = vobSubOcr.SubtitleFromOcr;
|
||||||
}
|
}
|
||||||
BatchConvertSave(targetFormat, offset, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, newFileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
BatchConvertSave(targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, newFileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
||||||
}
|
}
|
||||||
if (!mkvFileNames.Add(newFileName))
|
if (!mkvFileNames.Add(newFileName))
|
||||||
{
|
{
|
||||||
@ -656,7 +660,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
_stdOutWriter?.WriteLine();
|
_stdOutWriter?.WriteLine();
|
||||||
sub = vobSubOcr.SubtitleFromOcr;
|
sub = vobSubOcr.SubtitleFromOcr;
|
||||||
}
|
}
|
||||||
BatchConvertSave(targetFormat, offset, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, newFileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
BatchConvertSave(targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, newFileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
||||||
}
|
}
|
||||||
if (!mkvFileNames.Add(newFileName))
|
if (!mkvFileNames.Add(newFileName))
|
||||||
{
|
{
|
||||||
@ -699,7 +703,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BatchConvertSave(targetFormat, offset, deleteContains, targetEncoding, outputFolder, string.Empty, count, ref converted, ref errors, formats, newFileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
BatchConvertSave(targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, string.Empty, count, ref converted, ref errors, formats, newFileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -722,13 +726,13 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
if (!done && FileUtil.IsBluRaySup(fileName))
|
if (!done && FileUtil.IsBluRaySup(fileName))
|
||||||
{
|
{
|
||||||
_stdOutWriter.WriteLine("Found Blu-Ray subtitle format");
|
_stdOutWriter.WriteLine("Found Blu-Ray subtitle format");
|
||||||
ConvertBluRaySubtitle(fileName, targetFormat, offset, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, forcedOnly, ocrEngine, ocrDb, resolution, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
ConvertBluRaySubtitle(fileName, targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, forcedOnly, ocrEngine, ocrDb, resolution, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
else if (!done && FileUtil.IsVobSub(fileName))
|
else if (!done && FileUtil.IsVobSub(fileName))
|
||||||
{
|
{
|
||||||
_stdOutWriter.WriteLine("Found VobSub subtitle format");
|
_stdOutWriter.WriteLine("Found VobSub subtitle format");
|
||||||
ConvertVobSubSubtitle(fileName, targetFormat, offset, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, forcedOnly, ocrEngine, ocrDb, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
ConvertVobSubSubtitle(fileName, targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, forcedOnly, ocrEngine, ocrDb, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -740,7 +744,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
if (mp4Parser.VttcSubtitle != null && mp4Parser.VttcSubtitle.Paragraphs.Count > 0)
|
if (mp4Parser.VttcSubtitle != null && mp4Parser.VttcSubtitle.Paragraphs.Count > 0)
|
||||||
{
|
{
|
||||||
var preExt = LanguageAutoDetect.AutoDetectGoogleLanguageOrNull(mp4Parser.VttcSubtitle);
|
var preExt = LanguageAutoDetect.AutoDetectGoogleLanguageOrNull(mp4Parser.VttcSubtitle);
|
||||||
if (BatchConvertSave(targetFormat, offset, deleteContains, targetEncoding, outputFolder, string.Empty, count, ref converted, ref errors, formats, fileName, mp4Parser.VttcSubtitle, new SubRip(), null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, null, null, null, preExt))
|
if (BatchConvertSave(targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, string.Empty, count, ref converted, ref errors, formats, fileName, mp4Parser.VttcSubtitle, new SubRip(), null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, null, null, null, preExt))
|
||||||
{
|
{
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
@ -777,14 +781,14 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
}
|
}
|
||||||
|
|
||||||
var newFileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".mp4";
|
var newFileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".mp4";
|
||||||
BatchConvertSave(targetFormat, offset, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, newFileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
BatchConvertSave(targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, newFileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var newFileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".mp4";
|
var newFileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".mp4";
|
||||||
sub.Paragraphs.AddRange(track.Mdia.Minf.Stbl.GetParagraphs());
|
sub.Paragraphs.AddRange(track.Mdia.Minf.Stbl.GetParagraphs());
|
||||||
BatchConvertSave(targetFormat, offset, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, newFileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
BatchConvertSave(targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, newFileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -795,7 +799,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
Path.GetExtension(fileName).Equals(".mts", StringComparison.OrdinalIgnoreCase) ||
|
Path.GetExtension(fileName).Equals(".mts", StringComparison.OrdinalIgnoreCase) ||
|
||||||
Path.GetExtension(fileName).Equals(".m2ts", StringComparison.OrdinalIgnoreCase)) && (FileUtil.IsTransportStream(fileName) || FileUtil.IsM2TransportStream(fileName)))
|
Path.GetExtension(fileName).Equals(".m2ts", StringComparison.OrdinalIgnoreCase)) && (FileUtil.IsTransportStream(fileName) || FileUtil.IsM2TransportStream(fileName)))
|
||||||
{
|
{
|
||||||
var ok = TsConvert.ConvertFromTs(targetFormat, fileName, outputFolder, overwrite, ref count, ref converted, ref errors, formats, _stdOutWriter, null, resolution, targetEncoding, actions, offset, deleteContains, pacCodePage, targetFrameRate, multipleReplaceImportFiles, ocrEngine, teletextOnly, teletextOnlyPage);
|
var ok = TsConvert.ConvertFromTs(targetFormat, fileName, outputFolder, overwrite, ref count, ref converted, ref errors, formats, _stdOutWriter, null, resolution, targetEncoding, actions, offset, deleteFirst, deleteLast, deleteContains, pacCodePage, targetFrameRate, multipleReplaceImportFiles, ocrEngine, teletextOnly, teletextOnlyPage);
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
converted++;
|
converted++;
|
||||||
@ -871,7 +875,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
if (subtitle != null)
|
if (subtitle != null)
|
||||||
{
|
{
|
||||||
subtitle.FileName = fileName;
|
subtitle.FileName = fileName;
|
||||||
ConvertImageListSubtitle(fileName, subtitle, targetFormat, offset, deleteContains, targetEncoding, outputFolder, count, ref converted, ref errors, formats, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, string.Empty, ocrEngine, renumber, adjustDurationMs);
|
ConvertImageListSubtitle(fileName, subtitle, targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, count, ref converted, ref errors, formats, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, string.Empty, ocrEngine, renumber, adjustDurationMs);
|
||||||
}
|
}
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
@ -891,7 +895,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
}
|
}
|
||||||
else if (!done)
|
else if (!done)
|
||||||
{
|
{
|
||||||
BatchConvertSave(targetFormat, offset, deleteContains, targetEncoding, outputFolder, targetFileName, count,
|
BatchConvertSave(targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, targetFileName, count,
|
||||||
ref converted, ref errors, formats, fileName, sub, format, null, overwrite, pacCodePage,
|
ref converted, ref errors, formats, fileName, sub, format, null, overwrite, pacCodePage,
|
||||||
targetFrameRate, multipleReplaceImportFiles, actions, resolution, ebuHeaderFile: ebuHeaderFile,
|
targetFrameRate, multipleReplaceImportFiles, actions, resolution, ebuHeaderFile: ebuHeaderFile,
|
||||||
assaStyleFile: assaStyleFile, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
assaStyleFile: assaStyleFile, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
||||||
@ -977,7 +981,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConvertBluRaySubtitle(string fileName, string targetFormat, TimeSpan offset, string deleteContains, TextEncoding targetEncoding, string outputFolder, string targetFileName, int count, ref int converted, ref int errors, List<SubtitleFormat> formats, bool overwrite, int pacCodePage, double? targetFrameRate, ICollection<string> multipleReplaceImportFiles, List<BatchAction> actions, bool forcedOnly, string ocrEngine, string ocrDb, Point? resolution, int? renumber, double? adjustDurationMs)
|
private static void ConvertBluRaySubtitle(string fileName, string targetFormat, TimeSpan offset, string deleteFirst, string deleteLast, string deleteContains, TextEncoding targetEncoding, string outputFolder, string targetFileName, int count, ref int converted, ref int errors, List<SubtitleFormat> formats, bool overwrite, int pacCodePage, double? targetFrameRate, ICollection<string> multipleReplaceImportFiles, List<BatchAction> actions, bool forcedOnly, string ocrEngine, string ocrDb, Point? resolution, int? renumber, double? adjustDurationMs)
|
||||||
{
|
{
|
||||||
var format = Utilities.GetSubtitleFormatByFriendlyName(targetFormat) ?? new SubRip();
|
var format = Utilities.GetSubtitleFormatByFriendlyName(targetFormat) ?? new SubRip();
|
||||||
|
|
||||||
@ -1002,11 +1006,11 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
if (sub != null)
|
if (sub != null)
|
||||||
{
|
{
|
||||||
_stdOutWriter?.WriteLine("Converted subtitle");
|
_stdOutWriter?.WriteLine("Converted subtitle");
|
||||||
BatchConvertSave(targetFormat, offset, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, fileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
BatchConvertSave(targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, fileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConvertVobSubSubtitle(string fileName, string targetFormat, TimeSpan offset, string deleteContains, TextEncoding targetEncoding, string outputFolder, string targetFileName, int count, ref int converted, ref int errors, List<SubtitleFormat> formats, bool overwrite, int pacCodePage, double? targetFrameRate, ICollection<string> multipleReplaceImportFiles, List<BatchAction> actions, bool forcedOnly, string ocrEngine, string ocrDb, int? renumber, double? adjustDurationMs)
|
private static void ConvertVobSubSubtitle(string fileName, string targetFormat, TimeSpan offset, string deleteFirst, string deleteLast, string deleteContains, TextEncoding targetEncoding, string outputFolder, string targetFileName, int count, ref int converted, ref int errors, List<SubtitleFormat> formats, bool overwrite, int pacCodePage, double? targetFrameRate, ICollection<string> multipleReplaceImportFiles, List<BatchAction> actions, bool forcedOnly, string ocrEngine, string ocrDb, int? renumber, double? adjustDurationMs)
|
||||||
{
|
{
|
||||||
var format = Utilities.GetSubtitleFormatByFriendlyName(targetFormat) ?? new SubRip();
|
var format = Utilities.GetSubtitleFormatByFriendlyName(targetFormat) ?? new SubRip();
|
||||||
|
|
||||||
@ -1028,11 +1032,11 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
if (sub != null)
|
if (sub != null)
|
||||||
{
|
{
|
||||||
_stdOutWriter?.WriteLine("Converted subtitle");
|
_stdOutWriter?.WriteLine("Converted subtitle");
|
||||||
BatchConvertSave(targetFormat, offset, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, fileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
BatchConvertSave(targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, targetFileName, count, ref converted, ref errors, formats, fileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConvertImageListSubtitle(string fileName, Subtitle subtitle, string targetFormat, TimeSpan offset, string deleteContains, TextEncoding targetEncoding, string outputFolder, int count, ref int converted, ref int errors, List<SubtitleFormat> formats, bool overwrite, int pacCodePage, double? targetFrameRate, ICollection<string> multipleReplaceImportFiles, List<BatchAction> actions, string language, string ocrEngine, int? renumber, double? adjustDurationMs)
|
private static void ConvertImageListSubtitle(string fileName, Subtitle subtitle, string targetFormat, TimeSpan offset, string deleteFirst, string deleteLast, string deleteContains, TextEncoding targetEncoding, string outputFolder, int count, ref int converted, ref int errors, List<SubtitleFormat> formats, bool overwrite, int pacCodePage, double? targetFrameRate, ICollection<string> multipleReplaceImportFiles, List<BatchAction> actions, string language, string ocrEngine, int? renumber, double? adjustDurationMs)
|
||||||
{
|
{
|
||||||
var format = Utilities.GetSubtitleFormatByFriendlyName(targetFormat) ?? new SubRip();
|
var format = Utilities.GetSubtitleFormatByFriendlyName(targetFormat) ?? new SubRip();
|
||||||
|
|
||||||
@ -1054,7 +1058,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
if (sub != null)
|
if (sub != null)
|
||||||
{
|
{
|
||||||
_stdOutWriter?.WriteLine("Converted subtitle");
|
_stdOutWriter?.WriteLine("Converted subtitle");
|
||||||
BatchConvertSave(targetFormat, offset, deleteContains, targetEncoding, outputFolder, string.Empty, count, ref converted, ref errors, formats, fileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
BatchConvertSave(targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, string.Empty, count, ref converted, ref errors, formats, fileName, sub, format, null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, renumber: renumber, adjustDurationMs: adjustDurationMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1132,6 +1136,16 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetDeleteFirst(IList<string> commandLineArguments)
|
||||||
|
{
|
||||||
|
return GetArgument(commandLineArguments, "deletefirst:", string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetDeleteLast(IList<string> commandLineArguments)
|
||||||
|
{
|
||||||
|
return GetArgument(commandLineArguments, "deletelast:", string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
private static string GetDeleteContains(IList<string> commandLineArguments)
|
private static string GetDeleteContains(IList<string> commandLineArguments)
|
||||||
{
|
{
|
||||||
return GetArgument(commandLineArguments, "deletecontains:", string.Empty);
|
return GetArgument(commandLineArguments, "deletecontains:", string.Empty);
|
||||||
@ -1340,7 +1354,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool BatchConvertSave(string targetFormat, TimeSpan offset, string deleteContains, TextEncoding targetEncoding, string outputFolder, string targetFileName, int count, ref int converted, ref int errors,
|
internal static bool BatchConvertSave(string targetFormat, TimeSpan offset, string deleteFirst, string deleteLast, string deleteContains, TextEncoding targetEncoding, string outputFolder, string targetFileName, int count, ref int converted, ref int errors,
|
||||||
List<SubtitleFormat> formats, string fileName, Subtitle sub, SubtitleFormat format, IList<IBinaryParagraphWithPosition> binaryParagraphs, bool overwrite, int pacCodePage,
|
List<SubtitleFormat> formats, string fileName, Subtitle sub, SubtitleFormat format, IList<IBinaryParagraphWithPosition> binaryParagraphs, bool overwrite, int pacCodePage,
|
||||||
double? targetFrameRate, ICollection<string> multipleReplaceImportFiles, List<BatchAction> actions = null,
|
double? targetFrameRate, ICollection<string> multipleReplaceImportFiles, List<BatchAction> actions = null,
|
||||||
Point? resolution = null, bool autoDetectLanguage = false, BatchConvertProgress progressCallback = null, string ebuHeaderFile = null, string assaStyleFile = null, string ocrEngine = null, string preExt = null, int? renumber = null, double? adjustDurationMs = null, PreprocessingSettings preprocessingSettings = null, CancellationToken cancellationToken = default)
|
Point? resolution = null, bool autoDetectLanguage = false, BatchConvertProgress progressCallback = null, string ebuHeaderFile = null, string assaStyleFile = null, string ocrEngine = null, string preExt = null, int? renumber = null, double? adjustDurationMs = null, PreprocessingSettings preprocessingSettings = null, CancellationToken cancellationToken = default)
|
||||||
@ -1378,11 +1392,8 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
sub.AddTimeToAllParagraphs(offset);
|
sub.AddTimeToAllParagraphs(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete lines containing a specific text
|
// delete lines containing a specific text or from start/end
|
||||||
if (!string.IsNullOrEmpty(deleteContains))
|
DeleteContains(sub, deleteFirst, deleteLast, deleteContains);
|
||||||
{
|
|
||||||
DeleteContains(sub, deleteContains);
|
|
||||||
}
|
|
||||||
|
|
||||||
// adjust frame rate
|
// adjust frame rate
|
||||||
if (targetFrameRate.HasValue && targetFrameRate > 0)
|
if (targetFrameRate.HasValue && targetFrameRate > 0)
|
||||||
@ -2178,28 +2189,44 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
return nb.GetBitmap();
|
return nb.GetBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void DeleteContains(Subtitle sub, string deleteContains)
|
internal static void DeleteContains(Subtitle sub, string deleteFirst, string deleteLast, string deleteContains)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(deleteContains))
|
var skipFirst = 0;
|
||||||
|
if (int.TryParse(deleteFirst, out var skipF) && skipF > 0)
|
||||||
|
{
|
||||||
|
skipFirst = skipF;
|
||||||
|
}
|
||||||
|
|
||||||
|
var skipLast = 0;
|
||||||
|
if (int.TryParse(deleteLast, out var skipL) && skipL > 0)
|
||||||
|
{
|
||||||
|
skipLast = skipL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skipFirst == 0 && skipLast == 0 && string.IsNullOrWhiteSpace(deleteContains))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var deleted = 0;
|
var paragraphs = sub.Paragraphs.Skip(skipFirst).ToList();
|
||||||
for (var index = sub.Paragraphs.Count - 1; index >= 0; index--)
|
paragraphs = paragraphs.Take(paragraphs.Count - skipLast).ToList();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(deleteContains))
|
||||||
{
|
{
|
||||||
var paragraph = sub.Paragraphs[index];
|
for (var index = paragraphs.Count - 1; index >= 0; index--)
|
||||||
if (paragraph.Text.Contains(deleteContains, StringComparison.Ordinal))
|
|
||||||
{
|
{
|
||||||
deleted++;
|
var paragraph = paragraphs[index];
|
||||||
sub.Paragraphs.RemoveAt(index);
|
if (paragraph.Text.Contains(deleteContains, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
paragraphs.RemoveAt(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deleted > 0)
|
sub.Paragraphs.Clear();
|
||||||
{
|
sub.Paragraphs.AddRange(paragraphs);
|
||||||
sub.Renumber();
|
|
||||||
}
|
sub.Renumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool HasImageTarget(string targetFormat)
|
private static bool HasImageTarget(string targetFormat)
|
||||||
|
@ -13,7 +13,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
{
|
{
|
||||||
public static class TsConvert
|
public static class TsConvert
|
||||||
{
|
{
|
||||||
public static bool ConvertFromTs(string targetFormat, string fileName, string outputFolder, bool overwrite, ref int count, ref int converted, ref int errors, List<SubtitleFormat> formats, StreamWriter stdOutWriter, CommandLineConverter.BatchConvertProgress progressCallback, Point? resolution, TextEncoding targetEncoding, List<CommandLineConverter.BatchAction> actions, TimeSpan offset, string deleteContains, int pacCodePage, double? targetFrameRate, HashSet<string> multipleReplaceImportFiles, string ocrEngine, bool teletextOnly, string teletextOnlyPage)
|
public static bool ConvertFromTs(string targetFormat, string fileName, string outputFolder, bool overwrite, ref int count, ref int converted, ref int errors, List<SubtitleFormat> formats, StreamWriter stdOutWriter, CommandLineConverter.BatchConvertProgress progressCallback, Point? resolution, TextEncoding targetEncoding, List<CommandLineConverter.BatchAction> actions, TimeSpan offset, string deleteFirst, string deleteLast, string deleteContains, int pacCodePage, double? targetFrameRate, HashSet<string> multipleReplaceImportFiles, string ocrEngine, bool teletextOnly, string teletextOnlyPage)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(teletextOnlyPage))
|
if (!string.IsNullOrEmpty(teletextOnlyPage))
|
||||||
{
|
{
|
||||||
@ -58,7 +58,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
subtitle.Paragraphs.Add(new Paragraph(string.Empty, transportStreamSubtitle.StartMilliseconds, transportStreamSubtitle.EndMilliseconds));
|
subtitle.Paragraphs.Add(new Paragraph(string.Empty, transportStreamSubtitle.StartMilliseconds, transportStreamSubtitle.EndMilliseconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
success = CommandLineConverter.BatchConvertSave(targetFormat, offset, deleteContains, targetEncoding, outputFolder, string.Empty, count, ref converted, ref errors, formats, fileName, subtitle, new SubRip(), binaryParagraphs, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, null, null, ocrEngine, preExt);
|
success = CommandLineConverter.BatchConvertSave(targetFormat, offset, string.Empty, string.Empty, deleteContains, targetEncoding, outputFolder, string.Empty, count, ref converted, ref errors, formats, fileName, subtitle, new SubRip(), binaryParagraphs, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, null, null, ocrEngine, preExt);
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
converted--;
|
converted--;
|
||||||
@ -81,7 +81,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
|||||||
var subtitle = new Subtitle(kvp.Value);
|
var subtitle = new Subtitle(kvp.Value);
|
||||||
subtitle.Renumber();
|
subtitle.Renumber();
|
||||||
var preExt = TsToBluRaySup.GetFileNameEnding(programMapTableParser, kvp.Key);
|
var preExt = TsToBluRaySup.GetFileNameEnding(programMapTableParser, kvp.Key);
|
||||||
success = CommandLineConverter.BatchConvertSave(targetFormat, offset, deleteContains, targetEncoding, outputFolder, string.Empty, count, ref converted, ref errors, formats, fileName, subtitle, new SubRip(), null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, null, null, null, preExt);
|
success = CommandLineConverter.BatchConvertSave(targetFormat, offset, deleteFirst, deleteLast, deleteContains, targetEncoding, outputFolder, string.Empty, count, ref converted, ref errors, formats, fileName, subtitle, new SubRip(), null, overwrite, pacCodePage, targetFrameRate, multipleReplaceImportFiles, actions, resolution, true, null, null, null, preExt);
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
converted--;
|
converted--;
|
||||||
|
Loading…
Reference in New Issue
Block a user