Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async Task TranscodeAsync(StorageFile source)
- {
- var destination = await ApplicationData.Current.LocalFolder.CreateFileAsync("temp.step2.mp4", CreationCollisionOption.ReplaceExisting);
- var encodingProfile = await MediaEncodingProfile.CreateFromFileAsync(source);
- var effect1 = await CreateEffectDefinitionAsync(encodingProfile.Video, 0);
- var transcoder = new MediaTranscoder();
- transcoder.AddVideoEffect(effect1.ActivatableClassId, true, effect1.Properties);
- var profile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Vga);
- profile.Video.Width = 480;
- profile.Video.Height = 480;
- var prepare = await transcoder.PrepareFileTranscodeAsync(source, destination, profile);
- var transcode = prepare.TranscodeAsync();
- transcode.Progress += new AsyncActionProgressHandler<double>(TranscodeProgress);
- await transcode;
- }
- private async Task<IVideoEffectDefinition> CreateEffectDefinitionAsync(VideoEncodingProperties props, int index)
- {
- var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/croppedmark.png"));
- var stream = await file.OpenReadAsync();
- var bd = await BitmapDecoder.CreateAsync(stream);
- var pd = await bd.GetPixelDataAsync();
- var tempBuffer = pd.DetachPixelData();
- var definition1 = new WatermarkEffectDefinition(tempBuffer.AsBuffer());
- definition1.InputHeight = 640;
- definition1.InputWidth = 480;
- definition1.OutputHeight = 480;
- definition1.OutputWidth = 480;
- return definition1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement