59 lines
2.1 KiB
Plaintext
59 lines
2.1 KiB
Plaintext
|
@page "/export"
|
||
|
@using System.IO
|
||
|
@using Timelapse.Api;
|
||
|
@using ElectronNET.API;
|
||
|
@using Timelapse.Data;
|
||
|
@using Xabe.FFmpeg;
|
||
|
@using Xabe.FFmpeg.Extensions;
|
||
|
@inject ExtensionProjectService EPS;
|
||
|
@inject NavigationManager NavigationManager
|
||
|
<h1>Export Project</h1>
|
||
|
@if(EPS.IsProjectLoaded)
|
||
|
{
|
||
|
<div>
|
||
|
<div class="input-group mb-3">
|
||
|
<input type="text" class="form-control" placeholder="Path to video file" aria-label="Path to Video File" aria-describedby="basic-addon2" @bind-value="VideoPath">
|
||
|
<div class="input-group-append">
|
||
|
<button class="btn btn-outline-secondary" type="button" @onclick="Browse">Browse</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
<button class="btn btn-primary" @onclick="Export">Export</button>
|
||
|
|
||
|
</div>
|
||
|
}else{
|
||
|
<h4>Please Load A Project</h4>
|
||
|
|
||
|
}
|
||
|
@code {
|
||
|
public string VideoPath {get;set;}
|
||
|
public async Task Browse()
|
||
|
{
|
||
|
string filename=await Electron.Dialog.ShowSaveDialogAsync(Electron.WindowManager.BrowserWindows.First(),new SaveDialogOptions() { Filters = new ElectronNET.API.Entities.FileFilter[] {new ElectronNET.API.Entities.FileFilter() {Name="MPEG-4 Video", Extensions=new string[] {"mp4"}}}});
|
||
|
if(!string.IsNullOrWhiteSpace(filename))
|
||
|
{
|
||
|
VideoPath=filename;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
// public int Progress {get;set;}
|
||
|
public async Task Export()
|
||
|
{
|
||
|
|
||
|
int count=1;
|
||
|
|
||
|
while(File.Exists(
|
||
|
Path.Combine(EPS.ProjectDirectory,"Sections",EPS.Project.CurrentSection,$"{count}.png")
|
||
|
))
|
||
|
{
|
||
|
count++;
|
||
|
}
|
||
|
count--;
|
||
|
var cmd=FFmpeg.Conversions.New().BuildVideoFromImages(Enumerable.Range(1,count).Select<int,string>(e=>Path.Combine(EPS.ProjectDirectory,"Sections",EPS.Project.CurrentSection,$"{e}.png"))).SetFrameRate(20).SetPixelFormat(PixelFormat.yuv420p).SetOutput(VideoPath);
|
||
|
|
||
|
await cmd.Start();
|
||
|
Electron.Notification.Show(new ElectronNET.API.Entities.NotificationOptions("TimelapseNow","Video Export Complete"));
|
||
|
await Electron.Dialog.ShowMessageBoxAsync("Export Complete");
|
||
|
}
|
||
|
|
||
|
}
|