通过命令行中的ffmpeg或opencv获取灰色图像从IP摄像头捕获图像(capture image from IP camera through ffmpeg in command line or opencv getting a gray image)

现在我有一台IP摄像头。 我试图通过ffmpeg获取图像(像这样:ffmpeg -rtsp_transport tcp -i“我的rtsp流地址”-y -f image2 test.jpg)。没关系! 或者我试图通过opencv做到这一点,也没有问题。但是当我在vlc中打开流时,同时,我试图捕获图像,哦,我刚刚得到一个灰色图像。 为什么? 如果我在vlc中打开流两次,那也没关系! 如果捕获图像并一起查看rtsp流,只得到一个灰色图像。这是IP摄像头的原因? 正常图像 灰度图像

Now I have a IP camera. I tried to get a image through ffmpeg (like this : ffmpeg -rtsp_transport tcp -i "my rtsp stream address" -y -f image2 test.jpg ).That's OK! Or I tried to do this through opencv,no problem too.But when I open the stream in vlc,At the same time,I tried to capture the image ,oh,I just got a gray image. why? if I open the stream in vlc two times,that's also OK! If capturing the image and view the rtsp stream together,just got a gray image.Is the reason of IP camera?normal imagegray image

最满意答案

试试这个https://gist.github.com/jamek/1dda2add62b3f7ac415a

g++ -s -o ffmpeg_rtsp rtsp.cpp -lavcodec -lavutil -lswscale -lavformat

运行: ./ffmpeg_rtsp "your rtsp stream address"

Try this https://gist.github.com/jamek/1dda2add62b3f7ac415a

g++ -s -o ffmpeg_rtsp rtsp.cpp -lavcodec -lavutil -lswscale -lavformat

Run: ./ffmpeg_rtsp "your rtsp stream address"

更多推荐