LukasBommes / mv-extractor

Extract frames and motion vectors from H.264 and MPEG-4 encoded video.
MIT License
296 stars 58 forks source link

VideoCap with H264 capable Webcam? #4

Closed ImanityDev closed 2 years ago

ImanityDev commented 3 years ago

I was looking to implement several types of motion detection with a webcam on an embedded system. However, for this project to work I'd either need to implement all of this myself or have direct access to the webcam via the VideoCap-class, just like OpenCV does it using the device index. Would this be possible to implement?

LukasBommes commented 3 years ago

Hey Madv0x, if your webcam supports the Real-Time Streaming Protocol (RTSP) you can simply provide the RTSP URL in the open method of the VideoCap object. If your webcam does not support RTSP, you have to give it a try using the device index in the open method. It shoudl work, however I haven't tested this case. If it does not work, the implementation of VideoCap::open in src/video_cap.cpp has to be modified. The source code of the videoio module in OpenCV can provide hints on how to do it: https://github.com/opencv/opencv/blob/master/modules/videoio/src/cap_ffmpeg_impl.hpp#L883

LukasBommes commented 2 years ago

Closing due to inactivity. Feel free to reopen for further discussion.

Tran-Long commented 11 months ago

Hi @LukasBommes, thanks for your amazing library. I have some questions, please help me

  1. I was trying to open the webcam via cam index but not success. As you mentioned earlier in this thread, we should modify the src/video_cap.cpp. Can you update the library at this point?
  2. I also try to use streaming data. I run Python code in wsl and read streaming video from the webcam of my window host (streaming via MJPEG Streamer app in Window store). While doing this, all of the frame I got is the key frame (i.e type "I") and thus there is no motion vectors extracted. Is it a bug or am I missing something?

Please take a look and help me. Thank you so much