0

I can open a stream in VLC but in OpenCV I cannot capture frames. (Python 2.7, OpenCV 3.4.3 binary distribution x86, Windows 10). I've been following this guide: https://medium.com/@tomgrek/hackers-guide-to-the-aws-deeplens-1b8281bc6e24 but I cannot seem to read from random streams online (not sure whether I should be able to, I saw this question opencv videocapture can't open MJPEG stream about compiling with ffmpeg but I just downloaded the binary available in Sourceforge).

  • I am using an AWS Deeplens, updated to the latest version.

  • Installed ffmpeg, latest version.

Then, in /etc/ffserver.conf I added:

<Stream camera.h264>
File "/opt/awscam/out/ch1_out.h264"
VideoFrameRate 6
VideoSize 320x240
NoAudio
</Stream>

<Stream camera.mjpeg>
File "/opt/awscam/out/ch2_out.mjpeg"
VideoFrameRate 3
VideoSize 640x480
Format mjpeg
NoAudio
</Stream>
  • I start ffserver -f /etc/ffserver.conf
  • On my Windows machine, I use WSL and open an SSH tunnel into the AWS Deeplens ssh -L 8090:localhost:8090 aws_cam@192.168.0.10
  • At this point, in my Windows machine I can open VLC and if I point to http://localhost:8090/camera.mjpeg I can see the stream from the camera.

But if I run the following code:

cam = cv2.VideoCapture("http://localhost:8090/camera.mjpeg")
success, frame = cam.read()
opened = cam.isOpened()
success, frame, opened

I get:

False, None, False

If I browse to http://localhost:8090/stat.html, I see:

Available Streams
Path    Served Conns     bytes  Format  Bit rate kbits/s    Video kbits/s   Codec   Audio kbits/s    Codec  Feed
test1.mpg   0   0   mpeg    96  64  mpeg1video  32  mp2 feed1.ffm
test.asf    0   0   asf_stream  320 256 msmpeg4 64  wmav2   feed1.ffm
stat.html   17  42150   -   -   -       -   
index.html  0   0   -   -   -       -   
camera.h264 3   6805k   h264    0   0   libx264 0       /opt/awscam/out/ch1_out.h264
camera.mjpeg    12  41073k  mjpeg   0   0   mjpeg   0       /opt/awscam/out/ch2_out.mjpeg

And every time I call VideoCapture() I see how the number of Served for the camera.mjpeg stream increased by a 2 or 3 and the bytes, increases a few megabytes but I don't see anything in OpenCV. I have not tried any other video device in my Windows 10 but I can read images no problem. I also tried a random stream online, also opens in VLC but not in OpenCV, tried this one: http://136.176.70.200/mjpg/video.mjpg

Any ideas?

Josep Valls
  • 5,483
  • 2
  • 33
  • 67

1 Answers1

0

Looks like I need to compile OpenCV myself with ffmpeg support.

Josep Valls
  • 5,483
  • 2
  • 33
  • 67