private async void AcceptButton_Click(object sender, RoutedEventArgs e) { Pause(); progressText.Text = "0"; progressText.Visibility = Visibility.Visible; completedText.Visibility = Visibility.Collapsed; overlayGrid.Visibility = Visibility.Visible; OpenProcessingOverlay.Begin(); var props = await(_model.StorageFile as StorageFile).Properties.GetVideoPropertiesAsync(); var profile = MediaTranscoding.CreateVideoEncodingProfileFromProps(true, props); if (_tempFile == null) { _tempFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(Path.ChangeExtension(_model.StorageFile.Name, ".mp4"), CreationCollisionOption.GenerateUniqueName); } await SaveComposition(); _renderTask = _model.Composition.RenderToFileAsync(_tempFile, MediaTrimmingPreference.Precise, profile); _renderTask.Progress = OnProgress; _renderTask.Completed = OnCompleted; }
private async void AcceptButton_Click(object sender, RoutedEventArgs e) { Pause(); progressText.Text = "0"; progressText.Visibility = Visibility.Visible; completedText.Visibility = Visibility.Collapsed; overlayGrid.Visibility = Visibility.Visible; OpenProcessingOverlay.Begin(); Analytics.TrackEvent("VideoEditor_ExportStarted"); await SaveComposition(); var transcoder = new MediaTranscoder() { VideoProcessingAlgorithm = App.RoamingSettings.Read(Constants.VIDEO_PROCESSING, MediaVideoProcessingAlgorithm.Default) }; var props = await(_model.StorageFile as StorageFile).Properties.GetVideoPropertiesAsync(); var profile = MediaTranscoding.CreateVideoEncodingProfileFromProps(props); var source = _model.Composition.GenerateMediaStreamSource(); if (_tempFile == null) { _tempFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(Path.ChangeExtension(_model.StorageFile.Name, ".mp4"), CreationCollisionOption.GenerateUniqueName); } if (_tempStream != null) { _tempStream.Dispose(); } _tempStream = await _tempFile.OpenAsync(FileAccessMode.ReadWrite); var result = await transcoder.PrepareMediaStreamSourceTranscodeAsync(source, _tempStream, profile); if (!result.CanTranscode) { await UIUtilities.ShowErrorDialogAsync("Unable to Transcode!", $"Returned {result.FailureReason}"); return; } _renderTask = result.TranscodeAsync(); _renderTask.Progress = OnProgress; _renderTask.Completed += OnCompleted; }