Hi,
I’m currently working on a Python 3.7+ application that runs in Jetson Nano and performs the following actions:
- Consumes video from a USB web camera, for example a Logitech C270.
- Adds an overlay to the original camera image (for example a text with a counter).
- Publishes RTSP to be consumed from other devices: an android application, VLC, etc.
An example of using GStreamer is provided in this topic. This solution requires installing python bindings for GStreamer, but Jetpack does not have native support for Python 3.7 and PyGObject Python 3.7 can be installed but then it fails to import gi.
Code migrated to Python 3:
import gi
gi.require_version('Gst','1.0')
gi.require_version('GstVideo','1.0')
gi.require_version('GstRtspServer','1.0')
from gi.repository import GObject, Gst, GstVideo, GstRtspServer
Gst.init(None)
mainloop = GObject.MainLoop()
server = GstRtspServer.RTSPServer()
mounts = server.get_mount_points()
factory = GstRtspServer.RTSPMediaFactory()
factory.set_launch('( videotestsrc is-live=1 ! video/x-raw,width=320,height=240,framerate=30/1 ! nvvidconv ! nvv4l2h264enc insert-sps-pps=1 idrinterval=30 insert-vui=1 ! rtph264pay name=pay0 pt=96 )')
mounts.add_factory("/test", factory)
server.attach(None)
print("stream ready at rtsp://127.0.0.1:8554/test")
mainloop.run()
Error when running:
python3.7 test_gs.py
Traceback (most recent call last):
File "test_gs.py", line 1, in <module>
import gi
File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in <module>
from . import _gi
ImportError: cannot import name '_gi' from 'gi' (/usr/lib/python3/dist-packages/gi/__init__.py)
Thanks in advance,
Nicolás