Coder Social home page Coder Social logo

sahilparekh / gstreamer-python Goto Github PK

View Code? Open in Web Editor NEW
117.0 6.0 36.0 7 KB

Fetch RTSP Stream using GStreamer in Python and get image in Numpy

License: MIT License

Python 100.00%
python gstreamer rtsp opencv opencv2 opencv-python numpy example demo sample

gstreamer-python's Introduction

GStreamer-Python

This project helps in fetching continous live RTSP stream using GStreamer, Python and numpy without compromising on stream quality.

multiprocessing is used in python to avoid main thread getting stuck.

Getting Started

Just clone this Repo then in main_prg.py add your rtsp stream on below line:

self.camlink = '' #Add your RTSP cam link

Prerequisites

  1. Python 3
  2. GStreamer
  3. OpenCV (if you want to run this example as is)
  4. Numpy
1. Python 3 Installation

This you would already know

2. GStreamer Installation

You will need GStreamer. Installation instruction can be found on this link GStreamer Still for your quick reference will list installation instruction for Ubuntu:

apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
3. OpenCV Installation

There are various way to install OpenCV but example using (Conda, PIP or build from source). But for purpose of this project below is instruction using PIP

pip3 install opencv-contrib-python
4. Numpy Installation
pip3 install numpy

Running the program

Post cloning the Repo, go to repo dir (Also include cam link in main_prg.py as mentioned above).

python3 main_prg.py

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Star the REPO, if you find it useful. Feel free for pull requests.

CHEERS!!!

gstreamer-python's People

Contributors

sahilparekh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gstreamer-python's Issues

child process killed by pare error.

Hello, I have 11 child-processes and 1 parent-process. Child-processes are exist for streaming each eleven cameras and the parent-process makes and runs child-processes. Some processes in 11 processes were killed by parse error.

I'm getting the following error :

Error received from element m_rtspsrc: gst-resource-error-quark: Could not read from resource. (9)
Debugging information: gstrtspsrc.c(5216): gst_rtspsrc_loop_interleaved (): /GstPipeline:pipeline0/GstRTSPSrc:m_rtspsrc:
Could not receive message. (Parse error)
terminating cam pipe
Stopping CAM Stream by main process

Anybody can you tell me how to solve this? Any information would be appreciated. Thanks in advance.

Output resolution

Hi, I'm using your code and it works with very low latency as with its basic configuration. I see you already put latency=0 in the code... I like it!
I've a pair of questions for you:

  • Can you suggest how to resize the output window to a desired dimension? (my camera outputs at 1280 x 720, and I would like my window to fill the screen at 1920 x 1080)

  • Can you suggest how to check if stream is present and in case display a blank screen?

Thank you for your code, Davide.

CPU usage is too high

For 1920x1080 resolution.

The CPU is around 2 i7 cores.
May the pipeline configured with TCP/UDP connection will yield more efficiency.

Unable to display RTSP stream

Hi sahil,

Appreciate the work you have put in to read a rtsp stream using gstreamer.
I am trying to read from a Mambo Parrot drone a rtsp stream as numpy arrays. I have ran your instructions and code accordingly. The window pops up but after 1-2 frames it just stops and breaks.

The following error was thrown up :
Error received from element m_rtspsrc: gst-resource-error-quark: Could not read from resource. (9)
Debugging information: gstrtspsrc.c(4662): gst_rtspsrc_loop_interleaved (): /GstPipeline:pipeline0/GstRTSPSrc:m_rtspsrc:
Could not receive message. (Parse error)

This error also keeps popping up before the above error:
Unexpected message received
Unexpected message received

Hope you can point me in the right direction as to how to fix this. Thank you very much!

Not working on NVIDIA TX2 board

Hi,

On NVIDIA TX2 it seems that this pipline (from vid_streamv3.py):

rtspsrc name=m_rtspsrc ! rtph264depay name=m_rtph264depay ! avdec_h264 name=m_avdech264 ! videoconvert name=m_videoconvert ! videorate name=m_videorate ! appsink name=m_appsink'

Doesn't work.

This pipeline works for me on the command line to show on the screen so probably something more similar to that should be used:

rtspsrc location=rtsp://10.5.1.10/video1 ! queue ! decodebin ! videoconvert ! xvimagesin

Thank you, Sela.

How to increase frame size?

Hi
I use the code and found that the image size is small and only (352,288). How can I increase size?
My camera is 2M camera.

Doesn't work, while it works with a plain GST pipeline

Works:

gst-launch-1.0 rtspsrc location=rtsp://192.168.188.31:6554/trackID=0  ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert  autovideosink sync=false

Does not work:

Neils-MBP:GStreamer-Python neilyoung$ python3 main_prg.py 
Unexpected message received.
Pipeline state changed from null to ready.
Unexpected message received.
Pipeline state changed from ready to paused.
Unexpected message received.
Unexpected message received.
Unexpected message received.
Unexpected message received.
Unexpected message received.
Unexpected message received.
Unexpected message received.
0:00:00.489118000  9060 0x7fd5760c78c0 FIXME                default gstutils.c:4026:gst_pad_create_stream_id_internal:<fakesrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
Unexpected message received.
Unexpected message received.
Unexpected message received.
Unexpected message received.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.