This commit is contained in:
Nikolaj Olsson 2024-04-18 20:45:15 +02:00
parent 3431a2450f
commit 77e9c18306
3 changed files with 536 additions and 469 deletions

File diff suppressed because it is too large Load Diff

View File

@ -314,6 +314,29 @@ namespace Nikse.SubtitleEdit.Forms
buttonClear.Visible = BatchMode; buttonClear.Visible = BatchMode;
buttonAddFile.Visible = BatchMode; buttonAddFile.Visible = BatchMode;
var audioTracks = _mediaInfo.Tracks.Where(p => p.TrackType == FfmpegTrackType.Audio).ToList();
if (BatchMode)
{
listViewAudioTracks.Visible = false;
}
else if (audioTracks.Count > 1)
{
listViewAudioTracks.Visible = true;
for (var index = 0; index < audioTracks.Count; index++)
{
var trackInfo = audioTracks[index];
listViewAudioTracks.Items.Add($"#{index}: {trackInfo.TrackInfo}");
listViewAudioTracks.Items[index].Checked = true;
}
listViewAudioTracks.AutoSizeLastColumn();
}
else
{
listViewAudioTracks.Visible = false;
}
if (string.IsNullOrEmpty(inputVideoFileName) || _videoInfo == null || _videoInfo.Width == 0 || _videoInfo.Height == 0) if (string.IsNullOrEmpty(inputVideoFileName) || _videoInfo == null || _videoInfo.Width == 0 || _videoInfo.Height == 0)
{ {
buttonMode_Click(null, null); buttonMode_Click(null, null);
@ -873,6 +896,19 @@ namespace Nikse.SubtitleEdit.Forms
private Process GetFfmpegProcess(string inputVideoFileName, string outputVideoFileName, string assaTempFileName, int? passNumber = null, string twoPassBitRate = null, bool preview = false) private Process GetFfmpegProcess(string inputVideoFileName, string outputVideoFileName, string assaTempFileName, int? passNumber = null, string twoPassBitRate = null, bool preview = false)
{ {
var audioCutTracks = string.Empty;
if (listViewAudioTracks.Visible)
{
for (var index = 0; index < listViewAudioTracks.Items.Count; index++)
{
var listViewItem = listViewAudioTracks.Items[index];
if (!listViewItem.Checked)
{
audioCutTracks += $"-map 0:a:{index} ";
}
}
}
var pass = string.Empty; var pass = string.Empty;
if (passNumber.HasValue) if (passNumber.HasValue)
{ {
@ -909,7 +945,8 @@ namespace Nikse.SubtitleEdit.Forms
twoPassBitRate, twoPassBitRate,
OutputHandler, OutputHandler,
cutStart, cutStart,
cutEnd); cutEnd,
audioCutTracks);
} }
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
@ -1996,6 +2033,7 @@ namespace Nikse.SubtitleEdit.Forms
private void GenerateVideoWithHardSubs_ResizeEnd(object sender, EventArgs e) private void GenerateVideoWithHardSubs_ResizeEnd(object sender, EventArgs e)
{ {
listViewBatch.AutoSizeLastColumn(); listViewBatch.AutoSizeLastColumn();
listViewAudioTracks.AutoSizeLastColumn();
} }
private void listViewBatch_DragEnter(object sender, DragEventArgs e) private void listViewBatch_DragEnter(object sender, DragEventArgs e)

View File

@ -125,7 +125,7 @@ namespace Nikse.SubtitleEdit.Logic
/// <summary> /// <summary>
/// Generate a video with a burned-in Advanced Sub Station Alpha subtitle. /// Generate a video with a burned-in Advanced Sub Station Alpha subtitle.
/// </summary> /// </summary>
public static Process GenerateHardcodedVideoFile(string inputVideoFileName, string assaSubtitleFileName, string outputVideoFileName, int width, int height, string videoEncoding, string preset, string crf, string audioEncoding, bool forceStereo, string sampleRate, string tune, string audioBitRate, string pass, string twoPassBitRate, DataReceivedEventHandler dataReceivedHandler = null, string cutStart = null, string cutEnd = null) public static Process GenerateHardcodedVideoFile(string inputVideoFileName, string assaSubtitleFileName, string outputVideoFileName, int width, int height, string videoEncoding, string preset, string crf, string audioEncoding, bool forceStereo, string sampleRate, string tune, string audioBitRate, string pass, string twoPassBitRate, DataReceivedEventHandler dataReceivedHandler = null, string cutStart = null, string cutEnd = null, string audioCutTrack = "")
{ {
if (width % 2 == 1) if (width % 2 == 1)
{ {
@ -157,6 +157,9 @@ namespace Nikse.SubtitleEdit.Logic
} }
} }
audioSettings = audioCutTrack + " " + audioSettings;
var presetSettings = string.Empty; var presetSettings = string.Empty;
if (!string.IsNullOrEmpty(preset)) if (!string.IsNullOrEmpty(preset))
{ {