Esempio n. 1
0
        private async void TryToUseFFmpegURI()
        {
            try
            {
                // Set FFmpeg specific options. List of options can be found in https://www.ffmpeg.org/ffmpeg-protocols.html

                // Below are some sample options that you can set to configure RTSP streaming
                // Config.FFmpegOptions.Add("rtsp_flags", "prefer_tcp");
                // Config.FFmpegOptions.Add("stimeout", 100000);

                // Instantiate FFmpegInteropMSS using the URI
                VideoBox.Stop();
                ffmpegMss = await FFmpegInteropMSS.CreateFromUriAsync(inputURI);

                var source = ffmpegMss.CreateMediaPlaybackItem();

                // Pass MediaStreamSource to Media Element
                VideoBox.SetPlaybackSource(source);
            }
            catch (Exception ex)
            {
                ShowDialog.DisplayErrorMessage(ex.Message);
            }


            //try
            //{
            //    // Set FFmpeg specific options. List of options can be found in https://www.ffmpeg.org/ffmpeg-protocols.html
            //    PropertySet options = new PropertySet();

            //    // Below are some sample options that you can set to configure RTSP streaming
            //    // options.Add("rtsp_flags", "prefer_tcp");
            //    // options.Add("stimeout", 100000);

            //    // Instantiate FFmpegInteropMSS using the URI
            //    ffmpegMss = await FFmpegInteropMSS.CreateFromUriAsync(inputURI);
            //    if (ffmpegMss != null)
            //    {
            //        MediaStreamSource mss = ffmpegMss.GetMediaStreamSource();

            //        if (mss != null)
            //        {
            //            // Pass MediaStreamSource to Media Element
            //            VideoBox.Source = MediaSource.CreateFromMediaStreamSource(mss);
            //        }
            //        else
            //        {
            //            ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen);
            //        }
            //    }
            //    else
            //    {
            //        ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen);
            //    }
            //}
            //catch (Exception ex)
            //{
            //    ShowDialog.DisplayErrorMessage(ex.Message);
            //}
        }
Esempio n. 2
0
        private async void TryToUseFFmpegLocal()
        {
            if (inputFile != null)
            {
                VideoBox.Stop();

                // Open StorageFile as IRandomAccessStream to be passed to FFmpegInteropMSS
                IRandomAccessStream readStream = await inputFile.OpenAsync(FileAccessMode.Read);

                try
                {
                    // Instantiate FFmpegInteropMSS using the opened local file stream
                    ffmpegMss = await FFmpegInteropMSS.CreateFromStreamAsync(readStream);

                    if (ffmpegMss != null)
                    {
                        playbackItem = ffmpegMss.CreateMediaPlaybackItem();

                        // Pass MediaStreamSource to Media Element
                        VideoBox.SetPlaybackSource(playbackItem);
                    }
                    else
                    {
                        ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen);
                    }
                }
                catch (Exception ex)
                {
                    ShowDialog.DisplayErrorMessage(ex.Message);
                }
            }

            //try
            //{
            //    IRandomAccessStream readStream = await inputFile.OpenAsync(FileAccessMode.Read);

            //    ffmpegMss = await FFmpegInteropMSS.CreateFromStreamAsync(readStream);

            //    if (ffmpegMss != null)
            //    {
            //        MediaStreamSource mss = ffmpegMss.GetMediaStreamSource();

            //        if (mss != null)
            //        {
            //            mss.BufferTime = TimeSpan.Zero;
            //            sender.Source = MediaSource.CreateFromMediaStreamSource(mss);
            //            sender.RealTimePlayback = true;
            //            sender.Play();
            //        }
            //        else
            //        {
            //            ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen);
            //        }
            //    }
            //    else
            //    {
            //        ShowDialog.DisplayErrorMessage(ErrorInfo.CannotOpen);
            //    }
            //}
            //catch (Exception ex)
            //{
            //    ShowDialog.DisplayErrorMessage(ex.Message);
            //}
        }