actfw-gstreamer


Nameactfw-gstreamer JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/Idein/actfw-gstreamer
Summaryactfw's additional components using GStreamer
upload_time2024-02-14 05:00:29
maintainer
docs_urlNone
authorIdein Inc.
requires_python>=3.7,<4.0
licenseMIT
keywords actcast
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # actfw-gstreamer

actfw's components using GStreamer for implementation.
actfw is a framework for Actcast Application written in Python.

## Installation

```console
sudo apt-get update
sudo apt-get install -y python3-pip python3-pil 
sudo apt-get install libgstreamer1.0-dev libgirepository1.0-dev ibgstreamer-plugins-base1.0-dev libglib2.0-dev
pip3 install actfw-gstreamer
```

## Document

- [API References](https://idein.github.io/actfw-gstreamer/latest/)

## Usage

See [actfw-core](https://github.com/Idein/actfw-core) for basic usage of `actfw` framework.

### Initalization

An application using `actfw-gstreamer` have to initialize GStreamer library before using `actfw-gstreamer`'s components.

```python
if __name__ == '__main__':
    import gi

    gi.require_version('Gst', '1.0')
    from gi.repository import Gst
    Gst.init(None)

    main()
```

### `videotestsrc`

You can learn basic usage of `actfw-gstreamer` by using `videotestsrc`.

```python
from actfw_gstreamer.capture import GstreamerCapture
from actfw_gstreamer.gstreamer.converter import ConverterPIL
from actfw_gstreamer.gstreamer.stream import GstStreamBuilder
from actfw_gstreamer.restart_handler import SimpleRestartHandler


def videotestsrc_capture() -> GstreamerCapture:
    pipeline_generator = preconfigured_pipeline.videotestsrc()
    builder = GstStreamBuilder(pipeline_generator, ConverterPIL())
    restart_handler = SimpleRestartHandler(10, 5)
    return GstreamerCapture(builder, restart_handler)


def main():
    app = actfw_core.Application()

    capture = videotestsrc_capture()
    app.register_task(capture)

    consumer = YourConsumer()
    app.register_task(consumer)

    capture.connect(consumer)

    app.run()
```

This generates [`Frame`](https://idein.github.io/actfw-core/latest/actfw_core.html#actfw_core.capture.Frame)s using [videotestsrc](https://gstreamer.freedesktop.org/documentation/videotestsrc/index.html).

- `GstreamerCapture` is a [`Producer`](https://idein.github.io/actfw-core/latest/actfw_core.task.html#actfw_core.task.producer.Producer).
  - It generates `Frame`s consists of an output of `ConverterBase`.  In this case, converter class is `ConverterPIL` and output is `PIL.Image.Image`.
- `GstStreamBuilder` and `PipelineGenerator` determines how to build gstreamer pipelines.
- `preconfigured_pipeline` provides preconfigured `PipelineGenerator`s.
- `SimpleRestartHandler` is a simple implementation of `RestartHandlerBase`, which determines "restart strategy".

For more details, see [tests](tests/intergation_test/test_gstreamer_output.py).

### `rtspsrc`

You can use [rtspsrc](https://gstreamer.freedesktop.org/documentation/rtsp/rtspsrc.html) using `preconfigured_pipeline.rtsp_h264()`.

Note that, as of now (2021-04), [Actcast application](https://actcast.io/docs/ForVendor/ApplicationDevelopment/) cannot use multicast UDP with dynamic address and unicast UDP.
(RTSP client communicates with RTSP server in RTP and determines adderss of mulitcast UDP.)
Therefore, you can use only the option `protocols = "tcp"`.
See also https://gstreamer.freedesktop.org/documentation/rtsp/rtspsrc.html#rtspsrc:protocols .

You should also pay attention to decoders. Available decoders are below:

| decoder (package) \ device                                     | Raspberry Pi 3 | Raspberry Pi 4 | Jetson Nano |
| -------------------------------------------------------------- | -------------- | -------------- | ----------- |
| `omxh264` (from `gstreamer1.0-omx` and `gstreamer1.0-omx-rpi`) | o              | x              | ?           |
| `v4l2h264dec` (from `gstreamer1.0-plugins-good`)               | very slow      | o              | ?           |

If your application supports various devices, you should branch by hardware types and select appropriate `decoder_type`.
For example, it is recommended to use `decoder_type` `omx` for Raspberry Pi 3 and `v4l2` for Raspberry Pi 4.
Currently, this library does not provide auto determination.

## Development Guide

### Installation of dev requirements

```console
pip3 install poetry
poetry install
```

### Running tests

```console
poetry run nose2 -v
```

### Releasing package & API doc

CI will automatically do.
Follow the following branch/tag rules.

1. Make changes for next version in `master` branch (via pull-requests).
2. Make a PR that updates version in `pyproject.toml` and merge it to `master` branch.
3. Create GitHub release from `master` branch's HEAD.
    1. [Draft a new release](https://github.com/Idein/actfw-gstreamer/releases/new).
    2. Create new tag named `release-<New version>` (e.g. `release-1.4.0`) from `Choose a tag` pull down menu.
    3. Write title and description.
    4. Publish release.
4. Then CI will build/upload package to PyPI & API doc to GitHub Pages.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Idein/actfw-gstreamer",
    "name": "actfw-gstreamer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "actcast",
    "author": "Idein Inc.",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/6e/9a/cb55c20af2d4594d8291c13edf56106d772502b3bdc17527a0b7b08d0f6e/actfw_gstreamer-0.2.0.tar.gz",
    "platform": null,
    "description": "# actfw-gstreamer\n\nactfw's components using GStreamer for implementation.\nactfw is a framework for Actcast Application written in Python.\n\n## Installation\n\n```console\nsudo apt-get update\nsudo apt-get install -y python3-pip python3-pil \nsudo apt-get install libgstreamer1.0-dev libgirepository1.0-dev ibgstreamer-plugins-base1.0-dev libglib2.0-dev\npip3 install actfw-gstreamer\n```\n\n## Document\n\n- [API References](https://idein.github.io/actfw-gstreamer/latest/)\n\n## Usage\n\nSee [actfw-core](https://github.com/Idein/actfw-core) for basic usage of `actfw` framework.\n\n### Initalization\n\nAn application using `actfw-gstreamer` have to initialize GStreamer library before using `actfw-gstreamer`'s components.\n\n```python\nif __name__ == '__main__':\n    import gi\n\n    gi.require_version('Gst', '1.0')\n    from gi.repository import Gst\n    Gst.init(None)\n\n    main()\n```\n\n### `videotestsrc`\n\nYou can learn basic usage of `actfw-gstreamer` by using `videotestsrc`.\n\n```python\nfrom actfw_gstreamer.capture import GstreamerCapture\nfrom actfw_gstreamer.gstreamer.converter import ConverterPIL\nfrom actfw_gstreamer.gstreamer.stream import GstStreamBuilder\nfrom actfw_gstreamer.restart_handler import SimpleRestartHandler\n\n\ndef videotestsrc_capture() -> GstreamerCapture:\n    pipeline_generator = preconfigured_pipeline.videotestsrc()\n    builder = GstStreamBuilder(pipeline_generator, ConverterPIL())\n    restart_handler = SimpleRestartHandler(10, 5)\n    return GstreamerCapture(builder, restart_handler)\n\n\ndef main():\n    app = actfw_core.Application()\n\n    capture = videotestsrc_capture()\n    app.register_task(capture)\n\n    consumer = YourConsumer()\n    app.register_task(consumer)\n\n    capture.connect(consumer)\n\n    app.run()\n```\n\nThis generates [`Frame`](https://idein.github.io/actfw-core/latest/actfw_core.html#actfw_core.capture.Frame)s using [videotestsrc](https://gstreamer.freedesktop.org/documentation/videotestsrc/index.html).\n\n- `GstreamerCapture` is a [`Producer`](https://idein.github.io/actfw-core/latest/actfw_core.task.html#actfw_core.task.producer.Producer).\n  - It generates `Frame`s consists of an output of `ConverterBase`.  In this case, converter class is `ConverterPIL` and output is `PIL.Image.Image`.\n- `GstStreamBuilder` and `PipelineGenerator` determines how to build gstreamer pipelines.\n- `preconfigured_pipeline` provides preconfigured `PipelineGenerator`s.\n- `SimpleRestartHandler` is a simple implementation of `RestartHandlerBase`, which determines \"restart strategy\".\n\nFor more details, see [tests](tests/intergation_test/test_gstreamer_output.py).\n\n### `rtspsrc`\n\nYou can use [rtspsrc](https://gstreamer.freedesktop.org/documentation/rtsp/rtspsrc.html) using `preconfigured_pipeline.rtsp_h264()`.\n\nNote that, as of now (2021-04), [Actcast application](https://actcast.io/docs/ForVendor/ApplicationDevelopment/) cannot use multicast UDP with dynamic address and unicast UDP.\n(RTSP client communicates with RTSP server in RTP and determines adderss of mulitcast UDP.)\nTherefore, you can use only the option `protocols = \"tcp\"`.\nSee also https://gstreamer.freedesktop.org/documentation/rtsp/rtspsrc.html#rtspsrc:protocols .\n\nYou should also pay attention to decoders. Available decoders are below:\n\n| decoder (package) \\ device                                     | Raspberry Pi 3 | Raspberry Pi 4 | Jetson Nano |\n| -------------------------------------------------------------- | -------------- | -------------- | ----------- |\n| `omxh264` (from `gstreamer1.0-omx` and `gstreamer1.0-omx-rpi`) | o              | x              | ?           |\n| `v4l2h264dec` (from `gstreamer1.0-plugins-good`)               | very slow      | o              | ?           |\n\nIf your application supports various devices, you should branch by hardware types and select appropriate `decoder_type`.\nFor example, it is recommended to use `decoder_type` `omx` for Raspberry Pi 3 and `v4l2` for Raspberry Pi 4.\nCurrently, this library does not provide auto determination.\n\n## Development Guide\n\n### Installation of dev requirements\n\n```console\npip3 install poetry\npoetry install\n```\n\n### Running tests\n\n```console\npoetry run nose2 -v\n```\n\n### Releasing package & API doc\n\nCI will automatically do.\nFollow the following branch/tag rules.\n\n1. Make changes for next version in `master` branch (via pull-requests).\n2. Make a PR that updates version in `pyproject.toml` and merge it to `master` branch.\n3. Create GitHub release from `master` branch's HEAD.\n    1. [Draft a new release](https://github.com/Idein/actfw-gstreamer/releases/new).\n    2. Create new tag named `release-<New version>` (e.g. `release-1.4.0`) from `Choose a tag` pull down menu.\n    3. Write title and description.\n    4. Publish release.\n4. Then CI will build/upload package to PyPI & API doc to GitHub Pages.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "actfw's additional components using GStreamer",
    "version": "0.2.0",
    "project_urls": {
        "Changelog": "https://github.com/Idein/actfw-gstreamer/blob/master/CHANGELOG.md",
        "Documentation": "https://idein.github.io/actfw-gstreamer/latest/",
        "Homepage": "https://github.com/Idein/actfw-gstreamer",
        "Repository": "https://github.com/Idein/actfw-gstreamer"
    },
    "split_keywords": [
        "actcast"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "205677806b6d1dfc6a41ce4157b81743a05140a28a41edfe4973198bb840992d",
                "md5": "f66ac19e1360209bf5632795ae7456d8",
                "sha256": "5fd35ec8054d1d20d08b66a3c271231bdccbd4cda390987dd413bab508f35773"
            },
            "downloads": -1,
            "filename": "actfw_gstreamer-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f66ac19e1360209bf5632795ae7456d8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 14361,
            "upload_time": "2024-02-14T05:00:27",
            "upload_time_iso_8601": "2024-02-14T05:00:27.438516Z",
            "url": "https://files.pythonhosted.org/packages/20/56/77806b6d1dfc6a41ce4157b81743a05140a28a41edfe4973198bb840992d/actfw_gstreamer-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6e9acb55c20af2d4594d8291c13edf56106d772502b3bdc17527a0b7b08d0f6e",
                "md5": "5cd61a063f32377d38246331d6be9e08",
                "sha256": "48387376068b00c8921b43d7f5f8519e6d936fd2796516c73df202f5b297413b"
            },
            "downloads": -1,
            "filename": "actfw_gstreamer-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5cd61a063f32377d38246331d6be9e08",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 12472,
            "upload_time": "2024-02-14T05:00:29",
            "upload_time_iso_8601": "2024-02-14T05:00:29.503465Z",
            "url": "https://files.pythonhosted.org/packages/6e/9a/cb55c20af2d4594d8291c13edf56106d772502b3bdc17527a0b7b08d0f6e/actfw_gstreamer-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-14 05:00:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Idein",
    "github_project": "actfw-gstreamer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "lcname": "actfw-gstreamer"
}
        
Elapsed time: 0.17906s