Skip to content

Commit c25f3b6

Browse files
committed
Fixed audio track names in Encoding Settings not being applied.
1 parent 77bbed8 commit c25f3b6

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

VidCoder/Services/ProcessingService.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,8 +3143,14 @@ private void AutoResumeEncoding(object sender, EventArgs e)
31433143
});
31443144
}
31453145

3146-
// Automatically pick the correct audio on the given job.
3147-
// Only relies on input from settings and the current title.
3146+
/// <summary>
3147+
/// Automatically pick the correct audio on the given job.
3148+
/// Only relies on input from settings and the current title.
3149+
/// </summary>
3150+
/// <param name="job">The current encoding job.</param>
3151+
/// <param name="title">The source title.</param>
3152+
/// <param name="useCurrentContext">True to use the currently selected tracks to influence the choice.</param>
3153+
/// <param name="picker">The Picker to use.</param>
31483154
private void AutoPickAudio(VCJob job, SourceTitle title, bool useCurrentContext = false, Picker picker = null)
31493155
{
31503156
if (picker == null)

VidCoder/ViewModel/MainViewModel.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,13 +1287,35 @@ private void BuildAudioViewModelList()
12871287
// Fill in rest of unselected audio tracks
12881288
this.FillInUnselectedAudioTracks(audioTracksInnerList);
12891289

1290-
// Apply subtitle names from the Picker.
1290+
// Apply audio names from the Picker and Audio Encoding settings.
12911291
int outputIndex = 0;
12921292
foreach (AudioTrackViewModel audioTrackViewModel in audioTracksInnerList)
12931293
{
1294-
if (audioTrackViewModel.Selected)
1294+
audioTrackViewModel.Name = ProcessingService.GetPickerAudioName(picker, outputIndex++);
1295+
}
1296+
1297+
VCProfile profile = this.PresetsService.SelectedPreset.Preset.EncodingProfile;
1298+
if (profile.AudioEncodings != null)
1299+
{
1300+
foreach (AudioEncoding audioEncoding in profile.AudioEncodings)
12951301
{
1296-
audioTrackViewModel.Name = ProcessingService.GetPickerAudioName(picker, outputIndex++);
1302+
if (string.IsNullOrEmpty(audioEncoding.Name))
1303+
{
1304+
continue;
1305+
}
1306+
1307+
if (audioEncoding.InputNumber == 0)
1308+
{
1309+
foreach (AudioTrackViewModel audioTrackViewModel in audioTracksInnerList)
1310+
{
1311+
audioTrackViewModel.Name = audioEncoding.Name;
1312+
}
1313+
}
1314+
else if (audioEncoding.InputNumber <= audioTracksInnerList.Count)
1315+
{
1316+
AudioTrackViewModel audioTrackViewModel = audioTracksInnerList[audioEncoding.InputNumber - 1];
1317+
audioTrackViewModel.Name = audioEncoding.Name;
1318+
}
12971319
}
12981320
}
12991321
});

VidCoderCommon/Model/JsonEncodeFactory.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,17 @@ private static List<ResolvedAudioTrack> ResolveAudioTracks(List<PairedAudioTrack
291291
Encoder = HandBrakeEncoderHelpers.GetAudioEncoder((int)outputCodec).ShortName,
292292
};
293293

294+
// First priority: Chosen track name in the UI
294295
string trackName = chosenTrack.Name;
295296

296-
if (trackName == null)
297+
// Second priority name set in Audio Encoding
298+
if (string.IsNullOrEmpty(trackName) && !string.IsNullOrEmpty(encoding.Name))
299+
{
300+
trackName = encoding.Name;
301+
}
302+
303+
// Last priority: Source track name
304+
if (string.IsNullOrEmpty(trackName) && !string.IsNullOrEmpty(sourceTrack.Name))
297305
{
298306
trackName = sourceTrack.Name;
299307
}

0 commit comments

Comments
 (0)