♻️ 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
|
|
@ -9,7 +9,6 @@ import (
|
||||||
|
|
||||||
"codeberg.org/danjones000/strip-beats/app"
|
"codeberg.org/danjones000/strip-beats/app"
|
||||||
"codeberg.org/danjones000/strip-beats/input/boolean"
|
"codeberg.org/danjones000/strip-beats/input/boolean"
|
||||||
"codeberg.org/danjones000/strip-beats/media"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -25,8 +24,8 @@ var rootCmd = &cobra.Command{
|
||||||
// media.Watch(out.Format.Path)
|
// media.Watch(out.Format.Path)
|
||||||
show := boolean.Choose("Show stream?")
|
show := boolean.Choose("Show stream?")
|
||||||
if show {
|
if show {
|
||||||
stream := media.SelectAudioStream(out)
|
stream := out.WantedAudioStream()
|
||||||
fmt.Printf("Stream %d of %s: %+v\n", stream, out.Format.Path, out.Streams[stream])
|
fmt.Printf("Stream %d of %s: %+v\n", stream.Index, out.Format.Path, stream)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,24 @@ func (p Probe) GetFirstAcceptableAudio() *Stream {
|
||||||
return sts[0]
|
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 {
|
type Stream struct {
|
||||||
Index int
|
Index int
|
||||||
CodecName string `json:"codec_name"`
|
CodecName string `json:"codec_name"`
|
||||||
|
|
@ -130,21 +148,3 @@ func ProbeFile(path string) Probe {
|
||||||
}
|
}
|
||||||
return ret
|
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