From e9844528aa95654eba718927ab531c486ff52d67 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Mon, 24 Apr 2023 18:32:43 -0700 Subject: [PATCH] python-codecs: add timestamps --- plugins/python-codecs/package-lock.json | 4 ++-- plugins/python-codecs/package.json | 2 +- plugins/python-codecs/src/gst_generator.py | 3 +-- plugins/python-codecs/src/pilimage.py | 2 ++ plugins/python-codecs/src/vipsimage.py | 2 ++ 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/python-codecs/package-lock.json b/plugins/python-codecs/package-lock.json index f579db051..44fb4a068 100644 --- a/plugins/python-codecs/package-lock.json +++ b/plugins/python-codecs/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/python-codecs", - "version": "0.1.42", + "version": "0.1.46", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@scrypted/python-codecs", - "version": "0.1.42", + "version": "0.1.46", "devDependencies": { "@scrypted/sdk": "file:../../sdk" } diff --git a/plugins/python-codecs/package.json b/plugins/python-codecs/package.json index 9cab35a52..01fae6014 100644 --- a/plugins/python-codecs/package.json +++ b/plugins/python-codecs/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/python-codecs", - "version": "0.1.42", + "version": "0.1.46", "description": "Python Codecs for Scrypted", "keywords": [ "scrypted", diff --git a/plugins/python-codecs/src/gst_generator.py b/plugins/python-codecs/src/gst_generator.py index 8360f7e6a..ad95ec8e5 100644 --- a/plugins/python-codecs/src/gst_generator.py +++ b/plugins/python-codecs/src/gst_generator.py @@ -46,7 +46,6 @@ async def createPipelineIterator(pipeline: str): nonlocal hasFinished hasFinished = True yieldQueue.put(None) - sampleQueue.put_nowait(None) asyncio.run_coroutine_threadsafe(sampleQueue.put(None), loop = loop) if not finished.done(): finished.set_result(None) @@ -73,8 +72,8 @@ async def createPipelineIterator(pipeline: str): finally: yieldQueue.put(None) finally: - finish() print('gstreamer finished') + finish() def on_new_sample(sink, preroll): diff --git a/plugins/python-codecs/src/pilimage.py b/plugins/python-codecs/src/pilimage.py index b5692d6a7..ce5220903 100644 --- a/plugins/python-codecs/src/pilimage.py +++ b/plugins/python-codecs/src/pilimage.py @@ -2,6 +2,7 @@ import scrypted_sdk from typing import Any from thread import to_thread import io +import time try: from PIL import Image @@ -81,6 +82,7 @@ def toPILImage(pilImageWrapper: PILImage, options: scrypted_sdk.ImageOptions = N async def createPILMediaObject(image: PILImage): ret = await scrypted_sdk.mediaManager.createMediaObject(image, scrypted_sdk.ScryptedMimeTypes.Image.value, { + 'timestamp': time.time() * 1000, 'format': None, 'width': image.width, 'height': image.height, diff --git a/plugins/python-codecs/src/vipsimage.py b/plugins/python-codecs/src/vipsimage.py index f48ece93d..b8f5d46f6 100644 --- a/plugins/python-codecs/src/vipsimage.py +++ b/plugins/python-codecs/src/vipsimage.py @@ -7,6 +7,7 @@ except: Image = None pyvips = None from thread import to_thread +import time class VipsImage(scrypted_sdk.VideoFrame): def __init__(self, vipsImage: Image) -> None: @@ -90,6 +91,7 @@ def toVipsImage(vipsImageWrapper: VipsImage, options: scrypted_sdk.ImageOptions async def createVipsMediaObject(image: VipsImage): ret = await scrypted_sdk.mediaManager.createMediaObject(image, scrypted_sdk.ScryptedMimeTypes.Image.value, { + 'timestamp': time.time() * 1000, 'format': None, 'width': image.width, 'height': image.height,