fix first audio in lang

main
Gabe Farrell 9 months ago
parent c2ce2eee11
commit b9a297b69f

@ -6,7 +6,7 @@ const details = () => ({
Type: 'Video',
Operation: 'Transcode',
Description:
'Re-orders streams to move default audio and subtitle tracks to be first. \\n',
'Re-orders streams to move default audio and subtitle tracks to be first. Multiple default tracks may result in duplicate streams.\\n',
Version: '1.0',
Tags: 'pre-processing,ffmpeg',
Inputs: [],

@ -60,10 +60,9 @@ const details = () => ({
let foundAudioInLang = false;
let defaults = [] // list of tracks currently set as default
// 1, 2 jpn (default), 3 eng (default)
// [0,1,1]
// firstAudioIdx = 2
// convert = false
// 0 jpn (default), 1 eng (default)
// [true, true]
// firstAudioInLangIdx = 0
for (let i = 0; i < file.ffProbeData.streams.length; i++) {
try {
@ -71,9 +70,10 @@ const details = () => ({
defaults[audioIdx] = file.ffProbeData.streams[i].disposition.default === 1
// if we find an audio in the lang
if (languages.includes(file.ffProbeData.streams[i].tags.language)) {
// mark the id and break
firstAudioInLangIdx = audioIdx;
break;
// mark the id of the first track in lang
if (firstAudioInLangIdx === -1) {
firstAudioInLangIdx = audioIdx;
}
}
audioIdx += 1;
}

Loading…
Cancel
Save