Skip to content

Commit

Permalink
Merge pull request #14 from rohitggarg/master
Browse files Browse the repository at this point in the history
Offset and stream id support for precision slicing and placement
  • Loading branch information
xfrr authored Jun 21, 2018
2 parents 21d8833 + 53621db commit 48cfb58
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions models/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ type Mediafile struct {
outputFormat string
copyTs bool
nativeFramerateInput bool
inputInitialOffset string
rtmpLive string
hlsPlaylistType string
hlsSegmentDuration int
streamIds map[int]string
metadata Metadata
}

Expand Down Expand Up @@ -189,6 +191,14 @@ func (m *Mediafile) SetHlsPlaylistType(val string) {
m.hlsPlaylistType = val
}

func (m *Mediafile) SetInputInitialOffset(val string) {
m.inputInitialOffset = val
}

func (m *Mediafile) SetStreamIds(val map[int]string) {
m.streamIds = val
}

func (m *Mediafile) SetMetadata(v Metadata) {
m.metadata = v
}
Expand Down Expand Up @@ -339,6 +349,14 @@ func (m *Mediafile) HlsPlaylistType() string {
return m.hlsPlaylistType
}

func (m *Mediafile) InputInitialOffset() string {
return m.inputInitialOffset
}

func (m *Mediafile) StreamIds() map[int]string {
return m.streamIds
}

func (m *Mediafile) Metadata() Metadata {
return m.metadata
}
Expand All @@ -353,6 +371,7 @@ func (m *Mediafile) ToStrCommand() string {
"NativeFramerateInput",
"DurationInput",
"RtmpLive",
"InputInitialOffset",
"InputPath",

"Aspect",
Expand All @@ -379,6 +398,7 @@ func (m *Mediafile) ToStrCommand() string {
"SeekTime",
"Duration",
"CopyTs",
"StreamIds",
"OutputFormat",
"HlsSegmentDuration",
"HlsPlaylistType",
Expand Down Expand Up @@ -638,10 +658,29 @@ func (m *Mediafile) ObtainHlsPlaylistType() string {
}
}

func (m *Mediafile) ObtainInputInitialOffset() string {
if m.inputInitialOffset != "" {
return fmt.Sprintf("-itsoffset %s", m.inputInitialOffset)
} else {
return ""
}
}

func (m *Mediafile) ObtainHlsSegmentDuration() string {
if m.hlsSegmentDuration != 0 {
return fmt.Sprintf("-hls_time %d", m.hlsSegmentDuration)
} else {
return ""
}
}

func (m *Mediafile) ObtainStreamIds() string {
if m.streamIds != nil && len(m.streamIds) != 0 {
result := []string{}
for i, val := range m.streamIds {
result = append(result, fmt.Sprintf("-streamid %d:%s", i, val))
}
return strings.Join(result, " ")
}
return ""
}
1 change: 1 addition & 0 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Metadata struct {

type Streams struct {
Index int
ID string `json:"id"`
CodecName string `json:"codec_name"`
CodecLongName string `json:"codec_long_name"`
Profile string `json:"profile"`
Expand Down

0 comments on commit 48cfb58

Please sign in to comment.