131 lines
2.5 KiB
Go
131 lines
2.5 KiB
Go
package model
|
|
|
|
const (
|
|
CodecHEVC = "hevc"
|
|
CodecAVC = "avc"
|
|
)
|
|
|
|
type VideoProfileSettings struct {
|
|
Resolution Resolution // Only for 16:9
|
|
Codec string
|
|
MaxBitrate int
|
|
AvgBitrate int
|
|
}
|
|
|
|
var FFMpegCodecs = map[string]string{
|
|
CodecAVC: "h264_nvenc",
|
|
CodecHEVC: "hevc_nvenc",
|
|
}
|
|
|
|
var HLSCodecs = map[string]string{
|
|
CodecAVC: "avc1.42E01E", //TODO: those are just hardcoded stuff
|
|
CodecHEVC: "hvc1.1.6.L93.B0",
|
|
}
|
|
|
|
func (p VideoProfileSettings) FFMpegCodec() string {
|
|
return FFMpegCodecs[p.Codec]
|
|
}
|
|
|
|
func (p VideoProfileSettings) HLSCodec() string {
|
|
return HLSCodecs[p.Codec]
|
|
}
|
|
|
|
// The bitrate are just random numbers I wrote in...
|
|
var VideoProfiles = map[string]VideoProfileSettings{
|
|
"144p-avc": VideoProfileSettings{
|
|
Resolution: Resolution{
|
|
Width: 176,
|
|
Height: 144,
|
|
},
|
|
MaxBitrate: 70_000,
|
|
AvgBitrate: 50_000,
|
|
Codec: CodecAVC,
|
|
},
|
|
"144p-hevc": VideoProfileSettings{
|
|
Resolution: Resolution{
|
|
Width: 176,
|
|
Height: 144,
|
|
},
|
|
MaxBitrate: 50_000,
|
|
AvgBitrate: 40_000,
|
|
Codec: CodecHEVC,
|
|
},
|
|
"480p-avc": VideoProfileSettings{
|
|
Resolution: Resolution{
|
|
Width: 848,
|
|
Height: 480,
|
|
},
|
|
MaxBitrate: 250_000,
|
|
AvgBitrate: 200_000,
|
|
Codec: CodecAVC,
|
|
},
|
|
"480p-hevc": VideoProfileSettings{
|
|
Resolution: Resolution{
|
|
Width: 848,
|
|
Height: 480,
|
|
},
|
|
MaxBitrate: 200_000,
|
|
AvgBitrate: 170_000,
|
|
Codec: CodecHEVC,
|
|
},
|
|
"720p-avc": VideoProfileSettings{
|
|
Resolution: Resolution{
|
|
Width: 1280,
|
|
Height: 720,
|
|
},
|
|
MaxBitrate: 700_000,
|
|
AvgBitrate: 500_000,
|
|
Codec: CodecAVC,
|
|
},
|
|
"720p-hevc": VideoProfileSettings{
|
|
Resolution: Resolution{
|
|
Width: 1280,
|
|
Height: 720,
|
|
},
|
|
MaxBitrate: 500_000,
|
|
AvgBitrate: 400_000,
|
|
Codec: CodecHEVC,
|
|
},
|
|
"1080p-avc": VideoProfileSettings{
|
|
Resolution: Resolution{
|
|
Width: 1920,
|
|
Height: 1080,
|
|
},
|
|
MaxBitrate: 1_200_000,
|
|
AvgBitrate: 700_000,
|
|
Codec: CodecAVC,
|
|
},
|
|
"1080p-hevc": VideoProfileSettings{
|
|
Resolution: Resolution{
|
|
Width: 1920,
|
|
Height: 1080,
|
|
},
|
|
MaxBitrate: 1_000_000,
|
|
AvgBitrate: 500_000,
|
|
Codec: CodecHEVC,
|
|
},
|
|
// high bitrate version
|
|
"1080p-avc-hbr": VideoProfileSettings{
|
|
Resolution: Resolution{
|
|
Width: 1920,
|
|
Height: 1080,
|
|
},
|
|
MaxBitrate: 4_200_000,
|
|
AvgBitrate: 3_700_000,
|
|
Codec: CodecAVC,
|
|
},
|
|
"1080p-hevc-hbr": VideoProfileSettings{
|
|
Resolution: Resolution{
|
|
Width: 1920,
|
|
Height: 1080,
|
|
},
|
|
MaxBitrate: 4_000_000,
|
|
AvgBitrate: 3_500_000,
|
|
Codec: CodecHEVC,
|
|
},
|
|
}
|
|
|
|
func IsValidVideoProfile(profile string) bool {
|
|
_, ok := VideoProfiles[profile]
|
|
return ok
|
|
}
|