init
This commit is contained in:
commit
fa47df6d89
22 changed files with 1724 additions and 0 deletions
6
model/api.go
Normal file
6
model/api.go
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
package model
|
||||
|
||||
type APIMedia struct {
|
||||
Name string `json:"name"`
|
||||
FriendlyName string `json:"friendly_name"`
|
||||
}
|
||||
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
|
||||
}
|
||||
45
model/metadata.go
Normal file
45
model/metadata.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package model
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Chunk struct {
|
||||
FName string `json:"fname"` // just the basename
|
||||
Length float64 `json:"length"`
|
||||
}
|
||||
|
||||
type AudioStream struct {
|
||||
Index int `json:"index"`
|
||||
Lang string `json:"lang"` // there can be multiple instances of the same language! (Frédi és Béni is one example)
|
||||
Title string `json:"title"`
|
||||
Default bool `json:"default"`
|
||||
Codec string `json:"codec"`
|
||||
SampleRate int `json:"sample_rate"`
|
||||
Bitrate int `json:"bitrate"` // !!! <- This is before transcoding (if used!)
|
||||
Channels int `json:"channels"`
|
||||
AudioChunks []Chunk `json:"audio_chunks"`
|
||||
}
|
||||
|
||||
type Resolution struct {
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
}
|
||||
|
||||
func (r Resolution) String() string {
|
||||
return fmt.Sprintf("%dx%d", r.Width, r.Height)
|
||||
}
|
||||
|
||||
type VideoStream struct {
|
||||
Resolution Resolution `json:"resolution"`
|
||||
HLSCodecsString string `json:"hls_codecs_string"` // i.e.: avc1.42E01E
|
||||
PeakBitrate int `json:"peak_bitrate"` // for BANDWIDTH - bits per second
|
||||
AvgBitrate int `json:"avg_bitrate"` // for AVERAGE-BANDWIDTH - bits per second
|
||||
FrameRate float64 `json:"frame_rate"`
|
||||
VideoChunks []Chunk `json:"video_chunks"`
|
||||
}
|
||||
|
||||
type MediaMetadata struct {
|
||||
FriendlyName string `json:"friendly_name"`
|
||||
TargetDuration float64 `json:"target_duration"`
|
||||
VideoStream VideoStream `json:"video_stream"`
|
||||
AudioStreams []AudioStream `json:"audio_streams"`
|
||||
}
|
||||
11
model/slices.go
Normal file
11
model/slices.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package model
|
||||
|
||||
type Slice struct {
|
||||
Name string
|
||||
StartTime float64
|
||||
EndTime float64
|
||||
}
|
||||
|
||||
func (s Slice) Len() float64 {
|
||||
return s.EndTime - s.StartTime
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue