简体   繁体   中英

Capture and play MJPEG - Network Video stream over UDP with OpenCV and ffmpeg

I'm trying to receive and display a udp live mjpeg - network video stream from a network cam. I can play the video stream by starting VLC with the Argument --demux=mjpeg and then typing udp://@:1234 in the network stream field. Or with gstreamer by the console line: gst-launch -v udpsrc port=1234 ! jpegdec ! autovideosink gst-launch -v udpsrc port=1234 ! jpegdec ! autovideosink gst-launch -v udpsrc port=1234 ! jpegdec ! autovideosink . My Cam has the IP Address 192.168.1.2 and it sends the stream to the address 192.168.1.1:1234 .

I've tried to capture the stream with OpenCV with:

cv::VideoCapture cap;
cap.open("udp://@192.168.1.1:1234");

I tried also:

cap.open("udp://@:1234")

cap.open("udp://@localhost:1234")

cap.open("udp://192.168.1.1:1234")

cap.open("udp://192.168.1.1:1234/")

But the function hangs until I press ctrl+C . I have the same problem when I use ffmpeg with: ffmpeg -i udp://@192.168.1.1:1234 -vcodec mjpeg

What did I do wrong? When i installed ffmpeg i couldn't install the dependency libsdl1.2-dev . Is that the problem?

If so, there is any way to read the udp-frames from the socket and then decode the JPEG pictures and display it with OpenCV?

I have the OS Ubuntu linaro oneiric 11.10 with the kernel 3.0.35 from Freescale

thanks any way. i have fixed this problem by installing a newr version of ffmpeg and using the C-Api of ffmpeg

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