actfw's additional components using GStreamer
Project description
actfw-gstreamer
actfw's components using GStreamer for implementation. actfw is a framework for Actcast Application written in Python.
Installation
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 gcc
pip3 install actfw-gstreamer
Document
Usage
See 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.
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.
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 Frames using videotestsrc.
GstreamerCaptureis aProducer.- It generates
Frames consists of an output ofConverterBase. In this case, converter class isConverterPILand output isPIL.Image.Image.
- It generates
GstStreamBuilderandPipelineGeneratordetermines how to build gstreamer pipelines.preconfigured_pipelineprovides preconfiguredPipelineGenerators.SimpleRestartHandleris a simple implementation ofRestartHandlerBase, which determines "restart strategy".
For more details, see tests.
rtspsrc
You can use rtspsrc using preconfigured_pipeline.rtsp_h264().
Note that, as of now (2021-04), Actcast application 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
pip3 install poetry
poetry install
Running tests
poetry run pytest -v
Releasing package & API doc
CI will automatically do. Follow the following branch/tag rules.
- Make changes for next version in
masterbranch (via pull-requests). - Make a PR that updates version in
pyproject.tomland merge it tomasterbranch. - Create GitHub release from
masterbranch's HEAD.- Draft a new release.
- Create new tag named
release-<New version>(e.g.release-1.4.0) fromChoose a tagpull down menu. - Write title and description.
- Publish release.
- Then CI will build/upload package to PyPI & API doc to GitHub Pages.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file actfw_gstreamer-0.5.0.tar.gz.
File metadata
- Download URL: actfw_gstreamer-0.5.0.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.10.17 Linux/6.8.0-1024-aws
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
743afe8b05593f6858d33b8ab45c0bf7a0b60d29aad9186c32814851993a3b27
|
|
| MD5 |
7ece86884c0703e2d05651afb998df83
|
|
| BLAKE2b-256 |
93d0d4ca84edb7cd6398d5bd42544d67b27129fe1e4d2c29ab11f786af1dc1bc
|
File details
Details for the file actfw_gstreamer-0.5.0-py3-none-any.whl.
File metadata
- Download URL: actfw_gstreamer-0.5.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.10.17 Linux/6.8.0-1024-aws
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
304bfc8abad1166c9a93fea8eb1fa4c7fa41e7abeb86f2d1dbe7d5ffa0f29a6a
|
|
| MD5 |
f4400ef08fb339169a99591e97c85496
|
|
| BLAKE2b-256 |
df4dd089f5679fdf9e347f20bbe1e0ede2f6f370793f37f304b0f7fa600b152e
|