Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision |
solutions:video_stream_using_rpi_as_proxy [2021/08/04 09:46] – atolstov | solutions:video_stream_using_rpi_as_proxy [2021/08/05 16:34] – [Video proxy method] emozolyak |
---|
==== Intro ==== | {{ ::video_proxy_my_icon.jpg?nolink&150|}} |
| ====== Video stream proxy ====== |
| |
| ===== 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. | 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. |
| |
| |
==== Devices prerequisites ==== | ===== Devices prerequisites ===== |
=== IP Webcam testing app === | ==== 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. | 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 rstp:// or http:// protocol. | 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>. | 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 === | ==== 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.''\\ |
</code> | </code> |
| |
For example let's use login and password with IP camera' IP, using RSTP 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. | 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> |
</code> | </code> |
| |
So, the source stream is: | Let's take a closer look at the command. The source stream is: |
<code>rtsp://student:Hikvision@192.168.1.2:554</code> | <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 | Destination can be also set port only, and the IP will be IP of Raspberry Pi to get access to stream |
| |
| |
There are some variants to try to optimize perfomance | There are some variants to try to optimize performance |
Crop the output resolution, | |
=== 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 | * Decrease IP camera stream resolution |
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/}" | * Lower transcode output resolution |
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/}" | |
| === Lower picture resolution === |
| |
</code> | |
=== Hikvision === | |
<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> |
| |