I use python and opencv-python to capture frames from video, then use ffmpeg command to push rtsp stream with pipe. I can play the rtsp stream via gstreamer and vlc. However, a display device cannot decode and play the rtsp-stream because it cannot receive SPS and PPS frames. Use wireshark to capture stream, found that it doesn't send sps and pps frames, only send IDR frames.
The key codes are as follows.
# ffmpeg command
command = ['ffmpeg',
'-re',
'-y',
'-f', 'rawvideo',
'-vcodec', 'rawvideo',
'-pix_fmt', 'bgr24',
'-s', "{}x{}".format(width, height),
'-r', str(fps),
'-i', '-',
'-c:v', 'libx264',
'-preset', 'ultrafast',
'-f', 'rtsp',
'-flags', 'local_headers',
'-rtsp_transport', 'tcp',
'-muxdelay', '0.1',
rtsp_url]
p = sp.Popen(command, stdin=sp.PIPE)
while (cap.isOpened()):
ret, frame = cap.read()
if not ret:
cap = cv2.VideoCapture(video_path)
continue
p.stdin.write(frame.tobytes()
May be I miss some options of ffmpeg command?