IP Camera / GStreamer / Display streaming video

By: 壮大 増田
Posted: September 18, 2021

Note

brew install gstreamer
brew install gst-plugins-base
brew install gst-plugins-good
brew install gst-plugins-bad
brew install gst-plugins-ugly
gst-launch-1.0 -v playbin uri=rtsp://$USER:$PASS@$IPADDRESS/stream1 uridecodebin0::source::latency=300
An image from Notion
brew install gstreamer gst-plugins-base gst-plugins-good \
gst-plugins-bad gst-plugins-ugly gst-libav gst-rtsp-server \
gst-editing-services --with-orc --with-libogg --with-opus \
--with-pango --with-theora --with-libvorbis --with-libvpx \
--enable-gtk3
An image from Notion

実行したコードは以下

import sys
import rtsp


def main(uri: str):
    with rtsp.Client(uri) as client:
        _image = client.read()
        print(f'loading ... {uri}')

        while True:
            process_image(_image)
            _image = client.read(raw=True)


if __name__ == '__main__':
    args = sys.argv
    if len(args) == 1:
        print('1 argument is required.')
        sys.exit(1)
    main(args[1])
python main.py rtsp://sotapo:sotapo0520@192.168.0.116/stream1
I don't plan to develop this module any further, as more complex applications are better suited to use OpenCV, Gstreamer, or ffmpeg directly.
An image from Notion

めちゃくちゃ簡単なんだが。やっぱりOpenCVは安定してるな…