mirror of
https://github.com/koush/scrypted.git
synced 2026-02-07 07:52:12 +00:00
30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
from __future__ import annotations
|
|
import scrypted_python.scrypted_sdk
|
|
from scrypted_python.scrypted_sdk.types import MediaObject
|
|
import os
|
|
from typing import Any
|
|
|
|
class MediaObjectRemote:
|
|
pass
|
|
|
|
class MediaManager(scrypted_python.scrypted_sdk.MediaManager):
|
|
def __init__(self, api: Any) -> None:
|
|
super().__init__()
|
|
self.api = api
|
|
|
|
async def getFFmpegPath(self) -> str:
|
|
v = os.environ.get('SCRYPTED_FFMPEG_PATH_ENV_VARIABLE', None)
|
|
if v:
|
|
ffmpeg = os.environ.get(v, None)
|
|
if ffmpeg and os.path.exists(ffmpeg):
|
|
return ffmpeg
|
|
|
|
ffmpeg = os.environ.get('SCRYPTED_FFMPEG_PATH', None)
|
|
if ffmpeg and os.path.exists(ffmpeg):
|
|
return ffmpeg
|
|
return os.path.join(os.getcwd(), 'node_modules/ffmpeg-for-homebridge/ffmpeg')
|
|
|
|
async def convertMediaObjectToBuffer(self, mediaObject: MediaObject, toMimeType: str) -> bytearray:
|
|
intermediate = await self.api.convert(mediaObject)
|
|
converted = self.createMediaObject(intermediate.data)
|