Skip to content

Commit f649609

Browse files
committed
- [#] Choose streams by language, instead of streams index. Closes #9
1 parent 7c9d95a commit f649609

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

ffcvt.go

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -282,31 +282,13 @@ func transcodeFile(inputName string) {
282282
allAudioStreams := regexp.MustCompile(`Stream #0:.+: Audio: (.+)`).
283283
FindAllStringSubmatch(fsinfo, -1)
284284
if len(allAudioStreams) > 1 {
285-
// then find the designated audio stream language
286-
audioStreams := regexp.
287-
MustCompile(`Stream #(.+)\(` + Opts.Lang + `\): Audio: (.+)`).
288-
FindStringSubmatch(fsinfo)
289-
if len(audioStreams) >= 1 {
290-
// and use the 1st audio stream of the designated language
291-
// via *temporarily* tweaking AEP/VEP/SEP setting
292-
oldAEP, oldVEP, oldSEP = Opts.AEP, Opts.VEP, Opts.SEP
293-
oldEPUsed = true
294-
debug(audioStreams[1], 3)
295-
296-
Opts.AEP += " -map " + audioStreams[1]
297-
dealSurroundSound(audioStreams[2])
298-
// when `-map` is used (for audio), then all else need mapping as well
299-
videoStreams := regexp.MustCompile(`Stream #(.+?)(\(.+\))*: Video: `).
300-
FindStringSubmatch(fsinfo)
301-
Opts.VEP += " -map " + videoStreams[1]
302-
subtitleStreams := regexp.MustCompile(`Stream #(.+)\(.+\): Subtitle: `).
303-
FindAllStringSubmatch(fsinfo, -1)
304-
// keep all subtitle streams
305-
for _, subtitleStream := range subtitleStreams {
306-
Opts.SEP += " -map " + subtitleStream[1]
307-
}
308-
}
309-
// else: designated audio language not found, use `default` instead
285+
// then use the designated audio stream language
286+
// via *temporarily* using the AEP/VEP/SEP setting
287+
oldAEP, oldVEP, oldSEP = Opts.AEP, Opts.VEP, Opts.SEP
288+
oldEPUsed = true
289+
Opts.VEP += " -map 0:v"
290+
Opts.AEP += " -map 0:a:m:language:" + Opts.Lang
291+
Opts.SEP += " -map 0:s"
310292
} else {
311293
debug(inputName+" has single audio stream", 2)
312294
dealSurroundSound(allAudioStreams[0][1])

0 commit comments

Comments
 (0)