More tuning
parent
2c4575171f
commit
3408e48db9
15
stream.go
15
stream.go
|
@ -41,6 +41,7 @@ type Stream struct {
|
||||||
|
|
||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
chunks map[int]*Chunk
|
chunks map[int]*Chunk
|
||||||
|
seenChunks map[int]bool // only for stdout reader
|
||||||
|
|
||||||
coder *exec.Cmd
|
coder *exec.Cmd
|
||||||
|
|
||||||
|
@ -94,6 +95,7 @@ func (s *Stream) clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
s.chunks = make(map[int]*Chunk)
|
s.chunks = make(map[int]*Chunk)
|
||||||
|
s.seenChunks = make(map[int]bool)
|
||||||
s.goal = 0
|
s.goal = 0
|
||||||
|
|
||||||
if s.coder != nil {
|
if s.coder != nil {
|
||||||
|
@ -347,7 +349,7 @@ func (s *Stream) transcode(startId int) {
|
||||||
"-avoid_negative_ts", "disabled",
|
"-avoid_negative_ts", "disabled",
|
||||||
"-f", "hls",
|
"-f", "hls",
|
||||||
"-hls_time", fmt.Sprintf("%d", s.c.chunkSize),
|
"-hls_time", fmt.Sprintf("%d", s.c.chunkSize),
|
||||||
"-g", "64", "-keyint_min", "64",
|
"-force_key_frames", fmt.Sprintf("expr:gte(t,n_forced*%d)", s.c.chunkSize),
|
||||||
"-hls_segment_type", "mpegts",
|
"-hls_segment_type", "mpegts",
|
||||||
"-start_number", fmt.Sprintf("%d", startId),
|
"-start_number", fmt.Sprintf("%d", startId),
|
||||||
"-hls_segment_filename", s.getTsPath(-1),
|
"-hls_segment_filename", s.getTsPath(-1),
|
||||||
|
@ -425,9 +427,6 @@ func (s *Stream) monitorTranscodeOutput(cmdStdOut io.ReadCloser, startAt float64
|
||||||
l := string(line)
|
l := string(line)
|
||||||
|
|
||||||
if strings.Contains(l, ".ts") {
|
if strings.Contains(l, ".ts") {
|
||||||
// Debug
|
|
||||||
log.Printf("%s-%s: recv %s", s.m.id, s.quality, l)
|
|
||||||
|
|
||||||
// 1080p-000003.ts
|
// 1080p-000003.ts
|
||||||
idx := strings.Split(strings.Split(l, "-")[1], ".")[0]
|
idx := strings.Split(strings.Split(l, "-")[1], ".")[0]
|
||||||
id, err := strconv.Atoi(idx)
|
id, err := strconv.Atoi(idx)
|
||||||
|
@ -435,6 +434,14 @@ func (s *Stream) monitorTranscodeOutput(cmdStdOut io.ReadCloser, startAt float64
|
||||||
log.Println("Error parsing chunk id")
|
log.Println("Error parsing chunk id")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.seenChunks[id] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
s.seenChunks[id] = true
|
||||||
|
|
||||||
|
// Debug
|
||||||
|
log.Printf("%s-%s: recv %s", s.m.id, s.quality, l)
|
||||||
|
|
||||||
func() {
|
func() {
|
||||||
s.mutex.Lock()
|
s.mutex.Lock()
|
||||||
defer s.mutex.Unlock()
|
defer s.mutex.Unlock()
|
||||||
|
|
Loading…
Reference in New Issue