I need to catch RTSP stream from my IP-camera for convert and streaming to site. First I wanted use ffmpeg, but have not found ffmpeg wrappers for python2.7. Who can help me?
2 Answers
you don't need wrappers for ffmpeg, you can just execute commands directly from python
import os
os.system("ffmpeg -i rtsp://192.168.1.100/stream -codec copy -f h264 output.mp4 -codec copy -f mpegts udp://127.0.0.1:3000 &")
this captures an rtsp stream from 192.168.1.100/stream (replace this with your camera IP and streaming url, this would be in the camera settings probably on the camera site at 192.168.1.100), outputs it to an mp4 file and re-streams it to a local udp port 3000
need more information to know exactly what you're looking for
3 Comments
CuCaRot
I need to take frame by frame to numpy array form from rtsp link (real time processing), any solution?
luvwinnie
any solution with this?
Abhay Salvi
Yeah but for that you need ffmpeg pre installed
Here's a way to capture a single frame from an RTSP stream and save it to disk. You could modify this to save a video stream as well if you wanted:
import ffmpeg
stream = ffmpeg.input("rtsp://<IP or host>:554/", ss=0)
file = stream.output("test.png", vframes=1)
testfile = file.run(capture_stdout=True, capture_stderr=True)
1 Comment
Hendy
Maybe because it's 2021, but I had to install
ffmpeg-python or I got the error module 'ffmpeg' has no attribute 'input'