Mapping HTTP MJPEG IP Camera Video feed to video device
This is a very small concept but sometimes most useful logic that can solve biggest challenges if you want to get video feed wireless from IP Camera Android App or any other Pi Camera etc. Further, this method will map that HTTP mjpeg video stream to your linux video driver v4l. If you want to use opencv & process that IP Camera for facerecognition or else. Few, people tried to convert the string byte streams of video by cv2.imdecode() function from start & stop delimeters of streams but its was again needed to be converted to numpy array or opencv matrix array to get each frame to be processed which is very slow & requires lot processing from server side.
Dependecies:
- Video4Linux: sudo apt-get install build-essential libjpeg8-dev imagemagick libv4l-dev v4l-utils checkinstall
- VideoLoopback:
- sudo apt-get install build-essential checkinstall
- wget https://github.com/umlaeute/v4l2loopback/archive/master.zip
- unzip master.zip
- cd v4l2loopback-master
- make
- sudo checkinstall --pkgname=v4l2loopback --pkgversion="$(date +%Y%m%d%H%M)-git" --default
Test your video stream formats:
http://<YOUR IP ADDRESS>/video
http://<YOUR IP ADDRESS>/livestream.cgi?user=admin&pwd=&streamid=0&audio=0
rtsp://IP:PORT/axis-cgi/mjpg/video.cgi
http://IP:PORT/mjpg/video.mjpg
Read this for detailed info about IP Camera models & HTTP formats:
http://funvision.blogspot.in/2016/11/ip-camera-video-stream-opencv-and.html
Read this if you want to check for ffmpeg argument lists & input/output formats:
https://linux.die.net/man/1/ffmpeg
How to capture & map to camera device ID 1?
- sudo modprobe v4l2loopback
- ffmpeg -re -i http://192.168.43.1:8080/video -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video1
Now, you can use cv2.VideoCapture(1) & get input video feed
References:
- http://blogs.techvedika.com/mjpeg-linux-video-streaming-and-recording-over-http/
- https://blog.miguelgrinberg.com/post/how-to-build-and-run-mjpg-streamer-on-the-raspberry-pi
- https://askubuntu.com/questions/881305/is-there-any-way-ffmpeg-send-video-to-dev-video0-on-ubuntu
- https://stackoverflow.com/questions/26459560/ffmpeg-ip-camera-stream-recording
0 comments:
Post a Comment
Thanks for your comment. We will try to reply as soon as possible.
Regards
VSL Creations