Adjust bitrates

monorepo
Varun Patil 2022-11-12 02:09:09 -08:00
parent ae1c4ae682
commit 5b5a5afe78
2 changed files with 12 additions and 7 deletions

View File

@ -58,10 +58,10 @@ func NewManager(c *Config, path string, id string, close chan string) (*Manager,
m.numChunks = int(math.Ceil(m.probe.Duration.Seconds() / float64(c.chunkSize)))
// Possible streams
m.streams["360p"] = &Stream{c: c, m: m, quality: "360p", height: 360, width: 640, bitrate: 800000}
m.streams["480p"] = &Stream{c: c, m: m, quality: "480p", height: 480, width: 640, bitrate: 1500000}
m.streams["720p"] = &Stream{c: c, m: m, quality: "720p", height: 720, width: 1280, bitrate: 3000000}
m.streams["1080p"] = &Stream{c: c, m: m, quality: "1080p", height: 1080, width: 1920, bitrate: 5000000}
m.streams["360p"] = &Stream{c: c, m: m, quality: "360p", height: 360, width: 640, bitrate: 750000}
m.streams["480p"] = &Stream{c: c, m: m, quality: "480p", height: 480, width: 640, bitrate: 1000000}
m.streams["720p"] = &Stream{c: c, m: m, quality: "720p", height: 720, width: 1280, bitrate: 2500000}
m.streams["1080p"] = &Stream{c: c, m: m, quality: "1080p", height: 1080, width: 1920, bitrate: 4500000}
m.streams["1440p"] = &Stream{c: c, m: m, quality: "1440p", height: 1440, width: 2560, bitrate: 9000000}
m.streams["2160p"] = &Stream{c: c, m: m, quality: "2160p", height: 2160, width: 3840, bitrate: 14000000}

View File

@ -307,8 +307,7 @@ func (s *Stream) transcode(startId int) {
if s.quality != "max" {
args = append(args, []string{
"-vf", scale,
"-maxrate", fmt.Sprintf("%dk", s.bitrate/1000),
"-bufsize", fmt.Sprintf("%dK", s.bitrate/3000),
"-b:v", fmt.Sprintf("%dk", s.bitrate/1000),
}...)
}
@ -327,9 +326,15 @@ func (s *Stream) transcode(startId int) {
}
// Audio
ab := "192k"
if s.bitrate < 1000000 {
ab = "64k"
} else if s.bitrate < 3000000 {
ab = "128k"
}
args = append(args, []string{
"-c:a", "aac",
"-b:a", "192k",
"-b:a", ab,
}...)
// Segmenting specs