
Ich sehe, dass dieONVIF-Gerätemanagerfindet die Stream-URL kompatibler Kameras. Aber wie geht das? Gibt es eine Methode, um RTSP-Pfade von ONVIF-Kameras zu finden?
Antwort1
Entsprechend derONVIF-Kernspezifikation, bei einem ONVIF-kompatiblen Gerät ist der Einstiegspunkt für die Geräteverwaltung auf festgelegt http://${HOST}:${PORT}/onvif/device_service
.
Dieser Endpunkt wird für Geräteinteraktionen verwendet mitSOAP-Aktionen/-Operationen/-Befehle.
Eine weitere Spezifikation, dieONVIF-Mediendienstspezifikation, definiert Operationen zum Abfragen der unterstütztenProfile.
DerProfile abrufenDer Befehl gibt einen Überblick über alle Profile, die ein Gerät anbietet. Hier ist ein BeispielProfile abrufenAufruf mit curl
(und xmllint
zum schönen Ausdrucken der Antwort):
curl -X POST http://192.168.178.22:8080/onvif/device_service\
-H 'Content-Type: application/soap+xml; charset=utf-8'\
-H 'SOAPAction: "http://www.onvif.org/ver10/media/wsdl/GetProfiles"'\
-d '
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wsdl="http://www.onvif.org/ver10/media/wsdl">
<soap:Header/>
<soap:Body>
<wsdl:GetProfiles/>
</soap:Body>
</soap:Envelope>
' | xmllint --format -
Mein ONVIF-Gerät antwortet auf diesen Befehl mit folgendem (abgekürzt):
<SOAP-ENV:Envelope ...>
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<trt:GetProfilesResponse>
<trt:Profiles token="h264_ulaw_1920x1080" fixed="true">
<tt:Name>h264_ulaw_1920x1080</tt:Name>
<tt:VideoSourceConfiguration token="1920x1080_Config">
<tt:Name>1920x1080_Config</tt:Name>
<tt:UseCount>1</tt:UseCount>
<tt:SourceToken>1920x1080</tt:SourceToken>
<tt:Bounds x="0" y="0" width="1920" height="1080"/>
</tt:VideoSourceConfiguration>
<tt:AudioSourceConfiguration token="MicrophoneConfig">
<tt:Name>MicrophoneConfig</tt:Name>
<tt:UseCount>1</tt:UseCount>
<tt:SourceToken>Microphone</tt:SourceToken>
</tt:AudioSourceConfiguration>
<tt:VideoEncoderConfiguration token="h264">
<tt:Name>h264</tt:Name>
<tt:UseCount>1</tt:UseCount>
<tt:Encoding>H264</tt:Encoding>
<tt:Resolution>
<tt:Width>1920</tt:Width>
<tt:Height>1080</tt:Height>
</tt:Resolution>
<tt:Quality>0</tt:Quality>
<tt:RateControl>
<tt:FrameRateLimit>30</tt:FrameRateLimit>
<tt:EncodingInterval>1</tt:EncodingInterval>
<tt:BitrateLimit>2000</tt:BitrateLimit>
</tt:RateControl>
<tt:H264>
<tt:GovLength>150</tt:GovLength>
<tt:H264Profile>Baseline</tt:H264Profile>
</tt:H264>
<tt:Multicast>
<tt:Address>
<tt:Type>IPv4</tt:Type>
<tt:IPv4Address>192.168.178.22:8080</tt:IPv4Address>
</tt:Address>
<tt:Port>8080</tt:Port>
<tt:TTL>30</tt:TTL>
<tt:AutoStart>false</tt:AutoStart>
</tt:Multicast>
<tt:SessionTimeout>PT00H00M30S</tt:SessionTimeout>
</tt:VideoEncoderConfiguration>
<tt:AudioEncoderConfiguration token="AudioEncoder">
<tt:Name>AudioEncoder</tt:Name>
<tt:UseCount>0</tt:UseCount>
<tt:Encoding>G711</tt:Encoding>
<tt:Bitrate>1</tt:Bitrate>
<tt:SampleRate>8000</tt:SampleRate>
<tt:Multicast>
<tt:Address>
<tt:Type>IPv4</tt:Type>
<tt:IPv4Address>192.168.178.22:8080</tt:IPv4Address>
</tt:Address>
<tt:Port>8080</tt:Port>
<tt:TTL>30</tt:TTL>
<tt:AutoStart>false</tt:AutoStart>
</tt:Multicast>
<tt:SessionTimeout>PT00H00M30S</tt:SessionTimeout>
</tt:AudioEncoderConfiguration>
</trt:Profiles>
<trt:Profiles token="jpeg_ulaw_1920x1080" fixed="true">
<!-- -->
</trt:Profiles>
<trt:Profiles token="h264_opus_1920x1080" fixed="true">
<!-- -->
</trt:Profiles>
<trt:Profiles token="jpeg_opus_1920x1080" fixed="true">
<!-- -->
</trt:Profiles>
<!-- -->
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Also dasProfile abrufenAntwort enthält eine Reihe von Profiles
Elementen. Bemerkenswert ist der token
Attributwert jedes Profiles
Elements, z. B. <Profiles token="h264_ulaw_1920x1080" fixed="true">
. Diese Token können für nachfolgende Abfragen verwendet werden, indem derGetStreamUriBefehl:
curl -X POST http://192.168.178.22:8080/onvif/device_service\
-H 'Content-Type: application/soap+xml; charset=utf-8'\
-H 'SOAPAction: "http://www.onvif.org/ver10/media/wsdl/GetStreamUri"'\
-d '
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsdl="http://www.onvif.org/ver10/media/wsdl"
>
<soap:Header/>
<soap:Body>
<wsdl:GetStreamUri>
<wsdl:ProfileToken>h264_ulaw_1920x1080</wsdl:ProfileToken>
</wsdl:GetStreamUri>
</soap:Body>
</soap:Envelope>
' | xmllint --format -
... worauf mein Gerät antwortet (abgekürzt):
<SOAP-ENV:Envelope ...>
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<trt:GetStreamUriResponse>
<trt:MediaUri>
<tt:Uri>rtsp://192.168.178.22:8080/h264_ulaw.sdp</tt:Uri>
<tt:InvalidAfterConnect>false</tt:InvalidAfterConnect>
<tt:InvalidAfterReboot>false</tt:InvalidAfterReboot>
<tt:Timeout xsi:nil="true"/>
</trt:MediaUri>
</trt:GetStreamUriResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Und da haben wir es: Die URL des Videostreams ist im <Uri>
Element enthalten: rtsp://192.168.178.22:8080/h264_ulaw.sdp
.
(Übersicht über die Spezifikationen der ONVIF-Netzwerkschnittstelle)