mirror of
https://github.com/xfrr/goffmpeg.git
synced 2025-10-24 00:03:09 +08:00
Added input path to mediafile and seek using TS option for input
This commit is contained in:
@@ -30,6 +30,9 @@ type Mediafile struct {
|
||||
seekTime string
|
||||
quality int
|
||||
metadata Metadata
|
||||
muxDelay int
|
||||
seekUsingTsInput bool
|
||||
inputPath string
|
||||
}
|
||||
|
||||
/*** SETTERS ***/
|
||||
@@ -114,6 +117,14 @@ func (m *Mediafile) SetQuality(v int) {
|
||||
m.quality = v
|
||||
}
|
||||
|
||||
func (m *Mediafile) SetSeekUsingTsInput(val bool) {
|
||||
m.seekUsingTsInput = val
|
||||
}
|
||||
|
||||
func (m *Mediafile) SetInputPath(val string) {
|
||||
m.inputPath = val
|
||||
}
|
||||
|
||||
func (m *Mediafile) SetMetadata(v Metadata) {
|
||||
m.metadata = v
|
||||
}
|
||||
@@ -200,6 +211,18 @@ func (m Mediafile) Quality() int {
|
||||
return m.quality
|
||||
}
|
||||
|
||||
func (m Mediafile) MuxDelay() int {
|
||||
return m.muxDelay
|
||||
}
|
||||
|
||||
func (m Mediafile) SeekUsingTsInput() bool {
|
||||
return m.seekUsingTsInput
|
||||
}
|
||||
|
||||
func (m Mediafile) InputPath() string {
|
||||
return m.inputPath
|
||||
}
|
||||
|
||||
func (m Mediafile) Metadata() Metadata {
|
||||
return m.metadata
|
||||
}
|
||||
@@ -208,7 +231,7 @@ func (m Mediafile) Metadata() Metadata {
|
||||
func (m Mediafile) ToStrCommand() string {
|
||||
var strCommand string
|
||||
|
||||
opts := []string{"Aspect", "VideoCodec", "FrameRate", "Resolution", "VideoBitRate", "VideoBitRateTolerance", "AudioCodec", "AudioBitRate", "AudioChannels", "VideoMaxBitRate", "VideoMinBitRate", "BufferSize", "Threads", "Preset", "Target", "Duration", "KeyframeInterval", "SeekTime", "Quality"}
|
||||
opts := []string{"SeekUsingTsInput", "InputPath", "Aspect", "VideoCodec", "FrameRate", "Resolution", "VideoBitRate", "VideoBitRateTolerance", "AudioCodec", "AudioBitRate", "AudioChannels", "VideoMaxBitRate", "VideoMinBitRate", "BufferSize", "Threads", "Preset", "Target", "Duration", "KeyframeInterval", "SeekTime", "Quality", "ObtainMuxDelay"}
|
||||
for _, name := range opts {
|
||||
opt := reflect.ValueOf(&m).MethodByName(fmt.Sprintf("Obtain%s", name))
|
||||
if (opt != reflect.Value{}) {
|
||||
@@ -244,6 +267,10 @@ func (m *Mediafile) ObtainAspect() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Mediafile) ObtainInputPath() string {
|
||||
return fmt.Sprintf("-i \"%s\"", m.inputPath)
|
||||
}
|
||||
|
||||
func (m *Mediafile) ObtainVideoCodec() string {
|
||||
if m.videoCodec != "" {
|
||||
return fmt.Sprintf("-vcodec %s", m.videoCodec)
|
||||
@@ -362,3 +389,15 @@ func (m *Mediafile) ObtainPreset() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Mediafile) ObtainMuxDelay() string {
|
||||
return fmt.Sprintf("-muxdelay %d", m.muxDelay)
|
||||
}
|
||||
|
||||
func (m *Mediafile) ObtainSeekUsingTsInput() string {
|
||||
if m.seekUsingTsInput {
|
||||
return "-seek_timestamp 1"
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,6 @@ import (
|
||||
|
||||
type Transcoder struct {
|
||||
process *exec.Cmd
|
||||
inputPath string
|
||||
outputPath string
|
||||
mediafile *models.Mediafile
|
||||
configuration ffmpeg.Configuration
|
||||
@@ -28,10 +27,6 @@ func (t *Transcoder) SetProccess(v *exec.Cmd) {
|
||||
t.process = v
|
||||
}
|
||||
|
||||
func (t *Transcoder) SetInputPath(v string) {
|
||||
t.inputPath = v
|
||||
}
|
||||
|
||||
func (t *Transcoder) SetOutputPath(v string) {
|
||||
t.outputPath = v
|
||||
}
|
||||
@@ -50,10 +45,6 @@ func (t Transcoder) Process() *exec.Cmd {
|
||||
return t.process
|
||||
}
|
||||
|
||||
func (t Transcoder) InputPath() string {
|
||||
return t.inputPath
|
||||
}
|
||||
|
||||
func (t Transcoder) OutputPath() string {
|
||||
return t.outputPath
|
||||
}
|
||||
@@ -73,7 +64,7 @@ func (t Transcoder) FFprobeExec() string {
|
||||
func (t Transcoder) GetCommand() string {
|
||||
var rcommand string
|
||||
|
||||
rcommand = fmt.Sprintf("%s -y -i \"%s\" ", t.configuration.FfmpegBin, t.inputPath)
|
||||
rcommand = fmt.Sprintf("%s -y ", t.configuration.FfmpegBin)
|
||||
|
||||
media := t.mediafile
|
||||
|
||||
@@ -134,9 +125,9 @@ func (t *Transcoder) Initialize(inputPath string, outputPath string) (error) {
|
||||
// Set new Mediafile
|
||||
MediaFile := new(models.Mediafile)
|
||||
MediaFile.SetMetadata(Metadata)
|
||||
|
||||
MediaFile.SetInputPath(inputPath)
|
||||
// Set transcoder configuration
|
||||
t.SetInputPath(inputPath)
|
||||
|
||||
t.SetOutputPath(outputPath)
|
||||
t.SetMediaFile(MediaFile)
|
||||
t.SetConfiguration(configuration)
|
||||
|
Reference in New Issue
Block a user