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 support for -compression_level, -map_metadata and -metadata. #46

Merged
merged 3 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ SetHttpMethod
SetHttpKeepAlive
SetOutputPath
SetOutputFormat
SetAudioFilter
SetAudioVariableBitrate
SetCompressionLevel
SetFilter
SetInputInitialOffset
SetInputPipeCommand
SetMapMetadata
SetMetadata
SetStreamIds
SetTags
SetVideoFilter
```
Example
```golang
Expand Down
57 changes: 56 additions & 1 deletion models/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ type Mediafile struct {
audioFilter string
skipVideo bool
skipAudio bool
compressionLevel int
mapMetadata string
tags map[string]string
encryptionKey string
movflags string
bframe int
Expand Down Expand Up @@ -334,6 +337,18 @@ func (m *Mediafile) SetMetadata(v Metadata) {
m.metadata = v
}

func (m *Mediafile) SetCompressionLevel(val int) {
m.compressionLevel = val
}

func (m *Mediafile) SetMapMetadata(val string) {
m.mapMetadata = val
}

func (m *Mediafile) SetTags(val map[string]string) {
m.tags = val
}

func (m *Mediafile) SetMovFlags(v string) {
m.movflags = v
}
Expand Down Expand Up @@ -597,6 +612,18 @@ func (m *Mediafile) Metadata() Metadata {
return m.metadata
}

func (m *Mediafile) CompressionLevel() int {
return m.compressionLevel
}

func (m *Mediafile) MapMetadata() string {
return m.mapMetadata
}

func (m *Mediafile) Tags() map[string]string {
return m.tags
}

func (m *Mediafile) SetEncryptionKey(v string) {
m.encryptionKey = v
}
Expand All @@ -620,7 +647,6 @@ func (m *Mediafile) ToStrCommand() []string {
"InputPath",
"InputPipe",
"HideBanner",

"Aspect",
"Resolution",
"FrameRate",
Expand Down Expand Up @@ -665,11 +691,15 @@ func (m *Mediafile) ToStrCommand() []string {
"VideoFilter",
"HttpMethod",
"HttpKeepAlive",
"CompressionLevel",
"MapMetadata",
"Tags",
"EncryptionKey",
"OutputPath",
"Bframe",
"MovFlags",
}

for _, name := range opts {
opt := reflect.ValueOf(m).MethodByName(fmt.Sprintf("Obtain%s", name))
if (opt != reflect.Value{}) {
Expand Down Expand Up @@ -1097,6 +1127,20 @@ func (m *Mediafile) ObtainStreamIds() []string {
return nil
}

func (m *Mediafile) ObtainCompressionLevel() []string {
if m.compressionLevel != 0 {
return []string{"-compression_level", fmt.Sprintf("%d", m.compressionLevel)}
}
return nil
}

func (m *Mediafile) ObtainMapMetadata() []string {
if m.mapMetadata != "" {
return []string{"-map_metadata", m.mapMetadata}
}
return nil
}

func (m *Mediafile) ObtainEncryptionKey() []string {
return []string{"-hls_key_info_file", m.encryptionKey}
}
Expand All @@ -1108,6 +1152,17 @@ func (m *Mediafile) ObtainBframe() []string {
return nil
}

func (m *Mediafile) ObtainTags() []string {
if m.tags != nil && len(m.tags) != 0 {
result := []string{}
for key, val := range m.tags {
result = append(result, []string{"-metadata", fmt.Sprintf("%s=%s", key, val)}...)
}
return result
}
return nil
}

func (m *Mediafile) ObtainMovFlags() []string {
if m.movflags != "" {
return []string{"-movflags", m.movflags}
Expand Down