stream: add UseGopSize
parent
ec9900e166
commit
a7968c9279
|
@ -39,6 +39,9 @@ type Config struct {
|
|||
NVENCTemporalAQ bool `json:"nvencTemporalAQ"`
|
||||
NVENCScale string `json:"nvencScale"` // cuda, npp
|
||||
|
||||
// Use transpose for streaming
|
||||
// Use transpose workaround for streaming (VA-API)
|
||||
UseTranspose bool `json:"useTranspose"`
|
||||
|
||||
// Use GOP size workaround for streaming (NVENC)
|
||||
UseGopSize bool `json:"useGopSize"`
|
||||
}
|
||||
|
|
22
stream.go
22
stream.go
|
@ -513,17 +513,33 @@ func (s *Stream) transcode(startId int) {
|
|||
|
||||
// Segmenting specs
|
||||
args = append(args, []string{
|
||||
"-start_number", fmt.Sprintf("%d", startId),
|
||||
"-avoid_negative_ts", "disabled",
|
||||
"-f", "hls",
|
||||
"-hls_flags", "split_by_time",
|
||||
"-hls_time", fmt.Sprintf("%d", s.c.ChunkSize),
|
||||
"-hls_segment_type", "mpegts",
|
||||
"-hls_segment_filename", s.getTsPath(-1),
|
||||
"-force_key_frames", fmt.Sprintf("expr:gte(t,n_forced*%d)", s.c.ChunkSize),
|
||||
"-start_number", fmt.Sprintf("%d", startId),
|
||||
"-",
|
||||
}...)
|
||||
|
||||
// Keyframe specs
|
||||
if s.c.UseGopSize && s.m.probe.FrameRate > 0 {
|
||||
// Fix GOP size
|
||||
args = append(args, []string{
|
||||
"-g", fmt.Sprintf("%d", s.c.ChunkSize*s.m.probe.FrameRate),
|
||||
"-keyint_min", fmt.Sprintf("%d", s.c.ChunkSize*s.m.probe.FrameRate),
|
||||
}...)
|
||||
} else {
|
||||
// Force keyframes every chunk
|
||||
args = append(args, []string{
|
||||
"-force_key_frames", fmt.Sprintf("expr:gte(t,n_forced*%d)", s.c.ChunkSize),
|
||||
}...)
|
||||
}
|
||||
|
||||
// Output to stdout
|
||||
args = append(args, "-")
|
||||
|
||||
// Start the process
|
||||
s.coder = exec.Command(s.c.FFmpeg, args...)
|
||||
log.Printf("%s-%s: %s", s.m.id, s.quality, strings.Join(s.coder.Args[:], " "))
|
||||
|
||||
|
|
Loading…
Reference in New Issue