RTSP 摄像头子码流 url

问题描述 投票:0回答:1

我想获取任何给定摄像机的辅助流的

rtsp
路径。相机型号不同,制造商也不同。

我尝试使用

ONVIF
来实现此目的,但它只提供了主流的
rtsp
路径。我需要一些东西来获取辅助流。

有什么可能的方法来实现这一目标吗?任何

python
图书馆可以提供帮助或其他任何东西?

python camera rtsp onvif python-onvif
1个回答
0
投票
import onvif

def main():
    try:
        mycam = onvif.ONVIFCamera('192.168.29.194', 80, 'admin', 'admin123')
        device_info = mycam.devicemgmt.GetDeviceInformation()
        print("Manufacturer:", device_info.Manufacturer)
        print("Model:", device_info.Model)
        print("Firmware Version:", device_info.FirmwareVersion)

        media = mycam.create_media_service()
        profiles = media.GetProfiles()
        if not profiles:
            print("No media profiles found.")
            return

        """To fetch URI of primary stream"""
        media_profile_1 = profiles[0]
        profile_token_1 = media_profile_1.token  # Extracting the token from the media profile

        stream_uri_1 = media.GetStreamUri(
            {'StreamSetup': {'Stream': 'RTP-Unicast', 'Transport': {'Protocol': 'RTSP'}},
             'ProfileToken': profile_token_1}
        )

        video_stream_uri_1 = stream_uri_1.Uri
        print("Video Stream URI of primary stream:", video_stream_uri_1)

        """To fetch URI of secondary stream"""
        media_profile_2 = profiles[1]
        profile_token_2 = media_profile_2.token  # Extracting the token from the media profile

        stream_uri_2 = media.GetStreamUri(
            {'StreamSetup': {'Stream': 'RTP-Unicast', 'Transport': {'Protocol': 'RTSP'}},
             'ProfileToken': profile_token_2}
        )

        video_stream_uri_2 = stream_uri_2.Uri
        print("Video Stream URI of secondary stream:", video_stream_uri_2)

    except onvif.exceptions.ONVIFError as e:
        print(f"ONVIFError: {e}")

if __name__ == "__main__":
    main()
© www.soinside.com 2019 - 2024. All rights reserved.