diff --git a/README.md b/README.md index 9487461..302a74c 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,7 @@ SetQuality SetCopyTs SetInputPath SetOutputPath +SetOutputFormat ``` Example ```golang diff --git a/models/media.go b/models/media.go index 6aa48c7..c1e89fc 100644 --- a/models/media.go +++ b/models/media.go @@ -36,6 +36,7 @@ type Mediafile struct { seekTimeInput string inputPath string outputPath string + outputFormat string copyTs bool } @@ -145,6 +146,10 @@ func (m *Mediafile) SetOutputPath(val string) { m.outputPath = val } +func (m *Mediafile) SetOutputFormat(val string) { + m.outputFormat = val +} + func (m *Mediafile) SetMetadata(v Metadata) { m.metadata = v } @@ -259,6 +264,10 @@ func (m *Mediafile) OutputPath() string { return m.outputPath } +func (m *Mediafile) OutputFormat() string { + return m.outputFormat +} + func (m Mediafile) Metadata() Metadata { return m.metadata } @@ -267,7 +276,7 @@ func (m Mediafile) Metadata() Metadata { func (m Mediafile) ToStrCommand() string { var strCommand string - opts := []string{"SeekTimeInput", "DurationInput", "SeekUsingTsInput", "InputPath", "Aspect", "VideoCodec", "FrameRate", "Resolution", "VideoBitRate", "VideoBitRateTolerance", "AudioCodec", "AudioBitRate", "AudioChannels", "VideoMaxBitRate", "VideoMinBitRate", "BufferSize", "Threads", "Preset", "Target", "Duration", "KeyframeInterval", "SeekTime", "Quality", "MuxDelay", "CopyTs", "OutputPath"} + opts := []string{"SeekTimeInput", "DurationInput", "SeekUsingTsInput", "InputPath", "Aspect", "VideoCodec", "FrameRate", "Resolution", "VideoBitRate", "VideoBitRateTolerance", "AudioCodec", "AudioBitRate", "AudioChannels", "VideoMaxBitRate", "VideoMinBitRate", "BufferSize", "Threads", "Preset", "Target", "Duration", "KeyframeInterval", "SeekTime", "Quality", "MuxDelay", "CopyTs", "OutputFormat", "OutputPath"} for _, name := range opts { opt := reflect.ValueOf(&m).MethodByName(fmt.Sprintf("Obtain%s", name)) if (opt != reflect.Value{}) { @@ -451,6 +460,13 @@ func (m *Mediafile) ObtainCopyTs() string { return "" } +func (m *Mediafile) ObtainOutputFormat() string { + if m.outputFormat != "" { + return fmt.Sprintf("-f %s", m.outputFormat) + } + return "" +} + func (m *Mediafile) ObtainMuxDelay() string { return fmt.Sprintf("-muxdelay %d", m.muxDelay) } @@ -462,4 +478,3 @@ func (m *Mediafile) ObtainSeekUsingTsInput() string { return "" } } -