How to set properties of C#.NET Windows.Media.Core.VideoStabilizationEffect class

My question is this: If I’m transcoding a video using Windows.Media.Transcoding.MediaTranscoder (rather than capturing with Windows.Media.Capture.MediaCapture) and wish to add a video stabilization effect, how do I set the properties of the Windows.Media.Core.VideoStabilizationEffect object?

According to some Microsoft documentation (detailed here: Effects for video capture), because of the cropping done during video stabilization, it is desirable to set some properties that will ensure that the resulting output appears with the same apparent quality as the original. The link given above details how to set these properties, but only if capturing video, rather than transcoding.

Looking at the MSDN page for the VideoStabilizationEffect class, I’m instructed to create an instance of VideoStabilizationEffectDefinition, and then get an instance of VideoStabilizationEffect by passing that to MediaCapture.AddVideoEffectAsync or MediaTranscoder.AddVideoEffect. However, that is incorrect. You cannot obtain an instance of VideoStabilizationEffect by calling MediaTranscoder.AddVideoEffect, because all signatures for that method (there are 2) return void. I’m sure that internally, MediaTranscoder has an instance of VideoStabilizationEffect, but it does not appear to be exposed.

Here’s a small working example of my code:

        private async void MyButton_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker picker = new()
            {
                SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
                FileTypeFilter = { ".avi" }
            };

            picker.ViewMode = PickerViewMode.List;
            nint windowHandle = WindowNative.GetWindowHandle(this);
            InitializeWithWindow.Initialize(picker, windowHandle);

            StorageFile file = await picker.PickSingleFileAsync();

            FileSavePicker savePicker = new()
            {
                SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
                DefaultFileExtension = ".avi",
                SuggestedFileName = "NewVideo"
            };

            savePicker.FileTypeChoices.Add("AVI", new string[] { ".avi" });
            InitializeWithWindow.Initialize(savePicker, windowHandle);

            StorageFile destination = await savePicker.PickSaveFileAsync();

            MediaEncodingProfile profile = MediaEncodingProfile.CreateAvi(VideoEncodingQuality.Auto);

            VideoStabilizationEffectDefinition vidStabDef = new();

            MediaTranscoder transcoder = new MediaTranscoder();

            transcoder.AddVideoEffect(vidStabDef.ActivatableClassId);
            
            PrepareTranscodeResult prepareOp = await transcoder.PrepareFileTranscodeAsync(file, destination, profile);

            if (prepareOp.CanTranscode)
            {
                var transcodeOp = prepareOp.TranscodeAsync();

                transcodeOp.Progress += new AsyncActionProgressHandler<double>(TranscodeProgress);
                transcodeOp.Completed += new AsyncActionWithProgressCompletedHandler<double>(TranscodeComplete);
            }
        }

        public void TranscodeProgress(IAsyncActionWithProgress<double> asyncInfo, double percent)
        {

        }

        void TranscodeComplete(IAsyncActionWithProgress<double> asyncInfo, AsyncStatus status)
        {
            asyncInfo.GetResults();
            if (asyncInfo.Status == AsyncStatus.Completed)
            {
                // Display or handle complete info.
            }
            else if (asyncInfo.Status == AsyncStatus.Canceled)
            {
                // Display or handle cancel info.
            }
            else
            {
                // Display or handle error info.
            }
        }

The good news is that this works! The transcoding begins, it reports progress, it reports successful completion, and the resulting video is nicely stabilized. However, I can notice a very slight reduction in quality due to the zoom-in performed by the effect.

I’d like to be able to preconfigure the stabilization effect so that I have more control over the amount of cropping, etc. I’ll also note that the MSDN documention nowhere, as far as I can tell, details exactly what properties are available for this video effect.

So to summarize again: Does anyone know how I might configure the VideoStabilizationEffect before transcoding?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật