Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add audio filter #29

Merged
merged 3 commits into from
Apr 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions models/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,24 @@ type Mediafile struct {
httpKeepAlive bool
streamIds map[int]string
metadata Metadata
filter string
videoFilter string
audioFilter string
skipVideo bool
skipAudio bool
}

/*** SETTERS ***/
func (m *Mediafile) SetAudioFilter(v string) {
m.audioFilter = v
}

func (m *Mediafile) SetVideoFilter(v string) {
m.videoFilter = v
}

// Deprecated: Use SetVideoFilter instead.
func (m *Mediafile) SetFilter(v string) {
m.filter = v
m.SetVideoFilter(v)
}

func (m *Mediafile) SetAspect(v string) {
Expand Down Expand Up @@ -254,8 +264,17 @@ func (m *Mediafile) SetMetadata(v Metadata) {

/*** GETTERS ***/

// Deprecated: Use VideoFilter instead.
func (m *Mediafile) Filter() string {
return m.filter
return m.VideoFilter()
}

func (m *Mediafile) VideoFilter() string {
return m.videoFilter
}

func (m *Mediafile) AudioFilter() string {
return m.audioFilter
}

func (m *Mediafile) Aspect() string {
Expand Down Expand Up @@ -498,7 +517,8 @@ func (m *Mediafile) ToStrCommand() []string {
"HlsListSize",
"HlsSegmentDuration",
"HlsPlaylistType",
"Filter",
"AudioFilter",
"VideoFilter",
"HttpMethod",
"HttpKeepAlive",
"OutputPath",
Expand All @@ -517,9 +537,16 @@ func (m *Mediafile) ToStrCommand() []string {
return strCommand
}

func (m *Mediafile) ObtainFilter() []string {
if m.filter != "" {
return []string{"-vf", m.filter}
func (m *Mediafile) ObtainAudioFilter() []string {
if m.audioFilter != "" {
return []string{"-af", m.audioFilter}
}
return nil
}

func (m *Mediafile) ObtainVideoFilter() []string {
if m.videoFilter != "" {
return []string{"-vf", m.videoFilter}
}
return nil
}
Expand Down