Skip to content

Commit

Permalink
python-codecs: add timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Apr 25, 2023
1 parent 0609fc8 commit e984452
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions plugins/python-codecs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/python-codecs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scrypted/python-codecs",
"version": "0.1.42",
"version": "0.1.46",
"description": "Python Codecs for Scrypted",
"keywords": [
"scrypted",
Expand Down
3 changes: 1 addition & 2 deletions plugins/python-codecs/src/gst_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def finish():
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)
Expand All @@ -73,8 +72,8 @@ async def gen():
finally:
yieldQueue.put(None)
finally:
finish()
print('gstreamer finished')
finish()


def on_new_sample(sink, preroll):
Expand Down
2 changes: 2 additions & 0 deletions plugins/python-codecs/src/pilimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Any
from thread import to_thread
import io
import time

try:
from PIL import Image
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions plugins/python-codecs/src/vipsimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Image = None
pyvips = None
from thread import to_thread
import time

class VipsImage(scrypted_sdk.VideoFrame):
def __init__(self, vipsImage: Image) -> None:
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e984452

Please sign in to comment.