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 2 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
43 changes: 38 additions & 5 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 @@ -499,6 +518,8 @@ func (m *Mediafile) ToStrCommand() []string {
"HlsSegmentDuration",
"HlsPlaylistType",
"Filter",
timotto marked this conversation as resolved.
Show resolved Hide resolved
"AudioFilter",
"VideoFilter",
"HttpMethod",
"HttpKeepAlive",
"OutputPath",
Expand All @@ -517,9 +538,21 @@ func (m *Mediafile) ToStrCommand() []string {
return strCommand
}

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

// Deprecated: Use ObtainVideoFilter instead.
func (m *Mediafile) ObtainFilter() []string {
timotto marked this conversation as resolved.
Show resolved Hide resolved
if m.filter != "" {
return []string{"-vf", m.filter}
return m.ObtainVideoFilter()
}

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