Skip to content

Commit

Permalink
add color_transfer in video and count streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Насыров Юрий Ринатович committed Oct 31, 2024
1 parent e5dd79a commit 9071dec
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions probedata.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type Stream struct {
Level int `json:"level,omitempty"`
ColorRange string `json:"color_range,omitempty"`
ColorSpace string `json:"color_space,omitempty"`
ColorTransfer string `json:"color_transfer,omitempty"`
SampleFmt string `json:"sample_fmt,omitempty"`
SampleRate string `json:"sample_rate,omitempty"`
Channels int `json:"channels,omitempty"`
Expand Down Expand Up @@ -181,6 +182,42 @@ func (p *ProbeData) FirstAttachmentStream() *Stream {
return p.firstStream(StreamAttachment)
}

// CountVideoStreams returns the count of the video streams
func (p *ProbeData) CountVideoStreams() uint32 {
return p.countStreams(StreamVideo)
}

// CountAudioStreams returns the count of the audio streams
func (p *ProbeData) CountAudioStreams() uint32 {
return p.countStreams(StreamAudio)
}

// CountSubtitleStreams returns the count of the subtitle streams
func (p *ProbeData) CountSubtitleStreams() uint32 {
return p.countStreams(StreamSubtitle)
}

// CountDataStreams returns the count of the data streams
func (p *ProbeData) CountDataStreams() uint32 {
return p.countStreams(StreamData)
}

// CountAttachmentStreams returns the count of the attacment streams
func (p *ProbeData) CountAttachmentStreams() uint32 {
return p.countStreams(StreamAttachment)
}

func (p *ProbeData) countStreams(streamType StreamType) uint32 {
count := uint32(0)
for _, v := range p.Streams {
if v.CodecType == string(streamType) {
count++
}
}

return count
}

func (p *ProbeData) firstStream(streamType StreamType) *Stream {
for _, s := range p.Streams {
if s == nil {
Expand Down

0 comments on commit 9071dec

Please sign in to comment.