当前位置: 首页>>代码示例>>C#>>正文


C# MediaCapture.StartRecordToStreamAsync方法代码示例

本文整理汇总了C#中Windows.Media.Capture.MediaCapture.StartRecordToStreamAsync方法的典型用法代码示例。如果您正苦于以下问题:C# MediaCapture.StartRecordToStreamAsync方法的具体用法?C# MediaCapture.StartRecordToStreamAsync怎么用?C# MediaCapture.StartRecordToStreamAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.Media.Capture.MediaCapture的用法示例。


在下文中一共展示了MediaCapture.StartRecordToStreamAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Grid_Loaded

        private async void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            var camera = (await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture)).FirstOrDefault();

            if (camera != null)
            {
                mediaCapture = new MediaCapture();
                var settings = new MediaCaptureInitializationSettings() { VideoDeviceId = camera.Id };
                await mediaCapture.InitializeAsync(settings);
                displayRequest.RequestActive();
                VideoPreview.Source = mediaCapture;
                await mediaCapture.StartPreviewAsync();

                memStream = new InMemoryRandomAccessStream();
                MediaEncodingProfile mediaEncodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);
                await mediaCapture.StartRecordToStreamAsync(mediaEncodingProfile, memStream);
            }
            //video = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Video);
            //if (video!=null)
            //{
            //    MediaClip mediaClip = await MediaClip.CreateFromFileAsync(video);
            //    mediaComposition.Clips.Add(mediaClip);
            //    mediaStreamSource = mediaComposition.GeneratePreviewMediaStreamSource(600, 600);
            //    VideoPreview.SetMediaStreamSource(mediaStreamSource);
            //}
            //FFMPEGHelper.RTMPEncoder encoder = new FFMPEGHelper.RTMPEncoder();
            //encoder.Initialize("rtmp://youtube.co");
        }
开发者ID:krishnan-unni,项目名称:FFMPEGHelper,代码行数:28,代码来源:VideoProcessing.xaml.cs

示例2: OnNavigatedTo

        protected override async void OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs e)
        {
            media = new MediaCapture();
            var captureInitSettings = new MediaCaptureInitializationSettings();
            captureInitSettings.StreamingCaptureMode = StreamingCaptureMode.Audio;
            await media.InitializeAsync(captureInitSettings);
            media.Failed += (_, ex) => new MessageDialog(ex.Message).ShowAsync();
            media.RecordLimitationExceeded += (_) => new MessageDialog("record limit exceeded").ShowAsync();

            var stream = new AudioAmplitudeStream();
            media.StartRecordToStreamAsync(MediaEncodingProfile.CreateWav(AudioEncodingQuality.Low), stream);
            stream.AmplitudeReading += stream_AmplitudeReading;

            base.OnNavigatedTo(e);
        }
开发者ID:richorama,项目名称:WinRTdB,代码行数:15,代码来源:MainPage.xaml.cs

示例3: PrintMicrophoneSample

        public void PrintMicrophoneSample()
        {
            MediaCapture capture;
            IRandomAccessStream stream;
            const int BufferSize = 64000;
            bool recording;
            float volume = 100;



            capture = new MediaCapture();

            stream = new InMemoryRandomAccessStream();
            var captureInitSettings2 = new MediaCaptureInitializationSettings();
            captureInitSettings2.StreamingCaptureMode = StreamingCaptureMode.Audio;
            capture.InitializeAsync(captureInitSettings2).AsTask().Wait();

            capture.AudioDeviceController.VolumePercent = volume;

            MediaEncodingProfile profile = new MediaEncodingProfile();

            AudioEncodingProperties audioProperties = AudioEncodingProperties.CreatePcm(16000, 1, 16);
            profile.Audio = audioProperties;
            profile.Video = null;
            profile.Container = new ContainerEncodingProperties() { Subtype = MediaEncodingSubtypes.Wave };

            capture.StartRecordToStreamAsync(profile, stream).GetResults();

            recording = true;

            // waste time
            for (int i = 0; i < 5; i++)
            {
                i = i * 232323 + 89;// WriteLine(i);
            }

            capture.StopRecordAsync().GetResults();

            byte[] wav = new byte[stream.Size];
            stream.Seek(0);
            stream.ReadAsync(wav.AsBuffer(), (uint)stream.Size, InputStreamOptions.None).GetResults();

            int sum = 0;
            for(int i = 0; i < wav.Count(); i++)
            {
                sum += (int) wav[i];
            }
            WriteLine((double) wav.Count() / sum);
        }
开发者ID:zidx,项目名称:lights,代码行数:49,代码来源:StartupTask.cs


注:本文中的Windows.Media.Capture.MediaCapture.StartRecordToStreamAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。