public async Task <bool> StartRecordingAsync() { if (Initialized && PreviewStarted && !RecordingStarted) { #if WINDOWS_PHONE_APP MediaEncodingProfile recordProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.HD720p); recordProfile.Video.FrameRate.Numerator = _hfrVideoEncodingProperties.FrameRate.Numerator; recordProfile.Video.FrameRate.Denominator = _hfrVideoEncodingProperties.FrameRate.Denominator; double factor = (double)(recordProfile.Video.FrameRate.Numerator) / (recordProfile.Video.FrameRate.Denominator * 4); recordProfile.Video.Bitrate = (uint)(recordProfile.Video.Width * recordProfile.Video.Height * factor); await MediaCapture.StartRecordToStreamAsync(recordProfile, _recordingStream); #else MediaEncodingProfile recordProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto); await MediaCapture.StartRecordToStreamAsync(recordProfile, _recordingStream); #endif // Get camera's resolution VideoEncodingProperties resolution = (VideoEncodingProperties)_videoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoRecord); ResolutionWidth = (int)resolution.Width; ResolutionHeight = (int)resolution.Height; Messenger.SettingsChangedFlag = true; await MediaCapture.AddEffectAsync(RecordMediaStreamType, BufferTransformActivationId, Properties); RecordingStarted = true; } return(RecordingStarted); }
private async void InitializeFacialRecognition() { if (m_faceTracker == null) { m_faceTracker = await FaceTracker.CreateAsync(); } m_mediaCapture = new MediaCapture(); MediaCaptureInitializationSettings settings = new MediaCaptureInitializationSettings(); settings.StreamingCaptureMode = StreamingCaptureMode.Video; await m_mediaCapture.InitializeAsync(settings); VideoDeviceController deviceController = m_mediaCapture.VideoDeviceController; m_videoProperties = deviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) as VideoEncodingProperties; await m_mediaCapture.StartPreviewAsync(); TimeSpan timerInterval = TimeSpan.FromMilliseconds(66); m_frameProcessingTimer = ThreadPoolTimer.CreatePeriodicTimer(new TimerElapsedHandler(ProcessCurrentVideoFrame), timerInterval); }