在Windows Phone 8中以非标准大小录制(或录制后转换)视频

时间:2013-06-18 10:41:50

标签: c# windows-phone-8 windows-phone video-processing

我试图在Windows Phone 8中以特定分辨率捕获MP4视频(具体而言,480x480)。我知道我不能使用预设之外的尺寸,480x480不是预设。如何转换捕获的视频(例如640x480)并裁剪顶部和底部以使其成为480x480?欢迎使用任何免费或开源库(在Windows Phone上运行)。请不要回答“使用外部服务器”这样的答案,我需要一个设备上的解决方案。

1 个答案:

答案 0 :(得分:1)

使用Windows.Phone.Media.Capture API和AudioVideoCaptureDevice

AudioVideoCaptureDevice.OpenAsync的第二个参数 - 请参阅this link - 是分辨率。你可以使用AudioVideoCaptureDevice.GetAvailableCaptureResolutions(传感器)来获得分辨率

编辑:要设置自定义分辨率,请尝试AudioVideoCaptureDevice.SetCaptureResolutionAsync

编辑2:您可以尝试使用以下内容来转换录制的视频:(无法找到从soz到作者的代码!)

StorageFolder isoStore = await ApplicationData.Current.LocalFolder.GetFolderAsync("Shared");
        var file = await isoStore.CreateFileAsync("foos1.wmv", CreationCollisionOption.ReplaceExisting);
        using (var s = await file.OpenAsync(FileAccessMode.ReadWrite))
        {
            Windows.Foundation.Size resolution = new Windows.Foundation.Size(640, 480);
            avDevice = await AudioVideoCaptureDevice.OpenAsync(CameraSensorLocation.Back,
                AudioVideoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Back).Last());

            VideoBrush videoRecorderBrush = new VideoBrush();
            videoRecorderBrush.SetSource(avDevice);

            viewfinderRectangle.Fill = videoRecorderBrush;

            await avDevice.StartRecordingToStreamAsync(s);

            Thread.Sleep(30000);

            await avDevice.StopRecordingAsync();
        }


        new MediaPlayerLauncher()
        {
            Media = new Uri(file.Path, UriKind.Relative),
        }.Show();