Advertisement
FrayxRulez

Untitled

Apr 9th, 2017
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1.         private async Task TranscodeAsync(StorageFile source)
  2.         {
  3.             var destination = await ApplicationData.Current.LocalFolder.CreateFileAsync("temp.step2.mp4", CreationCollisionOption.ReplaceExisting);
  4.  
  5.             var encodingProfile = await MediaEncodingProfile.CreateFromFileAsync(source);
  6.  
  7.             var effect1 = await CreateEffectDefinitionAsync(encodingProfile.Video, 0);
  8.  
  9.             var transcoder = new MediaTranscoder();
  10.             transcoder.AddVideoEffect(effect1.ActivatableClassId, true, effect1.Properties);
  11.  
  12.             var profile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Vga);
  13.             profile.Video.Width = 480;
  14.             profile.Video.Height = 480;
  15.  
  16.             var prepare = await transcoder.PrepareFileTranscodeAsync(source, destination, profile);
  17.             var transcode = prepare.TranscodeAsync();
  18.  
  19.             transcode.Progress += new AsyncActionProgressHandler<double>(TranscodeProgress);
  20.  
  21.             await transcode;
  22.         }
  23.  
  24.         private async Task<IVideoEffectDefinition> CreateEffectDefinitionAsync(VideoEncodingProperties props, int index)
  25.         {
  26.             var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/croppedmark.png"));
  27.             var stream = await file.OpenReadAsync();
  28.             var bd = await BitmapDecoder.CreateAsync(stream);
  29.             var pd = await bd.GetPixelDataAsync();
  30.             var tempBuffer = pd.DetachPixelData();
  31.             var definition1 = new WatermarkEffectDefinition(tempBuffer.AsBuffer());
  32.             definition1.InputHeight = 640;
  33.             definition1.InputWidth = 480;
  34.             definition1.OutputHeight = 480;
  35.             definition1.OutputWidth = 480;
  36.             return definition1;
  37.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement