ffmpeg/ffplay实时播放rtmp视频流(解决高延迟问题)
ffplay -noinfbuf -fflags nobuffer -analyzeduration 10000 -i rtmp://192.168.1.123:1935/hls/test
python调用ffmpeg实时播放rtmp视频流(解决高延迟问题)
(安装opencv-python\opencv-contrib-python的4.1.1.26版本即可)
import numpy as np
import cv2
def main():
print("OpenCV Version:{}".format(cv2.__version__))
# 0: use CSI camera,1:use USB camera
ip_camera_url = 'rtmp://192.168.1.123:1935/hls/test'
cap = cv2.VideoCapture(ip_camera_url)
if(not cap.isOpened()):
print("can't open this camera")
while(True):
ret, FrameImage = cap.read()
if ret == True:
cv2.imshow('Camera Capture',FrameImage)
#Press Q to quit
if (cv2.waitKey(1)) == ord('q'):
cap.release()
break
else:
break
if __name__ == '__main__':
main()
# Release resource
cv2.destroyAllWindows()
linux下实时屏幕推流
ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+0,0 -vcodec h264 -max_delay 100 -f flv -g 5 -b 700000 -preset ultrafast rtmp://127.0.0.1:1935/hls/test