title: Using Uri connected IP camera to take pictures and record video with Windows UWP app
body: <p>Connecting directly IP cameras is a new UWP feature. On this page: <a href="https://blogs.windows.com/windowsdeveloper/2019/10/10/connecting-network-cameras-to-windows-10-devices/" rel="nofollow noreferrer">https://blogs.windows.com/windowsdeveloper/2019/10/10/connecting-network-cameras-to-windows-10-devices/</a></p>
  <p>It says:
  &quot;For streaming from a URI through the MediaCapture class, assign the desired URI to MediaCaptureInitializationSettings::DeviceUri. If credentials are required, they can be set through MediaCaptureInitializationSettings::DeviceUriPasswordCredential. The API supports ONVIF and generic RTSP server URIs. This allows applications to use the standard Windows Media APIs to capture video from generic cameras that do not conform to the ONVIF standards, or from an arbitrary URI without pairing.&quot;</p>
  <p><strong>Update:</strong>
  Now I am able to connect to the camera successfully. The problem was with the format of the URI. I have Reolink-410 Camera</p>
  <pre><code>MediaCapture = new MediaCapture();
  MediaCaptureInitializationSettings captureInitSettings = new MediaCaptureInitializationSettings();
  captureInitSettings.DeviceUri = new 
     Uri(&quot;rtsp://admin:password@192.168.1.241:554//h264Preview_01_main&quot;);
  captureInitSettings.DeviceUriPasswordCredential = new Windows.Security.Credentials.PasswordCredential
                  {
                      UserName = &quot;admin&quot;,
                      Password = &quot;password&quot;
                  };
  MediaCapture.Failed += MediaCapture_Failed;
  MediaCapture.RecordLimitationExceeded += MediaCapture_RecordLimitationExceeded;
  
  await MediaCapture.InitializeAsync(captureInitSettings);
  </code></pre>
  <p>After this I can take pictures successfully</p>
  <pre><code>....
  await _app.VM.MediaCapture.CapturePhotoToStorageFileAsync(GetImageEncodingProperties(), file);
  </code></pre>
  <p>But When I try to record video it throws exception:
  {&quot;The specified object or value does not exist. (Exception from HRESULT: 0xC00D36D5)&quot;}</p>
  <pre><code>...
  var _mediaRecording = await _app.VM.MediaCapture.PrepareLowLagRecordToStorageFileAsync(MediaEncodingProfile.CreateHevc(VideoEncodingQuality.Auto), file);// Exception here {&quot;The specified object or value does not exist. (Exception from HRESULT: 0xC00D36D5)&quot;}
  //also tried with CreateMP4
  
  await _mediaRecording.StartAsync(); 
  
  </code></pre>
  <p>I also have tried <code>await _mediaRecording.StartAsync();</code> which throws same exception.
  {&quot;The specified object or value does not exist. (Exception from HRESULT: 0xC00D36D5)&quot;}</p>