简体   繁体   中英

RTMP stream from OpenCV/cv2 to an nginx server, but client get just a green window

I would like to implement a surveillance server to detect objects with openCV.

For this I setup an Ubuntu server for this workflow:

Mobile CAM (from an Android) stream
|
| put the stream with RTMP to server rtmp://nginx/live/in [1]
|
v
nginx with the rtmp plugin
^
|
| the python script gets the mobile CAM stream from nginx rtmp://nginx/live/in [2]
|
v
surveillance script
|
| Stream to output back to rtmp://nginx/live/out with the results [3]
|
v
nginx with the rtmp plugin
^
|
| get the output stream from nginx rtmp://nginx/live/in [4]
|
RTMP stream client

I'm really not in the deep with stream and RTMP paramters. Up to now, I got [1] and [2] working, so I have the video from the mobile CAM in the frame from the phython OpenCV script.

On the destination client [4] (I use ffplay rtmp://nginx/live/out), I just have a green window, nothing else in it.

I use this for the streaming part:

...
                send_gst = "appsrc ! videoconvert ! video/x-raw,format=I420,clock-rate=90000 ! x264enc ! video/x-h264,stream-format=(string)byte-stream,alignment=(string)au ! h264parse ! queue ! flvmux ! rtmpsink location=rtmp://nginx/live/out"
                writer = cv2.VideoWriter(send_gst, 0, 20, (520, 380), True)
...
        if writer is not None:
                writer.write(frame)
...

Maybe there is someone who can give me some hints or which part of code is needet to help me.

Solved, the source and destination resolution should be the same

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM