Use FFmpegInteropX for UWP apps
- In Visual Studio, clone the the FFmpegInteropX Git repository.
- Build the library. You may encounter missing NuGet package errors. If so, edit the FFmpegInteropX.vcxproj file to change the paths of the missing packages.
- Update NuGet package. They may produce more missing package errors. Change NuGet paths in relevant files accordingly.
- Add FFmpegInteropX project as a reference to a UWP app project.
If you just want to use FmpegInteropX to stream an RTSP URL, it is straightforward:
//example of RTSP URL: rtsp://192.168.1.123/onvif-media/media.ampstring sStreamURL = StreamingUri.ToString().ToLower().Replace("http:", "rtsp:");if (string.IsNullOrEmpty(sUserName)){ //do nothing}else{ sStreamURL = sStreamURL.Replace("rtsp://", "rtsp://" + sUserName + ":" + sPassword + "@");}MyMediaPlayerElement.AutoPlay = true;FFmpegMediaSource _mediaSource = await FFmpegMediaSource.CreateFromUriAsync(sStreamURL);MyMediaPlayerElement.Source = _mediaSource.CreateMediaPlaybackItem();
The library does not have an option to handle credentials, so you have to embed them in the URL. You have little control over anything under the hood. If the library decides to stop streaming, you will be clueless.
If you have your own RTSP decoder to demux Annex-B H.26x NAL units, you can feed them to the library directly:
var config = new MediaSourceConfig();config.FFmpegOptions["loglevel"] = "debug";config.FFmpegOptions["debug"] = "true";FFmpegMediaSource ffmpegSource = await FFmpegMediaSource.CreateFromStreamAsync( new CircularStream(_circularBufferFFmpeg), config);MyMediaPlayerElement.Source = ffmpegSource.CreateMediaPlaybackItem();MyMediaPlayerElement.MediaPlayer.Play();
You have to create your own circular stream and circular buffer to do this. Again, if the library decides to stop streaming, you will be clueless.
FFmpegInteropX is not suitable for live streaming. It may be OK for playing video files.