python-codecs: fix assert spam, code cleanups

This commit is contained in:
Koushik Dutta
2023-05-26 08:56:27 -07:00
parent ff4665520c
commit 79765ba58e
5 changed files with 14 additions and 30 deletions

View File

@@ -1,3 +1,4 @@
import asyncio
import platform
from asyncio import Future
from typing import Any
@@ -9,13 +10,9 @@ import pilimage
import vipsimage
from generator_common import createImageMediaObject, createVideoFrame
from gst_generator import Gst, createPipelineIterator
from gstreamer_postprocess import (
GstreamerFormatPostProcess,
GstreamerPostProcess,
OpenGLPostProcess,
VaapiPostProcess,
getBands,
)
from gstreamer_postprocess import (GstreamerFormatPostProcess,
GstreamerPostProcess, OpenGLPostProcess,
VaapiPostProcess, getBands)
from util import optional_chain
@@ -155,7 +152,7 @@ class GstImage(scrypted_sdk.Image):
"format": reformat,
}
)
await colored.close()
asyncio.ensure_future(colored.close(), loop = asyncio.get_event_loop())
try:
return await image.toBuffer(
@@ -206,7 +203,7 @@ async def createResamplerPipeline(
caps = sample.get_caps()
srcCaps = caps.to_string().replace(" ", "")
pipeline = f"appsrc name=appsrc emit-signals=True is-live=True caps={srcCaps}"
pipeline = f"appsrc name=appsrc format=time emit-signals=True is-live=True caps={srcCaps}"
await pp.create(gst.gst, pipeline)
pp.resize = resize

View File

@@ -53,7 +53,7 @@ class GstreamerFormatPostProcess():
class GstreamerPostProcess():
def __init__(self) -> None:
self.postprocess = ' ! videocrop name=videocrop ! videoconvertscale ! capsfilter name=scaleCapsFilter'
self.postprocess = ' ! videocrop name=videocrop ! videoconvert ! videoscale ! capsfilter name=scaleCapsFilter'
self.resize = None
async def create(self, gst, pipeline: str):
@@ -210,12 +210,8 @@ class OpenGLPostProcess():
self.gltransformation = self.gst.get_by_name('gltransformation')
# sets the target texture size
self.glCapsFilter = self.gst.get_by_name('glCapsFilter')
# sets output format to something other than RGBA if necessary since gl can't handle non-RGBA
# self.swCapsFilter = self.gst.get_by_name('swCapsFilter')
def update(self, caps, sampleSize: Tuple[int, int], options: scrypted_sdk.ImageOptions):
# print(options)
sampleWidth, sampleHeight = sampleSize
crop = options.get('crop')
@@ -237,7 +233,6 @@ class OpenGLPostProcess():
width = int(width)
height = int(height)
# pipeline += " ! videoscale"
glCaps += f",width={width},height={height}"
self.glCapsFilter.set_property('caps', caps.from_string(glCaps))
@@ -271,11 +266,3 @@ class OpenGLPostProcess():
gltransformation.set_property('scale-y', scaleY)
gltransformation.set_property('translation-x', translationX)
gltransformation.set_property('translation-y', translationY)
# if format and format != 'RGBA':
# swcaps = f'video/x-raw,format={format}'
# print(swcaps)
# self.swCapsFilter.set_property('caps', caps.from_string(swcaps))
# else:
# self.swCapsFilter.set_property('caps', 'video/x-raw')
# print('nc')