如何使用Python重塑脚本的输出流以使其适用于cvlc流?

问题描述

流包含来自树莓派pi相机的帧。

stream.py需要更改:

import sys
import cv2
from picamera.array import PiRGBArray
from picamera import PiCamera
import time


RES_W = 640
RES_H = 480

camera = PiCamera()
camera.resolution = (RES_W,RES_H)
camera.framerate = 24 # FPS
rawCapture = PiRGBArray(camera,size=(RES_W,RES_H))

# allow the camera to warmup
time.sleep(2)

for frame in camera.capture_continuous(rawCapture,format="bgr"):
    
    # image is apparently not the right format for cvlc
    image = frame.array
    # processing the image for face recognition purposes
    # ...

    # related to first reference
    sys.stdout.buffer.write(image)

    # clear the stream in preparation for the next frame
    rawCapture.truncate(0)

我用来将 stream.py 输出流传输到cvlc 的命令不起作用,因为cvlc似乎无法正确解释该流

(服务器)

python3 stream.py | cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264

应该可以使用:

(客户端)

vlc http://raspBerrypi:8090

它通过以下方式毫无问题地工作:

(服务器)

raspivid -o - -t 0 -n -w 640 -h 400 -fps 24 | cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,dst=:8090}' :demux=h264

有关更多参考:

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)