Skip to content

General Usage

This document will describe how to execute some of the most important commands used with the device service.

Execute GetStreamURI Command through EdgeX

Note

Make sure to replace Camera001 in all the commands below, with the proper deviceName.

  1. Get the profile token by executing the GetProfiles command:

    curl -s http://0.0.0.0:59882/api/v3/device/name/Camera001/MediaProfiles | jq -r '"profileToken: " + '.event.readings[].objectValue.Profiles[].Token''
    
    Example output:
    profileToken: profile_1
    profileToken: profile_2
    

  2. To get the RTSP URI from the ONVIF device, execute the GetStreamURI command, using a profileToken found in step 1:
    In this example, profile_1 is the profileToken:

    curl -s "http://0.0.0.0:59882/api/v3/device/name/Camera001/StreamUri?jsonObject=$(base64 -w 0 <<< '{
        "StreamSetup" : {
            "Stream" : "RTP-Unicast",
            "Transport" : {
            "Protocol" : "RTSP"
            }
        },
        "ProfileToken": "profile_1"
    }')" | jq -r '"streamURI: " + '.event.readings[].objectValue.MediaUri.Uri''
    
    Example output:
    streamURI: rtsp://192.168.86.34:554/stream1
    

  3. Stream the RTSP stream.

    Warning

    RTSP streams are insecure, as the credentials are included in plaintext. Always keep this in mind when streaming via RTSP.

    ffplay can be used to stream. The command follows this format:
    ffplay -rtsp_transport tcp "rtsp://<user>:<password>@<IP address>:<port>/<streamname>"
    
    Using the streamURI returned from the previous step, run ffplay:
    ffplay -rtsp_transport tcp "rtsp://admin:Password123@192.168.86.34:554/stream1"
    

    While the streamURI returned did not contain the username and password, those credentials are required in order to correctly authenticate the request and play the stream. Therefore, it is included in both the VLC and ffplay streaming examples.

    If the password uses special characters, you must use percent-encoding.

  4. To shut down ffplay, use the ctrl-c command.

To learn more about the API, see here

Troubleshooting Guide

Axis camera authentication failure

If while using Axis cameras you face authentication failure it might help by disabling its replay attack protection. For doing so please refer to Axis-replay-attack-protection. For more info on this refer to Axis-onvif-stackoverflow.

License

Apache-2.0