[HOW-TO] make this rtsp stream stable?
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- python, raspberry-pi
- Domain
- audio-video-rtc, embedded-iot
Research direction
Start with camera.py, especially FfmpegOutput, the assigned error_callback, and start_encoder; main.py shows the continuous-running entry point. Reproduce the stream interruption and inspect the complete broken-pipe exception and callback output to determine whether the failure is reported by ffmpeg or Picamera2. Done means the failure source is identified and the stream's stability issue is addressed.
Written by the indexing model from the issue text.
Description
i have a example to push rtsp stream to my server
raspberrypi 4b
picamera2 0.3.18
python 3.11.2
camera.py
from picamera2 import Picamera2
from picamera2.encoders import H264Encoder
from picamera2.outputs import FfmpegOutput
from tool.log.log_uru import Logger
class Camera(object):
def __init__(self, sn):
self.rtsp = None
self.lug = Logger().get_logger
self.picam2 = Picamera2()
# Picamera2.set_logging(Picamera2.DEBUG)
# rtsp推流的编码
self.encoder = None
resolution = (1280, 720)
self.picam2.configure(self.picam2.create_video_configuration(main={"size": resolution}))
self.picam2.start()
self.lug.info("Camera initialized")
self.start_rtsp()
def error_callback(self, e):
"""
picamera2异常断开的回调函数
"""
self.lug.error("Camera Error {}", e)
# 重连
# self.picam2.stop_encoder(self.encoder)
# self.start_rtsp()
# self.lug.warning("reconnecting...")
def start_rtsp(self):
# self.encoder = H264Encoder(bitrate=1000000)
self.encoder = H264Encoder(bitrate=1000000, repeat=True, iperiod=15, framerate=15)
self.rtsp = FfmpegOutput("-f rtsp rtsp://myserverip/live/test")
self.rtsp.error_callback = self.error_callback
self.encoder.output = self.rtsp
self.picam2.start_encoder(self.encoder)
def stop(self):
"""
停止camera
:return:
"""
self.picam2.stop()
i run this camera.
main.py
if __name__ == '__main__':
Camera("camera")
while True:
pass
However, if he pushes the RTSP stream for a maximum of 10 minutes, a broken pipe exception will appear。i want to know this is the ffmpeg's error or picamera2's error;
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 258
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from raspberrypi/picamera2
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
raspberrypi/picamera2#1405 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
raspberrypi/picamera2#1404 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 57/100
raspberrypi/picamera2#1403 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
raspberrypi/picamera2#1392 · 13 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
raspberrypi/picamera2#1389 · 4 comments ·
All issues in raspberrypi/picamera2
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100