init
This commit is contained in:
commit
fa47df6d89
22 changed files with 1724 additions and 0 deletions
131
model/const.go
Normal file
131
model/const.go
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue