Use time code for file name when export audio for selected lines - thx nissansz :)

Fix  #6090
This commit is contained in:
niksedk 2022-07-26 07:47:39 +02:00
parent 5aa8e0e6c7
commit 3b2d082d0a
6 changed files with 19 additions and 75 deletions

View File

@ -13,6 +13,8 @@
* Add toolbar icon for WebVTT properties - thx Leon
* Add shortcut for toggle between text box and waveform - thx Marko
* Add shortcuts for go to next/prev and focus waveform - thx cyzs233
* Export audio for selected lines - thx nissansz
* Audio-to-text for selected lines - thx Mishasama
* IMPROVED:
* Update Polish translation - thx admas
* Update Bulgarian translation - thx Калин

View File

@ -1403,6 +1403,7 @@ To use an API key go to "Options -> Settings -> Tools" to enter your Googl
<RemoveBookmark>Remove bookmark</RemoveBookmark>
<GoToSourceView>Go to source view</GoToSourceView>
<GoToListView>Go to list view</GoToListView>
<ExtractAudio>Extract audio...</ExtractAudio>
</ContextMenu>
</Menu>
<Controls>

View File

@ -45,7 +45,7 @@ namespace Nikse.SubtitleEdit.Forms
progressBar1.Value++;
try
{
var targetFile = Path.Combine(targetFolder, (index+1)+ ".wav");
var targetFile = Path.Combine(targetFolder, MakeTimeCodeFileName(item) + ".wav");
var audioParameter = string.Empty;
if (_audioTrackNumber > 0)
{
@ -98,6 +98,15 @@ namespace Nikse.SubtitleEdit.Forms
DialogResult = DialogResult.OK;
}
private string MakeTimeCodeFileName(Paragraph item)
{
//0_00_01_042__0_00_03_919_01.wav
return
item.StartTime.ToDisplayString().Replace('.', '_').Replace(':', '_').Replace(',', '_') +
"__" +
item.StartTime.ToDisplayString().Replace('.', '_').Replace(':', '_').Replace(',', '_');
}
private void UpdateStatus(string status)
{
labelProgress.Text = status;

View File

@ -740,77 +740,6 @@ namespace Nikse.SubtitleEdit.Forms
return false;
}
private void SplitSingle(StringBuilder sb)
{
string t = sb.ToString().Trim();
var tarr = t.SplitToLines();
if (checkBoxMergeShortLines.Checked == false && tarr.Count == 3 &&
tarr[0].Length < Configuration.Settings.General.SubtitleLineMaximumLength &&
tarr[1].Length < Configuration.Settings.General.SubtitleLineMaximumLength &&
tarr[2].Length < Configuration.Settings.General.SubtitleLineMaximumLength)
{
FixedSubtitle.Paragraphs.Add(new Paragraph { Text = tarr[0] + Environment.NewLine + tarr[1] });
return;
}
if (checkBoxMergeShortLines.Checked == false && tarr.Count == 2 &&
tarr[0].Length < Configuration.Settings.General.SubtitleLineMaximumLength &&
tarr[1].Length < Configuration.Settings.General.SubtitleLineMaximumLength)
{
FixedSubtitle.Paragraphs.Add(new Paragraph { Text = tarr[0] + Environment.NewLine + tarr[1] });
return;
}
if (checkBoxMergeShortLines.Checked == false && tarr.Count == 1 && tarr[0].Length < Configuration.Settings.General.SubtitleLineMaximumLength)
{
FixedSubtitle.Paragraphs.Add(new Paragraph { Text = tarr[0].Trim() });
return;
}
Paragraph p = null;
if (CanMakeThreeLiner(out var threeLiner, sb.ToString()))
{
var parts = threeLiner.SplitToLines();
FixedSubtitle.Paragraphs.Add(new Paragraph { Text = parts[0] + Environment.NewLine + parts[1] });
FixedSubtitle.Paragraphs.Add(new Paragraph { Text = parts[2].Trim() });
return;
}
foreach (string text in Utilities.AutoBreakLineMoreThanTwoLines(sb.ToString(), Configuration.Settings.General.SubtitleLineMaximumLength, Configuration.Settings.General.MergeLinesShorterThan, "en").SplitToLines())
{
if (p == null)
{
p = new Paragraph { Text = text };
}
else if (p.Text.Contains(Environment.NewLine))
{
FixedSubtitle.Paragraphs.Add(p);
p = new Paragraph();
if (text.Length >= Configuration.Settings.General.SubtitleLineMaximumLength)
{
p.Text = Utilities.AutoBreakLine(text);
}
else
{
p.Text = text;
}
}
else
{
if (checkBoxMergeShortLines.Checked || p.Text.Length > Configuration.Settings.General.SubtitleLineMaximumLength || text.Length > Configuration.Settings.General.SubtitleLineMaximumLength)
{
p.Text = Utilities.AutoBreakLine(p.Text + Environment.NewLine + text.Trim());
}
else
{
p.Text = p.Text + Environment.NewLine + text.Trim();
}
}
}
if (p != null)
{
FixedSubtitle.Paragraphs.Add(p);
}
}
private void ImportAutoSplit(string[] textLines)
{
var sub = new Subtitle();
@ -1326,7 +1255,7 @@ namespace Nikse.SubtitleEdit.Forms
private void listViewInputFiles_DragDrop(object sender, DragEventArgs e)
{
var fileNames = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string fileName in fileNames.OrderBy(p => p))
foreach (var fileName in fileNames.OrderBy(p => p))
{
AddInputFile(fileName);
}

View File

@ -8739,9 +8739,9 @@ namespace Nikse.SubtitleEdit.Forms
}
};
var audio = new ToolStripMenuItem("Audio");
var audio = new ToolStripMenuItem(LanguageSettings.Current.GenerateVideoWithBurnedInSubs.Audio);
audio.Tag = "(REMOVE)";
if (SubtitleListview1.SelectedItems.Count > 0)
if (SubtitleListview1.SelectedItems.Count > 0 && !string.IsNullOrEmpty(_videoFileName))
{
toolStripMenuItemSelectedLines.DropDownItems.Insert(0, audio);
var audioClip = new ToolStripMenuItem(LanguageSettings.Current.Main.Menu.ContextMenu.ExtractAudio);

View File

@ -4576,6 +4576,9 @@ namespace Nikse.SubtitleEdit.Logic
case "Main/Menu/ContextMenu/GoToListView":
language.Main.Menu.ContextMenu.GoToListView = reader.Value;
break;
case "Main/Menu/ContextMenu/ExtractAudio":
language.Main.Menu.ContextMenu.ExtractAudio = reader.Value;
break;
case "Main/Controls/SubtitleFormat":
language.Main.Controls.SubtitleFormat = reader.Value;
break;