♻️ Convert SelectAudioStream into a method of Probe
This commit is contained in:
parent
d91fc4b9ec
commit
d87422488c
2 changed files with 20 additions and 21 deletions
|
|
@ -62,6 +62,24 @@ func (p Probe) GetFirstAcceptableAudio() *Stream {
|
|||
return sts[0]
|
||||
}
|
||||
|
||||
func (pr Probe) WantedAudioStream() *Stream {
|
||||
count := pr.GetAudioCount()
|
||||
if count < 1 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if count == 1 {
|
||||
return pr.GetFirstAudio()
|
||||
}
|
||||
|
||||
pref := pr.GetFirstAcceptableAudio()
|
||||
if pref != nil {
|
||||
return pref
|
||||
}
|
||||
|
||||
return pr.GetFirstAudio()
|
||||
}
|
||||
|
||||
type Stream struct {
|
||||
Index int
|
||||
CodecName string `json:"codec_name"`
|
||||
|
|
@ -130,21 +148,3 @@ func ProbeFile(path string) Probe {
|
|||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func SelectAudioStream(pr Probe) int {
|
||||
count := pr.GetAudioCount()
|
||||
if count < 1 {
|
||||
return -1
|
||||
}
|
||||
|
||||
if count == 1 {
|
||||
return pr.GetFirstAudio().Index
|
||||
}
|
||||
|
||||
pref := pr.GetFirstAcceptableAudio()
|
||||
if pref != nil {
|
||||
return pref.Index
|
||||
}
|
||||
|
||||
return pr.GetFirstAudio().Index
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue