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
Last revisionBoth sides next revision
solutions:video_stream_using_rpi_as_proxy [2021/07/30 08:23] atolstovsolutions:video_stream_using_rpi_as_proxy [2021/08/05 16:34] – [Video proxy method] emozolyak
Line 1: Line 1:
-==== Intro ====+{{ ::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.  +===== Intro =====
-To get video stream to WebHMI it should be without login/password to access. +
  
 +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)
 +Also, this could be a Linux or Windows powered machine. 
  
  
  
-==== Devices prerequisites ==== +===== Devices prerequisites ===== 
-Any camera, that can show stream using rstp:// or http:// protocol. +==== IP Webcam testing app ====
-By default, cgi should be enabled manually in settings.\\ +
-''Hikvision: Configuration, Network, Advanced Settings, Enable Hikvision-CGI.'' +
-''Dahua: Configuration, Network, Advanced Settings, Enable Hikvision-CGI.''+
  
 +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. 
  
-Tested devices list: 
  
-**Dahua** DH-IPC-K22          <code>( link: http://login:password@ip-camera:80/cgi-bin/mjpg/video.cgi?channel=1&subtype=1 )</code>+Any IP camera, that can show stream using rtsp:// or http:// protocol.
  
-**Hikvision** DS-2CD2423G0-IW <code>( link: http://login:password@ip-camera:80/Streaming/channels/102/httpPreview )</code>+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 ====
-It can be done with Windows machine or Linux, e.g. Rapsbian on Raspberry Pi.+  * WebHMI with IP 192.168.1.1 
 +  * IP Camera with IP 192.168.1.2 
 +  * Broadcast server with IP 192.168.1.3 
 + 
 +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. 
-To start with, login to IP-camera and check the settings, if cgi enabled and test access via link using browser.  +If it is not present in the system, you can install it with 
-Thencopy following link to terminal and test with -vvv argument+<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. 
 +Alternativelyif you want to test to possibility, use IP Webcam app. There is default config which allows both vlc or WebHMI videostream testing.
  
-In the end, create a .sh script and add to autorun +===Command to output and argument explanations=== 
-<code bash> +Access to IP cameras stream usually can be provided via RTSP or HTTP protocols. 
-cvlc -vvv -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/}"+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> 
 +cvlc -vvv rtsp://student:Hikvision@192.168.1.58:554/Streaming/Channels/102
 </code> </code>
  
-The output should not have warning and unresolved errors such as no codecs finded  +If you can see the image, so the IP camera settings done and now you can start configure transcoding.
-Command to output and argument explanations +
-=== 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=192.168.1.192: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=192.168.1.192:8888/}"+
  
-#width crop  +<code bash example_transcode_stream> 
-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=192.168.1.192:8888/}" +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/}" 
-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=192.168.1.192: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> </code>
-=== Hikvision ===+ 
 +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> <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=192.168.1.192: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=192.168.1.192: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=192.168.1.192: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=192.168.1.192: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.txt · Last modified: 2022/01/15 01:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki