Windows Phone 8.1 MediaComposition - Sound too fast when stitching video

I had a problem trying to merge several videos together. Whenever I combine 2 or more videos, the sound plays at double speed, while the video plays normally.

Below is the code. Did I miss something?

I get the same results when testing, but clone a single video or select multiple videos.

I compared with the sample code here (I don't crop).

public static IAsyncOperation<IStorageFile> ConcatenateVideoRT([ReadOnlyArray]IStorageFile[] videoFiles, IStorageFolder outputFolder, string outputfileName) { return Task.Run<IStorageFile>(async () => { IStorageFile _OutputFile = await outputFolder.CreateFileAsync(outputfileName, CreationCollisionOption.GenerateUniqueName); MediaComposition _MediaComposition = new MediaComposition(); foreach (IStorageFile _VideoFile in videoFiles) { MediaClip _MediaClip = await MediaClip.CreateFromFileAsync(_VideoFile); _MediaComposition.Clips.Add(_MediaClip); _MediaComposition.Clips.Add(_MediaClip.Clone()); } TranscodeFailureReason _TranscodeFailureReason = await _MediaComposition.RenderToFileAsync(_OutputFile); if (_TranscodeFailureReason != TranscodeFailureReason.None) { throw new Exception("Video Concatenation Failed: " + _TranscodeFailureReason.ToString()); } return _OutputFile; }).AsAsyncOperation(); } 
+5
source share
1 answer

There seem to be two questions. I got this working by adding the following line:

 MediaEncodingProfile _MediaEncodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Vga); 

And changing the following line:

 TranscodeFailureReason _TranscodeFailureReason = await _MediaComposition.RenderToFileAsync(_OutputFile); 

To:

 TranscodeFailureReason _TranscodeFailureReason = await _MediaComposition.RenderToFileAsync(_OutputFile, MediaTrimmingPreference.Fast, _MediaEncodingProfile); 

The problem is that RenderToFileAsync does not work properly when using VideoEncodingQuality.HD720p or VideoEncodingQuality.HD1080p, both of these recreate a quick sound problem. Also, using VideoEncodingQuality.Auto seems to cause the encoding to fail (although I think it is designed to use the default settings from the camera).

In addition, I posted this issue on the Microsoft Partner Community forums, and their answer was that encoding may be interrupted on certain devices, for example. in its tests, the video recorded on the Lumia 638 cannot be encoded / concatenated even on other devices, but the video from HTC 8x, Lumia 920 and Lumia 930 can be encoded on all devices even 638.

They suggested that the device problem (firmware) was not a Windows.Media.Editing API problem.

+3
source

Source: https://habr.com/ru/post/1214682/


All Articles