Skip to content

Instantly share code, notes, and snippets.

@polatengin
Created July 26, 2017 08:33
Show Gist options
  • Save polatengin/900323a9f1ec20fdbf8467c2d0e0a652 to your computer and use it in GitHub Desktop.
Save polatengin/900323a9f1ec20fdbf8467c2d0e0a652 to your computer and use it in GitHub Desktop.
Windows 10 UWP uygulamasında MediaEditing ile resimlerden video oluşturmak
<Page
x:Class="CreatingVideoFromImages.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CreatingVideoFromImages">
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button Content="Video Oluştur" Click="Button_Click" />
<MediaElement x:Name="player" Width="1024" Height="768" />
</StackPanel>
</Page>
private async void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
var composition = new MediaComposition();
var folderPhotos = await Package.Current.InstalledLocation.GetFolderAsync("Assets\\Photos");
foreach (var file in await folderPhotos.GetFilesAsync())
{
var clip = await MediaClip.CreateFromImageFileAsync(file, TimeSpan.FromMilliseconds(3500));
composition.Clips.Add(clip);
}
var folderSounds = await Package.Current.InstalledLocation.GetFolderAsync("Assets\\Sounds");
foreach (var file in await folderSounds.GetFilesAsync())
{
var track = await BackgroundAudioTrack.CreateFromFileAsync(file);
composition.BackgroundAudioTracks.Add(track);
}
var renderFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("video.mp4", CreationCollisionOption.GenerateUniqueName);
await composition.RenderToFileAsync(renderFile);
player.SetSource(await renderFile.OpenReadAsync(), renderFile.ContentType);
player.Play();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment