Skip to content

Commit

Permalink
Merge pull request #7 from rohitggarg/master
Browse files Browse the repository at this point in the history
Added native framerate option
  • Loading branch information
xfrr authored May 29, 2018
2 parents acd7beb + 8a91256 commit c405ed1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ SetSeekUsingTsInput
SetQuality
SetCopyTs
SetInputPath
SetNativeFramerateInput
SetOutputPath
SetOutputFormat
```
Expand Down
22 changes: 19 additions & 3 deletions models/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Mediafile struct {
outputPath string
outputFormat string
copyTs bool
nativeFramerateInput bool
}

/*** SETTERS ***/
Expand Down Expand Up @@ -150,6 +151,10 @@ func (m *Mediafile) SetOutputFormat(val string) {
m.outputFormat = val
}

func (m *Mediafile) SetNativeFramerateInput(val bool) {
m.nativeFramerateInput = val
}

func (m *Mediafile) SetMetadata(v Metadata) {
m.metadata = v
}
Expand Down Expand Up @@ -268,6 +273,10 @@ func (m *Mediafile) OutputFormat() string {
return m.outputFormat
}

func (m *Mediafile) NativeFramerateInput() bool {
return m.nativeFramerateInput
}

func (m Mediafile) Metadata() Metadata {
return m.metadata
}
Expand All @@ -276,7 +285,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", "OutputFormat", "OutputPath"}
opts := []string{"SeekTimeInput", "DurationInput", "SeekUsingTsInput", "NativeFramerateInput", "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{}) {
Expand Down Expand Up @@ -316,13 +325,20 @@ func (m *Mediafile) ObtainInputPath() string {
return fmt.Sprintf("-i \"%s\"", m.inputPath)
}

func (m *Mediafile) ObtainNativeFramerateInput() string {
if m.nativeFramerateInput {
return "-re"
}
return ""
}

func (m *Mediafile) ObtainOutputPath() string {
return fmt.Sprintf("\"%s\"", m.outputPath)
}

func (m *Mediafile) ObtainVideoCodec() string {
if m.videoCodec != "" {
return fmt.Sprintf("-vcodec %s", m.videoCodec)
return fmt.Sprintf("-c:v %s", m.videoCodec)
}
return ""
}
Expand Down Expand Up @@ -350,7 +366,7 @@ func (m *Mediafile) ObtainVideoBitRate() string {

func (m *Mediafile) ObtainAudioCodec() string {
if m.audioCodec != "" {
return fmt.Sprintf("-acodec %s", m.audioCodec)
return fmt.Sprintf("-c:a %s", m.audioCodec)
}
return ""
}
Expand Down

0 comments on commit c405ed1

Please sign in to comment.