简体   繁体   English

捕获和播放MJPEG-使用OpenCV和ffmpeg通过UDP传输网络视频流

[英]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. 我正在尝试接收和显示udp实时mjpeg-来自网络摄像头的网络视频流。 I can play the video stream by starting VLC with the Argument --demux=mjpeg and then typing udp://@:1234 in the network stream field. 通过使用参数--demux=mjpeg启动VLC,然后在网络流字段中键入udp://@:1234 ,可以播放视频流。 Or with gstreamer by the console line: gst-launch -v udpsrc port=1234 ! jpegdec ! autovideosink 或通过控制台行使用gstreamer: gst-launch -v udpsrc port=1234 ! jpegdec ! autovideosink 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 . 我的Cam的IP地址为192.168.1.2 ,它将流发送到地址192.168.1.1:1234

I've tried to capture the stream with OpenCV with: 我试图用OpenCV捕获流:

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 . 但是该函数将一直挂起,直到我按ctrl+C为止。 I have the same problem when I use ffmpeg with: ffmpeg -i udp://@192.168.1.1:1234 -vcodec mjpeg 当我将ffmpeg与以下内容一起使用时,我会遇到相同的问题: 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 . 当我安装ffmpeg时,我无法安装依赖项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? 如果是这样,有什么方法可以从套接字读取udp帧,然后解码JPEG图片并用OpenCV显示它?

I have the OS Ubuntu linaro oneiric 11.10 with the kernel 3.0.35 from Freescale 我有Freescale linaro oneiric 11.10操作系统和Freescale内核3.0.35

thanks any way. 不管怎么说,还是要谢谢你。 i have fixed this problem by installing a newr version of ffmpeg and using the C-Api of ffmpeg 我通过安装较新版本的ffmpeg并使用ffmpeg的C-Api解决了此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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