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

Both sides previous revisionPrevious revision
Next revision
Previous revision
solutions:video_stream_using_rpi_as_proxy [2021/07/30 09:33] atolstovsolutions:video_stream_using_rpi_as_proxy [2022/01/15 01:30] (current) – ↷ Links adapted because of a move operation 127.0.0.1
Line 1: Line 1:
-==== Intro ====+{{ network:video_proxy_my_icon.jpg?nolink&150|}} 
 +====== Video stream proxy ======
  
-Nowadays, IP camera's manufacturers does 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. +===== Intro ===== 
 + 
 +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). The solution, is the shim web server in LAN, which will transcode H.264 to MJPEG. (e.g. Raspberry Pi).
Line 8: Line 11:
  
  
-==== Devices prerequisites ==== +===== Devices prerequisites ===== 
-Any IP camera, that can show stream using rstp:// or http:// protocol.+==== 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.\\ By default, cgi should be enabled manually in settings.\\
-''Hikvision: Configuration, Network, Advanced Settings, Enable Hikvision-CGI. Then create a cgi user.'' +''Hikvision: Configuration, Network, Advanced Settings, Enable Hikvision-CGI. Then create a cgi user.''\\ 
-''Dahua: Configuration, Integration Protocol, Enable CGI. Use web login user.''+''Dahua: Configuration, Integration Protocol, Enable CGI. Use web login user.''\\
  
  
 === Tested devices list: ===  === 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> **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> **Hikvision** DS-2CD2423G0-IW <code bash cgi-link>http://login:password@ip-camera:80/Streaming/channels/102/httpPreview</code>
- 
- 
  
  
Line 27: Line 38:
   * WebHMI with IP 192.168.1.1   * WebHMI with IP 192.168.1.1
   * IP Camera with IP 192.168.1.2   * IP Camera with IP 192.168.1.2
-  * Raspberry Pi with IP 192.168.1.3+  * Broadcast server with IP 192.168.1.3
  
-It can be done with Windows machine or Linux, e.g. Rapsbian on Raspberry Pi.+Broadcast server can be Windows or Linux machine, e.g. Rapsbian on Raspberry Pi .
 Let's consider using Rapsberry Pi 3B+ powered Raspbian 10. Let's consider using Rapsberry Pi 3B+ powered Raspbian 10.
  
 To do this, VLC player is preinstalled with Rapsbian.  To do this, VLC player is preinstalled with Rapsbian. 
 +If it is not present in the system, you can install it with
 +<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. To start with, login to IP-camera and check the settings, if cgi enabled and test access via link using browser.
-To test if it workscopy following link to terminal and run with ''-vvv'' argument to show the maximum verbosity.+Alternativelyif you want to test to possibility, use IP Webcam app. There is default config which allows both vlc or WebHMI videostream testing.
  
 ===Command to output and argument explanations=== ===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>
 +That should look like this:
 <code bash test_stream> <code bash test_stream>
 cvlc -vvv rtsp://student:Hikvision@192.168.1.58:554/Streaming/Channels/102 cvlc -vvv rtsp://student:Hikvision@192.168.1.58:554/Streaming/Channels/102
 </code> </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> <code bash test_transcode_stream>
Line 46: Line 74:
 </code> </code>
  
-where+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>
  
-<code>rtsp://student:Hikvision@192.168.1.2:554</code>  - login and password with IP camera' IP, using RSTP protocol (through 554 port) 
-<code>dst=192.168.1.3:8888/</code> is the Raspberry Pi IP with custom port, e.g. 8888. 
  
 +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.
  
-The output should not have warning and unresolved errors such as no codecs finded +==== Perfomance optimisation ====
  
-There are some variants to try to optimize perfomance +<WRAP center round important 60%> 
 +Do not forget to get rid of ''-vvv'' argument due to huge additional processor load.  
 +</WRAP>
  
-=== Dahua ===  
-<code bash> 
- #full crop  
-cvlc -Idummy http://admin:admin@192.168.1.101/cgi-bin/mjpg/video.cgi?channel=1&subtype=1 --sout "#transcode{vcodec=MJPG}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8888/}" 
-cvlc -Idummy rtsp://admin:admin@192.168.1.101/cgi-bin/mjpg/video.cgi?channel=1&subtype=1 --sout "#transcode{vcodec=MJPG}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8888/}" 
  
-#width crop  +There are some variants to try to optimize performance 
-cvlc -Idummy http://admin:admin@192.168.1.101/cgi-bin/mjpg/video.cgi?channel=1&subtype=1 --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://admin:admin@192.168.1.101/cgi-bin/mjpg/video.cgi?channel=1&subtype=1 --sout "#transcode{vcodec=MJPG,vfilter=canvas{width=640,height=480}}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8888/}"+
  
- +  * Decrease IP camera stream resolution 
-</code> +  * Lower transcode output resolution 
-=== Hikvision ===+  
 +=== Lower picture resolution === 
 <code bash> <code bash>
-#full  +#full resolution 
-cvlc -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=:8888/}" +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 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=: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/}"
  
-#width crop  +#transcode to lower resolution  
-cvlc -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=:8888/}" +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 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=: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> </code>
  
solutions/video_stream_using_rpi_as_proxy.1627637609.txt.gz · Last modified: 2021/07/30 09:33 by atolstov

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki