From 88f3f7a9aeb56f37bc4feaaf2b2ddb509fc19e42 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 30 Mar 2024 23:04:22 +0100 Subject: [PATCH] Include same quality transcoded level if codecs are differents --- transcoder/src/filestream.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/transcoder/src/filestream.go b/transcoder/src/filestream.go index ca61ed51..dd8c2a03 100644 --- a/transcoder/src/filestream.go +++ b/transcoder/src/filestream.go @@ -74,8 +74,8 @@ func (fs *FileStream) GetMaster() string { break } } - // TODO: also check if the codec is valid in a hls before putting transmux - if true { + // original stream + { bitrate := float64(fs.Info.Video.Bitrate) master += "#EXT-X-STREAM-INF:" master += fmt.Sprintf("AVERAGE-BANDWIDTH=%d,", int(math.Min(bitrate*0.8, float64(transmux_quality.AverageBitrate())))) @@ -88,14 +88,21 @@ func (fs *FileStream) GetMaster() string { master += "CLOSED-CAPTIONS=NONE\n" master += fmt.Sprintf("./%s/index.m3u8\n", Original) } + aspectRatio := float32(fs.Info.Video.Width) / float32(fs.Info.Video.Height) + transmux_codec := "avc1.640028" + for _, quality := range Qualities { - if quality.Height() < fs.Info.Video.Quality.Height() { + same_codec := fs.Info.Video.MimeCodec != nil && *fs.Info.Video.MimeCodec == transmux_codec + inc_lvl := quality.Height() < fs.Info.Video.Quality.Height() || + (quality.Height() == fs.Info.Video.Quality.Height() && !same_codec) + + if inc_lvl { master += "#EXT-X-STREAM-INF:" master += fmt.Sprintf("AVERAGE-BANDWIDTH=%d,", quality.AverageBitrate()) master += fmt.Sprintf("BANDWIDTH=%d,", quality.MaxBitrate()) master += fmt.Sprintf("RESOLUTION=%dx%d,", int(aspectRatio*float32(quality.Height())+0.5), quality.Height()) - master += "CODECS=\"avc1.640028\"," + master += fmt.Sprintf("CODECS=\"%s\",", transmux_codec) master += "AUDIO=\"audio\"," master += "CLOSED-CAPTIONS=NONE\n" master += fmt.Sprintf("./%s/index.m3u8\n", quality)