python-codecs: use non hw accelerated h265 by default

This commit is contained in:
Koushik Dutta
2023-10-17 10:38:14 -07:00
parent d1b57ed3ad
commit f8bcf196d3
4 changed files with 32 additions and 4 deletions

View File

@@ -316,6 +316,7 @@ async def generateVideoFramesGstreamer(
options: scrypted_sdk.VideoFrameGeneratorOptions = None,
filter: Any = None,
h264Decoder: str = None,
h265Decoder: str = None,
postProcessPipeline: str = None,
) -> scrypted_sdk.VideoFrame:
ffmpegInput: scrypted_sdk.FFmpegInput = (
@@ -367,6 +368,17 @@ async def generateVideoFramesGstreamer(
decoder = "vtdec_hw"
else:
decoder = "avdec_h264 output-corrupt=false"
elif videoCodec == "h265":
setDecoderClearDefault(h265Decoder)
if not decoder:
# hw acceleration is "safe" to use on mac, but not
# on other hosts where it may crash.
# defaults must be safe.
if platform.system() == "Darwin":
decoder = "vtdec_hw"
else:
decoder = "avdec_h265 output-corrupt=false"
else:
# decodebin may pick a hardware accelerated decoder, which isn't ideal
# so use a known software decoder for h264 and decodebin for anything else.

View File

@@ -62,6 +62,7 @@ class GstreamerGenerator(
options,
filter,
self.storage.getItem("h264Decoder"),
self.storage.getItem("h265Decoder"),
self.storage.getItem("postProcessPipeline"),
)
@@ -81,6 +82,20 @@ class GstreamerGenerator(
],
"combobox": True,
},
{
"key": "h265Decoder",
"title": "H25 Decoder",
"description": "The Gstreamer pipeline to use to decode H265 video.",
"value": self.storage.getItem("h265Decoder") or "Default",
"choices": [
"Default",
"decodebin",
"vtdec_hw",
"nvh265dec",
"vaapih265dec",
],
"combobox": True,
},
{
"key": "postProcessPipeline",
"title": "Post Process Pipeline",
@@ -229,11 +244,12 @@ class CodecFork:
options: scrypted_sdk.VideoFrameGeneratorOptions,
filter: Any,
h264Decoder: str,
h265Decoder: str,
postProcessPipeline: str,
) -> scrypted_sdk.VideoFrame:
async for data in self.generateVideoFrames(
gstreamer.generateVideoFramesGstreamer(
mediaObject, options, filter, h264Decoder, postProcessPipeline
mediaObject, options, filter, h264Decoder, h265Decoder, postProcessPipeline
),
"gstreamer",
options and options.get("firstFrameOnly"),