-
-
Save polatengin/900323a9f1ec20fdbf8467c2d0e0a652 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows 10 UWP uygulamasında MediaEditing ile resimlerden video oluşturmak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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