mirror of
https://github.com/owncast/owncast.git
synced 2024-11-28 11:09:01 +03:00
Use VA-API hardware scaling
This commit is contained in:
parent
9b2f45aa18
commit
f4516015c2
2 changed files with 42 additions and 3 deletions
|
@ -16,6 +16,7 @@ type Codec interface {
|
||||||
DisplayName() string
|
DisplayName() string
|
||||||
GlobalFlags() string
|
GlobalFlags() string
|
||||||
PixelFormat() string
|
PixelFormat() string
|
||||||
|
Scaler() string
|
||||||
ExtraArguments() string
|
ExtraArguments() string
|
||||||
ExtraFilters() string
|
ExtraFilters() string
|
||||||
VariantFlags(v *HLSVariant) string
|
VariantFlags(v *HLSVariant) string
|
||||||
|
@ -53,6 +54,11 @@ func (c *Libx264Codec) PixelFormat() string {
|
||||||
return "yuv420p" //nolint:goconst
|
return "yuv420p" //nolint:goconst
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scaler is the scaler used for resizing the video in the transcoder.
|
||||||
|
func (c *Libx264Codec) Scaler() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
||||||
func (c *Libx264Codec) ExtraArguments() string {
|
func (c *Libx264Codec) ExtraArguments() string {
|
||||||
return strings.Join([]string{
|
return strings.Join([]string{
|
||||||
|
@ -117,6 +123,11 @@ func (c *OmxCodec) PixelFormat() string {
|
||||||
return "yuv420p"
|
return "yuv420p"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scaler is the scaler used for resizing the video in the transcoder.
|
||||||
|
func (c *OmxCodec) Scaler() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
||||||
func (c *OmxCodec) ExtraArguments() string {
|
func (c *OmxCodec) ExtraArguments() string {
|
||||||
return strings.Join([]string{
|
return strings.Join([]string{
|
||||||
|
@ -183,6 +194,11 @@ func (c *VaapiCodec) PixelFormat() string {
|
||||||
return "vaapi_vld"
|
return "vaapi_vld"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scaler is the scaler used for resizing the video in the transcoder.
|
||||||
|
func (c *VaapiCodec) Scaler() string {
|
||||||
|
return "scale_vaapi"
|
||||||
|
}
|
||||||
|
|
||||||
// ExtraFilters are the extra filters required for this codec in the transcoder.
|
// ExtraFilters are the extra filters required for this codec in the transcoder.
|
||||||
func (c *VaapiCodec) ExtraFilters() string {
|
func (c *VaapiCodec) ExtraFilters() string {
|
||||||
return ""
|
return ""
|
||||||
|
@ -245,6 +261,11 @@ func (c *NvencCodec) PixelFormat() string {
|
||||||
return "yuv420p"
|
return "yuv420p"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scaler is the scaler used for resizing the video in the transcoder.
|
||||||
|
func (c *NvencCodec) Scaler() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
||||||
func (c *NvencCodec) ExtraArguments() string {
|
func (c *NvencCodec) ExtraArguments() string {
|
||||||
return ""
|
return ""
|
||||||
|
@ -304,6 +325,11 @@ func (c *QuicksyncCodec) PixelFormat() string {
|
||||||
return "nv12"
|
return "nv12"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scaler is the scaler used for resizing the video in the transcoder.
|
||||||
|
func (c *QuicksyncCodec) Scaler() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
||||||
func (c *QuicksyncCodec) ExtraArguments() string {
|
func (c *QuicksyncCodec) ExtraArguments() string {
|
||||||
return ""
|
return ""
|
||||||
|
@ -362,6 +388,11 @@ func (c *Video4Linux) PixelFormat() string {
|
||||||
return "nv21"
|
return "nv21"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scaler is the scaler used for resizing the video in the transcoder.
|
||||||
|
func (c *Video4Linux) Scaler() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
// ExtraArguments are the extra arguments used with this codec in the transcoder.
|
||||||
func (c *Video4Linux) ExtraArguments() string {
|
func (c *Video4Linux) ExtraArguments() string {
|
||||||
return ""
|
return ""
|
||||||
|
@ -421,6 +452,11 @@ func (c *VideoToolboxCodec) PixelFormat() string {
|
||||||
return "nv12"
|
return "nv12"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scaler is the scaler used for resizing the video in the transcoder.
|
||||||
|
func (c *VideoToolboxCodec) Scaler() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// ExtraFilters are the extra filters required for this codec in the transcoder.
|
// ExtraFilters are the extra filters required for this codec in the transcoder.
|
||||||
func (c *VideoToolboxCodec) ExtraFilters() string {
|
func (c *VideoToolboxCodec) ExtraFilters() string {
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -300,7 +300,7 @@ func (v *HLSVariant) getVariantString(t *Transcoder) string {
|
||||||
if (v.videoSize.Width != 0 || v.videoSize.Height != 0) && !v.isVideoPassthrough {
|
if (v.videoSize.Width != 0 || v.videoSize.Height != 0) && !v.isVideoPassthrough {
|
||||||
// Order here matters, you must scale before changing hardware formats
|
// Order here matters, you must scale before changing hardware formats
|
||||||
filters := []string{
|
filters := []string{
|
||||||
v.getScalingString(),
|
v.getScalingString(t.codec.Scaler()),
|
||||||
}
|
}
|
||||||
if t.codec.ExtraFilters() != "" {
|
if t.codec.ExtraFilters() != "" {
|
||||||
filters = append(filters, t.codec.ExtraFilters())
|
filters = append(filters, t.codec.ExtraFilters())
|
||||||
|
@ -351,8 +351,11 @@ func (v *HLSVariant) SetVideoScalingHeight(height int) {
|
||||||
v.videoSize.Height = height
|
v.videoSize.Height = height
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *HLSVariant) getScalingString() string {
|
func (v *HLSVariant) getScalingString(scaler string) string {
|
||||||
return fmt.Sprintf("scale=%s", v.videoSize.getString())
|
if scaler == "" {
|
||||||
|
scaler = "scale"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s=%s", scaler, v.videoSize.getString())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video Quality
|
// Video Quality
|
||||||
|
|
Loading…
Reference in a new issue