{"id":28640798,"url":"https://github.com/chryscloud/chrys-cloud-sdk-python","last_synced_at":"2025-06-12T20:32:35.194Z","repository":{"id":62562126,"uuid":"291129097","full_name":"chryscloud/chrys-cloud-sdk-python","owner":"chryscloud","description":"Chrysalis Python Cloud SDK.  Easy and powerful control over live media streaming consumption and ingestion into various machine learning libraries in the cloud.","archived":false,"fork":false,"pushed_at":"2020-08-28T23:15:30.000Z","size":27,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-26T23:19:41.087Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chryscloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-28T19:24:43.000Z","updated_at":"2021-07-21T15:24:11.000Z","dependencies_parsed_at":"2022-11-03T15:30:50.169Z","dependency_job_id":null,"html_url":"https://github.com/chryscloud/chrys-cloud-sdk-python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chryscloud/chrys-cloud-sdk-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chryscloud%2Fchrys-cloud-sdk-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chryscloud%2Fchrys-cloud-sdk-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chryscloud%2Fchrys-cloud-sdk-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chryscloud%2Fchrys-cloud-sdk-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chryscloud","download_url":"https://codeload.github.com/chryscloud/chrys-cloud-sdk-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chryscloud%2Fchrys-cloud-sdk-python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259522458,"owners_count":22870469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-12T20:30:42.061Z","updated_at":"2025-06-12T20:32:35.186Z","avatar_url":"https://github.com/chryscloud.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python Chrysalis Cloud SDK\n\nThis repository houses the official Chrysalis Cloud Python SDK for use with [Chryscloud.com](https://chryscloud.com/) cloud, end-to-end media streaming and analytics platform.\n\nChrysalis Cloud SDK aims to provide easy and powerful control over live media streaming consumption and ingestion into various machine learning libraries in the cloud.\n\nIf you're looking for a hybrid edge-cloud solution we recommend you look into our open source project [Chrysalis Edge Proxy](https://github.com/chryscloud/video-edge-ai-proxy)\n\n## Contents\n\n- [Features](#features)\n- [Prerequisite](#prerequisite)\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Probing](#probe)\n    - [Live stream frames](#retrieve-latest-video-image-from-a-live-stream)\n    - [Buffered frames in the past](#retrieve-video-images-from-the-past)\n    - [Thumbnail image from video stream](#thumbnail-image-from-video-stream)\n    - [Turn permanent storage on/off](#turn-storage-on-and-off)\n    - [Example](#example)\n      - [Live stream with OpenCV](#display-live-stream-with-opencv)\n- [Development](#development)\n    - [Mac OS X](#mac-os-x)\n    - [Ubuntu \u003e= 18.04 LTS](#mac-os-x)\n    - [Ubuntu \u003c 18.04 LTS](#mac-os-x)\n    - [Installing](#installing)\n\n## Features\n\n- Easy integration with numerous machine learning platforms\n- Support for easy access to RTMP live video stream from Chrysalis Cloud (live video/audio streaming)\n- Supporting for any camera that has RTMP streaming abilities\n- Deals with complexities of media stream management\n- Secure access media streams\n\n## Prerequisite\n\n- [Install anaconda](https://docs.anaconda.com/anaconda/install/)\n- [Install FFmpeg \u003e 4.0](https://ffmpeg.org/download.html)\n- [Add RTMP camera on Chrysalis Platform](https://chryscloud.com)\n\nCheck `FFmpeg` version:\n```\nffmpeg -version\n```\n\n### Adding RTMP camera on Chrysalis Developer Platform\n\n\n\n## Installation\n\nCreate `environment.yml` file. \n\nYou can easily add to this file dependencies and additional image manipulation libraries such as Pillow and OpenCV.\n\n[If you need GPU support, you can check how to work with Anaconda and GPU packages](https://docs.anaconda.com/anaconda/user-guide/tasks/gpu-packages/). \n\n\n```yaml\nname: chrysalis\nchannels:\n  - conda-forge\ndependencies:\n  - ca-certificates=2020.1.1=0\n  - certifi=2020.4.5.1=py37_0\n  - pip=20.0.2=py37_1\n  - wheel=0.34.2=py37_0\n  - python=3.7.7=hcf32534_0_cpython\n  - opencv=4.2.0\n  - av=7.0.1\n  - numpy=1.18.1\n  - redis-py=3.4.1\n  - pip:\n    - Cython\n    - chrysalis==1.0.0\n```\n\nCreate new conda environment:\n```shell\nconda env create -f environment.yml\n```\n\n## Usage\n\n- all returned images are in numpy format.\n- all returned images are in bgr24 pixel format.\n\nCheck ChImage attributes for more details\n\n### Probe\n\nProbing returns information about the streaming media. It gives you a sense if the camera is streaming, when it was last seen, what is the frame cache duration stored on the Chrysalis streaming server.\n\n```python\nimport chrysalis\n# connection to Chrysalis Cloud\nchrys = chrysalis.Connect(host=\"https://myserver.at.chrysvideo.com\", port=\"1234\", password=\"mypassword\", ssl_ca_cert=\"mycert.cer\")\n# returns ProbeInfo object\nprobe = chrys.Probe()\nprint(\"start {}, end {}, duration {} s, assessed fps {}\".format(probe.start_timestamp, probe.end_timestamp, probe.duration, probe.fps))\n```\n\nThe ProbeInfo object returns the information about cached frames as well as assessment of FPS (frames per second) streamed from the camera.\n\n`start_timestamp` and `end_timestamp` are UTC times in milliseconds since epoch.\n\n```python\nProbeInfo Attributes\n    ----------\n    start_timestamp : int\n        Earlies contained media data in video stream cache\n    end_timestamp : int\n        Latest contained media data in video stream cache\n    duration : int\n        Duration of the buffered media stream in seconds\n    fps : int\n        Approximation of Frames per Second of source stream\n    \"\"\"\n```\n\n## Retrieve latest video image from a live stream\n\nChrysalis Cloud Python SDK takes care of delivering crisp and clear images from your live video stream, regardless of the processing speeds, speed ups or slow downs because of the latency or even if your camera disconnects from the network.\n\n```python\nimport chrysalis\n\n# connection to Chrysalis Cloud\nchrys = chrysalis.Connect(host=\"https://myserver.at.chrysvideo.com\", port=\"1234\", password=\"mypassword\", ssl_ca_cert=\"mycert.cer\")\n\n# Perpetual reading of the stream\nwhile True:\n    # VideoLatestImage returns ChImage object\n    img = chrys.VideoLatestImage()\n```\n\n`ChImage` object returned from VideoLatestImage has a following structure:\n\n```python\nChImage Attributes\n    ----------\n    data: numpy\n        Image stored in numpy in bgr24 format\n    start_timestamp : int\n        Earlies contained media data in video stream cache\n    end_timestamp : int\n        Latest contained media data in video stream cache\n    duration : int\n        Duration of the buffered media stream in seconds\n    fps : int\n        Approximation of Frames per Second of source stream\n    \"\"\"\n```\n\nVideoLatestImage returns `None` image when frame not available.\n\nVideoLatestImage might return None in cases when querying for the next frame is faster than the camera stream produces them.\n\nThe SDK will not return already consumed frames (images) in the perpetual reading of the stream.\n\nYou can also consume live stream images from mutliple sinks in case when you need to run the same live stream (e.g. the same image) through multiple Computer Vision algorithms. Not returning already consumed frames applies per SDK instance basis.\n\n## Retrieve video images from the past\n\nBased on what is available in the frame cache on Chrysalis streaming nodes you can also query video images from the past. Use `Probing` in case you need more information how much back in time you can query the video stream.\n\n```python\nimport chrysalis\n\n# connection to Chrysais Cloud\nchrys = chrysalis.Connect(hos=\"https://myserver.at.chrysvideo.com\", prt=\"1234\", password=\"mypassword\", ssl_ca_cert=\"mycert.cer\")\n\nprobe = ch.Probe()\nstart = probe.end_timestamp - (1000 * 30) # 30 seconds in the past\nend = probe.end_timestamp - (1000 * 15) # until 15 seconds in the past (end \u003e start)\n\n# Perpetual reading of the stream until end is reached\nwhile True:\n    # VideoLatestImage returns ChImage object\n    img = ch.VideoPastImage(start, end)\n```\n\n## Thumbnail image from video stream\n\nThumbnails are in `bgr24 format in numpy array`. In fact all images for local consumption are in the same format. This makes it easy to consume images in any processing and analytics after. \n\n```python\nimport chrysalis\n\nchrys = chrysalis.Connect(host=\"https://myserver.at.chrysalis.com\", port=\"1234\", password=\"mypassword\", ssl_ca_cert=\"mycert.crt\")\n\n d = datetime.today() - timedelta(hours=0, minutes=0, seconds=2)\nimg = chrys.Screenshot(dt=d)\n```\n\nDue to the nature of H.264 straming it is not guaranteed the successfulness of the Screenshot method. In case no screenshot was found `img = None`. \n\nThis function tries to traverse the H.264 buffered stream seeking for I-Frame. the closest I-Frame to given `dt` (timestamp) is returned if I-Frame found. \n\n## Turn Storage On and Off\n\nBased on video analysis you can decide to store a stream into the permanent Chrysalis Cloud storage. Since live video form a webcam might be streaming 24/7 we don’t necessarily need to store everything, but rather we can perform simple analysis (e.g. movement detection, face recognition, …) to decide when and for how long we want to permanently store that video segment.\n\n`Coming soon`\n\n## Example\n\nAll examples are in `/examples` folder. Create conda environment from prepared `environment.yml` in examples folder before you run the examples.  \n\nCreate environment:\n```\nconda env create -f environment.yml\n```\n\nActivate examples environment:\n```\nconda activate chrysexamples\n```\n\n### Display live stream with OpenCV\n\n```python\nimport chrysalis\n\n# connection to Chrysalis Cloud\nchrys = chrysalis.Connect(host=\"https://myserver.at.chrysalis.com\", port=\"1234\", password=\"mypassword\", ssl_ca_cert=\"mycert.cer\")\n\n# Perpetual reading of the stream\nwhile True:\n    # VideoLatestImage returns ChImage object\n    img = chrys.VideoLatestImage()\n    if img is not None:\n        cv2.imshow(\"live video\", img.data)\n        if cv2.waitKey(1) \u0026 0xFF == ord('q'):\n            break\n```\n\n# Development\n\n## Install FFmpeg\n\n### Mac OS X\n\n```\nbrew install ffmpeg pkg-config\n```\n\n### Ubuntu \u003e= 18.04 LTS\n\nOn Ubuntu 18.04 LTS everything can come from the default sources:\n\n```\nsudo apt-get install -y python-dev pkg-config\n\n# Library components\nsudo apt-get install -y \\\n    libavformat-dev libavcodec-dev libavdevice-dev \\\n    libavutil-dev libswscale-dev libswresample-dev libavfilter-dev\n```\n\n### Ubuntu \u003c 18.04 LTS\n\nOn older Ubuntu releases you will be unable to satisfy these requirements with the default package sources. We recommend compiling and installing FFmpeg from source. For FFmpeg:\n\n```\nsudo apt install \\\n    autoconf \\\n    automake \\\n    build-essential \\\n    cmake \\\n    libass-dev \\\n    libfreetype6-dev \\\n    libjpeg-dev \\\n    libtheora-dev \\\n    libtool \\\n    libvorbis-dev \\\n    libx264-dev \\\n    pkg-config \\\n    wget \\\n    yasm \\\n    zlib1g-dev\n\nwget http://ffmpeg.org/releases/ffmpeg-3.2.tar.bz2\ntar -xjf ffmpeg-3.2.tar.bz2\ncd ffmpeg-3.2\n\n./configure --disable-static --enable-shared --disable-doc\nmake\n```\n\n\n## Installing\n\n\n```bash\ngit clone https://github.com/cocoonhealth/ChrysalisPythonSDK.git\n\ncd ChrysalisPythonSDK\n\nsudo pip install -e . \n```\nThis should install it's dependencies also. \n\n# Contributing\n\nPlease read `CONTRIBUTING.md` for details on our code of conduct, and the process of submitting pull requests to us. \n\n# Versioning\n\nCurrent version is initial release - 1.0.0\n\n# License\n\nThis project is licensed under Apache 2.0 License - see the `LICENSE` for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchryscloud%2Fchrys-cloud-sdk-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchryscloud%2Fchrys-cloud-sdk-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchryscloud%2Fchrys-cloud-sdk-python/lists"}