User Tools

Site Tools


solutions:video_stream_using_rpi_as_proxy

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
solutions:video_stream_using_rpi_as_proxy [2021/07/26 12:00] – created atolstovsolutions:video_stream_using_rpi_as_proxy [2021/08/04 10:13] atolstov
Line 1: Line 1:
-  * **Dahua** DH-IPC-K22 +==== Intro ==== 
-  **Hikvision** DS-2CD2423G0-IW+ 
 +Nowadays, IP camera's manufacturers do not provide unauthorized access to video stream due to security reasons. To use videostream in WebHMI it should be without login/password to access. Also, using a server in between PC and IP Camera will allow access from many users, what is a true broadcast, unlike direct IP camera connection, which is usually limited to 10 users.  
 + 
 +The solution, is the shim web server in LAN, which will transcode H.264 to MJPEG. (e.g. Raspberry Pi). 
 +Also, this could be a Linux or Windows powered machine.  
 + 
 + 
 + 
 +==== Devices prerequisites ==== 
 +=== IP Webcam testing app === 
 + 
 +If there is no IP camera at moment, you can use [[https://play.google.com/store/apps/details?id=com.pas.webcam|IP Webcam]] to test WebHMI videostream (as it is not ecrypted be default) or VLC transcoding if you want to substitute phone with IP camera later after testing.  
 + 
 + 
 +Any IP camera, that can show stream using rtsp:// or http:// protocol. 
 + 
 +You can see the links at IP Webcam app screen. When the IP Webcam server started, it has default cgi access via link <code> http://phone-ip:8080/video</code> 
 + 
 + 
 +=== IP camera CGI setting === 
 +By default, cgi should be enabled manually in settings.\\ 
 +''Hikvision: Configuration, Network, Advanced Settings, Enable Hikvision-CGI. Then create a cgi user.''\\ 
 +''Dahua: Configuration, Integration Protocol, Enable CGI. Use web login user.''\\ 
 + 
 + 
 +=== Tested devices list: ===  
 +For example, there was a two different manufacturers devices tested. 
 +**Dahua** DH-IPC-K22          <code bash cgi-link>http://login:password@ip-camera:80/cgi-bin/mjpg/video.cgi?channel=1&subtype=1</code> 
 + 
 +**Hikvision** DS-2CD2423G0-IW <code bash cgi-link>http://login:password@ip-camera:80/Streaming/channels/102/httpPreview</code>
  
  
 ==== VLC transcode ==== ==== VLC transcode ====
-<code bash>+  * WebHMI with IP 192.168.1.1 
 +  * IP Camera with IP 192.168.1.2 
 +  * Broadcast server with IP 192.168.1.3
  
-#full  +Broadcast server can be Windows or Linux machinee.gRapsbian on Raspberry Pi 
-vlc -Idummy rtsp://student:Hikvision@192.168.1.58:554/Streaming/Channels/102  --sout "#transcode{vcodec=MJPG}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=192.168.1.192:8888/}" +Let's consider using Rapsberry Pi 3B+ powered Raspbian 10.
-vlc -Idummy http://student:Hikvision@192.168.1.58:80/Streaming/channels/102/httpPreview --sout "#transcode{vcodec=MJPG}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=192.168.1.192:8888/}"+
  
-#width crop  +To do this, VLC player is preinstalled with Rapsbian.  
-vlc -Idummy rtsp://student:Hikvision@192.168.1.58:554/Streaming/Channels/102  --sout "#transcode{vcodec=MJPG,vfilter=canvas{width=640,height=480}}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=192.168.1.192:8888/}" +If it is not present in the system, you can install it with 
-vlc -Idummy http://student:Hikvision@192.168.1.58:80/Streaming/channels/102/httpPreview --sout "#transcode{vcodec=MJPG,vfilter=canvas{width=640,height=480}}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=192.168.1.192:8888/}"+<code bash>sudo apt-get install vlc</code> 
 +To start with, login to IP-camera and check the settings, if cgi enabled and test access via link using browser. 
 +Alternatively, if you want to test to possibility, use IP Webcam appThere is default config which allows both vlc or WebHMI videostream testing. 
 + 
 +===Command to output and argument explanations=== 
 +Access to IP cameras stream usually can be provided via RTSP or HTTP protocols. 
 +Put the link in the following example and try to watch and then to transcode stream
 + 
 + 
 +<code bash example_stream> 
 +cvlc -vvv http://login:password@ip-address:port/link_to_stream
 </code> </code>
 +That should look like this:
 +<code bash test_stream>
 +cvlc -vvv rtsp://student:Hikvision@192.168.1.58:554/Streaming/Channels/102
 +</code>
 +
 +If you can see the image, so the IP camera settings done and now you can start configure transcoding.
 +
 +<code bash example_transcode_stream>
 +cvlc -vvv -Idummy http://login:password@ip-address:port/link_to_stream  --sout "#transcode{vcodec=MJPG}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8888/}"
 +</code>
 +
 +For example let's use login and password with IP camera' IP, using RTSP protocol (through 554 port) and transcode the full resolution stream to 192.168.1.3:8888 which is Raspberry Pi server and custom port 8888.
 +
 +<code bash test_transcode_stream>
 +cvlc -vvv -Idummy rtsp://student:Hikvision@192.168.1.2:554/Streaming/Channels/102  --sout "#transcode{vcodec=MJPG}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=192.168.1.3:8888/}"
 +</code>
 +
 +Let's take a closer look at the command. The source stream is:
 +<code>rtsp://student:Hikvision@192.168.1.2:554</code>  
 +Destination can be also set port only, and the IP will be IP of Raspberry Pi to get access to stream
 +<code>dst=:8888/</code>
 +The output broadcast URL is
 +<code>http://192.168.1.3:8888</code>
 +
 +
 +To test if it works, copy following link to terminal and run with ''-vvv'' argument to show the maximum verbosity.
 +The output should not have warning and unresolved errors such as no codecs finded.
 +
 +==== Perfomance optimisation ====
 +
 +<WRAP center round important 60%>
 +Do not forget to get rid of ''-vvv'' argument due to huge additional processor load. 
 +</WRAP>
 +
 +
 +There are some variants to try to optimize performance 
 +
 +  * Decrease IP camera stream resolution
 +  * Lower transcode output resolution
 + 
 +=== Lower picture resolution === 
 +<code bash>
 +#full resolution
 +cvlc -Idummy http://login:password@ip-address:80/link_to_stream --sout "#transcode{vcodec=MJPG}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8888/}"
 +cvlc -Idummy rtsp://http://login:password@ip-address:554/link_to_stream --sout "#transcode{vcodec=MJPG}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8888/}"
 +
 +#transcode to lower resolution 
 +cvlc -Idummy http://login:password@ip-address:80/link_to_stream --sout "#transcode{vcodec=MJPG,vfilter=canvas{width=640,height=480}}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8888/}"
 +cvlc -Idummy rtsp://http://login:password@ip-address:554/link_to_stream --sout "#transcode{vcodec=MJPG,vfilter=canvas{width=640,height=480}}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8888/}"
 +</code>
 +
  
  
  
solutions/video_stream_using_rpi_as_proxy.txt · Last modified: 2022/01/15 01:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki