Skip to content

Commit

Permalink
#3750 use the correct stream attributes for av1
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Jul 25, 2023
1 parent 274c5fd commit 1f1b937
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
17 changes: 13 additions & 4 deletions xpra/codecs/gstreamer/codec_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ def get_default_encoder_options() -> Dict[str,Dict[str,Any]]:
"zero-reorder-delay" : True,
},
"svtav1enc" : {
# "speed" : 12,
# "gop-size" : 251,
# "speed" : 12,
# "gop-size" : 251,
"intra-refresh" : 1, #open gop
# "lookahead" : 0,
# "rc" : 1, #vbr
# "lookahead" : 0,
# "rc" : 1, #vbr
},
"svtvp9enc" : {
},
Expand Down Expand Up @@ -127,6 +127,15 @@ def get_default_encoder_options() -> Dict[str,Dict[str,Any]]:
options[element] = encoder_options
return options

def get_default_decoder_options() -> Dict[str,Dict[str,Any]]:
options : Dict[str,Dict[str,Any]] = {
"av1dec" : {
"stream-format": "obu-stream",
"alignment": "tu",
},
}
return options


def get_version() -> Tuple[int, ...]:
return (5, 0)
Expand Down
30 changes: 18 additions & 12 deletions xpra/codecs/gstreamer/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
VideoPipeline,
get_version, get_type, get_info,
init_module, cleanup_module,
get_default_decoder_options,
)
from xpra.os_util import WIN32
from xpra.util import roundup, typedict
Expand Down Expand Up @@ -71,12 +72,14 @@ def get_codecs_options() -> Dict[str,Tuple[str,...]]:
def find_codecs(options) -> Dict[str,str]:
codecs : Dict[str,str] = {}
for encoding, elements in options.items():
if encoding in FORMATS and elements and has_plugins(*elements):
codecs[encoding] = elements[0]
break
if encoding in FORMATS and elements:
found = [x for x in elements if has_plugins(x)]
if found:
codecs[encoding] = found[0]
log(f"find_codecs({options})={codecs}")
return codecs


CODECS = find_codecs(get_codecs_options())


Expand Down Expand Up @@ -111,21 +114,24 @@ def create_pipeline(self, options:typedict):
if self.encoding not in get_encodings():
raise ValueError(f"invalid encoding {self.encoding!r}")
self.dst_formats = options.strtupleget("dst-formats")
decoder_element = CODECS.get(self.encoding)
if not decoder_element:
decoder = CODECS.get(self.encoding)
if not decoder:
raise RuntimeError(f"invalid encoding {self.encoding}")
stream_attrs : Dict[str,Any] = {
"width" : self.width,
"height" : self.height,
}
for k,v in {
"profile" : "main",
"stream-format" : "byte-stream",
"alignment" : "au",
}.items():
eopts = get_default_decoder_options().get(decoder, {})
if not eopts:
eopts = {
"profile" : "main",
"stream-format" : "byte-stream",
"alignment" : "au",
}
for k,v in eopts.items():
stream_attrs[k] = options.strget(k, v)
stream_caps = get_caps_str(f"video/x-{self.encoding}", stream_attrs)
if decoder_element.startswith("nv"):
if decoder.startswith("nv"):
gst_format = "NV12"
self.output_format = "NV12"
else:
Expand All @@ -138,7 +144,7 @@ def create_pipeline(self, options:typedict):
})
elements = [
f"appsrc name=src emit-signals=1 block=0 is-live=1 do-timestamp=1 stream-type={STREAM_TYPE} format={GST_FORMAT_BYTES} caps={stream_caps}",
f"{decoder_element} name=decoder",
f"{decoder} name=decoder",
f"appsink name=sink emit-signals=1 max-buffers=10 drop=false sync=false async=true qos=false caps={output_caps}",
]
if not self.setup_pipeline_and_bus(elements):
Expand Down

0 comments on commit 1f1b937

Please sign in to comment.