Beispiel #1
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;

            await _capture.InitializeAsync(new MediaCaptureInitializationSettings
            {
                VideoDeviceId        = await GetBackOrDefaulCameraIdAsync(),
                StreamingCaptureMode = StreamingCaptureMode.Video
            });

            IBuffer shaderY = await PathIO.ReadBufferAsync("ms-appx:///Invert_093_NV12_Y.cso");

            IBuffer shaderUV = await PathIO.ReadBufferAsync("ms-appx:///Invert_093_NV12_UV.cso");

            var definition = new VideoEffects.ShaderEffectDefinitionNv12(shaderY, shaderUV);

            await _capture.AddEffectAsync(MediaStreamType.VideoRecord, definition.ActivatableClassId, definition.Properties);

            Preview.Source = _capture;
            await _capture.StartPreviewAsync();

            var previewProps = (VideoEncodingProperties)_capture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview);

            TextLog.Text += String.Format("Preview: {0} {1}x{2} {3}fps\n", previewProps.Subtype, previewProps.Width, previewProps.Height, previewProps.FrameRate.Numerator / (float)previewProps.FrameRate.Denominator);

            var recordProps = (VideoEncodingProperties)_capture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoRecord);

            TextLog.Text += String.Format("Record: {0} {1}x{2} {3}fps\n", recordProps.Subtype, recordProps.Width, recordProps.Height, recordProps.FrameRate.Numerator / (float)recordProps.FrameRate.Denominator);

            StorageFile file = await KnownFolders.VideosLibrary.CreateFileAsync("VideoEffectRecordCaptureTestApp.mp4", CreationCollisionOption.ReplaceExisting);

            var profile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);

            profile.Audio = null;

            TextLog.Text += "Starting record\n";
            await _capture.StartRecordToStorageFileAsync(profile, file);

            TextLog.Text += "Record started to" + file.Path + "\n";

            for (int i = 0; i < 10; i++)
            {
                await Task.Delay(1000);

                TextLog.Text += i + "s\n";
            }

            TextLog.Text += "Stopping record\n";
            await _capture.StopRecordAsync();

            TextLog.Text += "Record stopped\n";
        }
Beispiel #2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;

            await _capture.InitializeAsync(new MediaCaptureInitializationSettings
            {
                VideoDeviceId = await GetBackOrDefaulCameraIdAsync(),
                StreamingCaptureMode = StreamingCaptureMode.Video
            });

            IBuffer shaderY = await PathIO.ReadBufferAsync("ms-appx:///Invert_093_NV12_Y.cso");
            IBuffer shaderUV = await PathIO.ReadBufferAsync("ms-appx:///Invert_093_NV12_UV.cso");
            var definition = new VideoEffects.ShaderEffectDefinitionNv12(shaderY, shaderUV);

            await _capture.AddEffectAsync(MediaStreamType.VideoRecord, definition.ActivatableClassId, definition.Properties);

            Preview.Source = _capture;
            await _capture.StartPreviewAsync();

            var previewProps = (VideoEncodingProperties)_capture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview);
            TextLog.Text += String.Format("Preview: {0} {1}x{2} {3}fps\n", previewProps.Subtype, previewProps.Width, previewProps.Height, previewProps.FrameRate.Numerator / (float)previewProps.FrameRate.Denominator);

            var recordProps = (VideoEncodingProperties)_capture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoRecord);
            TextLog.Text += String.Format("Record: {0} {1}x{2} {3}fps\n", recordProps.Subtype, recordProps.Width, recordProps.Height, recordProps.FrameRate.Numerator / (float)recordProps.FrameRate.Denominator);

            StorageFile file = await KnownFolders.VideosLibrary.CreateFileAsync("VideoEffectRecordCaptureTestApp.mp4", CreationCollisionOption.ReplaceExisting);
            var profile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);
            profile.Audio = null;

            TextLog.Text += "Starting record\n";
            await _capture.StartRecordToStorageFileAsync(profile, file);
            TextLog.Text += "Record started to" + file.Path + "\n";

            for (int i = 0; i < 10; i++)
            {
                await Task.Delay(1000);
                TextLog.Text += i + "s\n";
            }

            TextLog.Text += "Stopping record\n";
            await _capture.StopRecordAsync();
            TextLog.Text += "Record stopped\n";
        }