WIP - Attempt to add av1 support

For some reason Chrome doesn't detect the codec despite definitely
supporting AV1 decoding.  Nothing telling show up in console,
chrome://webrtc-internals/, or chrome://media-internals/.  Testing
via `docker-compose up`.
This commit is contained in:
Ethan Waldo
2023-01-15 10:26:22 -05:00
parent cfc6bd417f
commit da1eb21408
10 changed files with 164 additions and 19 deletions

View File

@ -62,6 +62,17 @@ func NewVideoPipeline(rtpCodec codec.RTPCodec, display string, pipelineSrc strin
}
switch rtpCodec.Name {
case codec.AV1().Name:
if err := gst.CheckPlugins([]string{"ximagesrc", "vpx"}); err != nil {
return "", err
}
pipelineStr = strings.Join([]string{
fmt.Sprintf(videoSrc, display, fps),
"svtav1enc",
fmt.Sprintf("bitrate=%d", bitrate),
pipelineStr,
}, " ")
case codec.VP8().Name:
if hwenc == "VAAPI" {
if err := gst.CheckPlugins([]string{"ximagesrc", "vaapi"}); err != nil {
@ -105,7 +116,7 @@ func NewVideoPipeline(rtpCodec codec.RTPCodec, display string, pipelineSrc strin
return "", err
}
pipelineStr = fmt.Sprintf(videoSrc+"vp9enc target-bitrate=%d cpu-used=-5 threads=4 deadline=1 keyframe-max-dist=30 auto-alt-ref=true"+pipelineStr, display, fps, bitrate*1000)
pipelineStr = fmt.Sprintf(videoSrc+"vp9enc target-bitrate=%d cpu-used=5 threads=4 deadline=1 keyframe-max-dist=30 auto-alt-ref=true"+pipelineStr, display, fps, bitrate*1000)
case codec.H264().Name:
if err := gst.CheckPlugins([]string{"ximagesrc"}); err != nil {
return "", err

View File

@ -44,6 +44,12 @@ func (Capture) Init(cmd *cobra.Command) error {
return err
}
// DEPRECATED: video codec
cmd.PersistentFlags().Bool("av1", false, "DEPRECATED: use video_codec")
if err := viper.BindPFlag("av1", cmd.PersistentFlags().Lookup("av1")); err != nil {
return err
}
// DEPRECATED: video codec
cmd.PersistentFlags().Bool("vp8", false, "DEPRECATED: use video_codec")
if err := viper.BindPFlag("vp8", cmd.PersistentFlags().Lookup("vp8")); err != nil {
@ -164,7 +170,10 @@ func (s *Capture) Set() {
s.VideoCodec = codec.VP8()
}
if viper.GetBool("vp8") {
if viper.GetBool("av1") {
s.VideoCodec = codec.AV1()
log.Warn().Msg("you are using deprecated config setting 'NEKO_AV1=true', use 'NEKO_VIDEO_CODEC=av1' instead")
} else if viper.GetBool("vp8") {
s.VideoCodec = codec.VP8()
log.Warn().Msg("you are using deprecated config setting 'NEKO_VP8=true', use 'NEKO_VIDEO_CODEC=vp8' instead")
} else if viper.GetBool("vp9") {

View File

@ -27,6 +27,8 @@ func ParseStr(codecName string) (codec RTPCodec, ok bool) {
ok = true
switch strings.ToLower(codecName) {
case AV1().Name:
codec = AV1()
case VP8().Name:
codec = VP8()
case VP9().Name:
@ -62,6 +64,21 @@ func (codec RTPCodec) Register(engine *webrtc.MediaEngine) error {
}, codec.Type)
}
func AV1() RTPCodec {
return RTPCodec{
Name: "av1",
PayloadType: 100,
Type: webrtc.RTPCodecTypeVideo,
Capability: webrtc.RTPCodecCapability{
MimeType: webrtc.MimeTypeAV1,
ClockRate: 90000,
Channels: 0,
SDPFmtpLine: "",
RTCPFeedback: RTCPFeedback,
},
}
}
func VP8() RTPCodec {
return RTPCodec{
Name: "vp8",