Skip to content

Commit

Permalink
#3706 don't bother trying vaapi with nvidia by default
Browse files Browse the repository at this point in the history
doesn't seem to work, even with 'nvidia-vaapi-driver' installed
  • Loading branch information
totaam committed Jan 12, 2023
1 parent c11dc30 commit 519f6d2
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions xpra/codecs/gstreamer/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import os

from xpra.util import parse_simple_dict
from xpra.util import parse_simple_dict, envbool
from xpra.codecs.codec_constants import video_spec
from xpra.gst_common import (
import_gst, normv,
Expand All @@ -24,6 +24,8 @@
Gst = import_gst()
log = Logger("encoder", "gstreamer")

NVIDIA_VAAPI = envbool("XPRA_NVIDIA_VAAPI", False)

assert get_version and init_module and cleanup_module
ENCODERS = {
"h264" : ("vaapih264enc", "x264enc"),
Expand Down Expand Up @@ -137,13 +139,23 @@ def create_pipeline(self, options):
}[self.colorspace]
CAPS = f"video/x-raw,width={self.width},height={self.height},format=(string){gst_rgb_format},framerate=60/1,interlace=progressive"
#parse encoder plugin string:
encoder_options = ENCODERS.get(self.encoding, ())
encoder_options = list(ENCODERS.get(self.encoding, ()))
encoder_str = os.environ.get("XPRA_GSTREAMER_ENCODER_PLUGIN")
if not encoder_str:
if not encoder_options:
raise ValueError(f"{self.encoding} is not supported here")
#choose the first option (ie: "vaapih264enc"):
encoder_str = encoder_options[0]
#choose the first option (ie: "vaapih264enc")
# but skip 'vaapih264enc' on nvidia hardware:
while encoder_options:
encoder_str = encoder_options.pop(0)
if NVIDIA_VAAPI or encoder_str!="vaapih264enc":
break
try:
from xpra.codecs.nvidia.nv_util import has_nvidia_hardware
if not has_nvidia_hardware():
break
except ImportError:
break
parts = encoder_str.split(" ", 1)
encoder = parts[0]
encoder_options = DEFAULT_ENCODER_OPTIONS.get(encoder, {})
Expand Down

0 comments on commit 519f6d2

Please sign in to comment.