mirror of
https://github.com/wagesj45/butterflow-ui.git
synced 2024-11-14 05:43:33 -06:00
Processing Videos
Can now actually process a video. Needs some safety checks to make sure the user doesn't select something that causes it to go haywire.
This commit is contained in:
parent
3af7fd2b2c
commit
da04af543b
7 changed files with 124 additions and 26 deletions
|
@ -77,11 +77,14 @@ namespace butterflow_ui
|
|||
process.StartInfo.CreateNoWindow = true;
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.RedirectStandardError = true;
|
||||
process.EnableRaisingEvents = true;
|
||||
process.OutputDataReceived += Process_OutputDataReceived; ;
|
||||
process.OutputDataReceived += Process_OutputDataReceived;
|
||||
process.ErrorDataReceived += Process_OutputDataReceived;
|
||||
|
||||
process.Start();
|
||||
process.BeginOutputReadLine();
|
||||
process.BeginErrorReadLine();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -148,4 +148,13 @@
|
|||
</Path>
|
||||
</Viewbox>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="RadarIcon">
|
||||
<Viewbox>
|
||||
<Path Fill="#000000">
|
||||
<Path.Data>
|
||||
<PathGeometry Figures="M12 0c6.623 0 12 5.377 12 12s-5.377 12-12 12-12-5.377-12-12 5.377-12 12-12zm6.363 18.363c-1.629 1.629-3.879 2.637-6.363 2.637-4.967 0-9-4.033-9-9 0-4.28 2.994-7.866 7-8.777v1.029c-3.449.889-6 4.023-6 7.748 0 4.415 3.585 8 8 8 2.208 0 4.208-.896 5.656-2.344l.707.707zm-2.475-2.475c-.995.996-2.37 1.612-3.888 1.612-3.036 0-5.5-2.464-5.5-5.5 0-2.33 1.452-4.324 3.5-5.124v1.092c-1.481.737-2.5 2.267-2.5 4.032 0 2.484 2.016 4.5 4.5 4.5 1.242 0 2.367-.504 3.181-1.319l.707.707zm-4.888-5.62v-7.268c0-.265.105-.52.293-.707.187-.188.442-.293.707-.293.265 0 .52.105.707.293.188.187.293.442.293.707v7.268c.598.346 1 .992 1 1.732 0 1.104-.896 2-2 2s-2-.896-2-2c0-.74.402-1.386 1-1.732z" FillRule="EvenOdd"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Viewbox>
|
||||
</ControlTemplate>
|
||||
</ResourceDictionary>
|
27
butterflow-ui/Localization/Localization.Designer.cs
generated
27
butterflow-ui/Localization/Localization.Designer.cs
generated
|
@ -249,6 +249,15 @@ namespace butterflow_ui.Localization {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Output.
|
||||
/// </summary>
|
||||
public static string FileOutputGroupBox {
|
||||
get {
|
||||
return ResourceManager.GetString("FileOutputGroupBox", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Flow Filter.
|
||||
/// </summary>
|
||||
|
@ -420,6 +429,24 @@ namespace butterflow_ui.Localization {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Process.
|
||||
/// </summary>
|
||||
public static string ProcessLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("ProcessLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Process the video. This may be a long process..
|
||||
/// </summary>
|
||||
public static string ProcessTooltip {
|
||||
get {
|
||||
return ResourceManager.GetString("ProcessTooltip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Pyramid Scale Factor.
|
||||
/// </summary>
|
||||
|
|
|
@ -240,6 +240,9 @@
|
|||
<data name="FastPyramidsTooltip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="FileOutputGroupBox" xml:space="preserve">
|
||||
<value>Output</value>
|
||||
</data>
|
||||
<data name="FlowFilterLabel" xml:space="preserve">
|
||||
<value>Flow Filter</value>
|
||||
</data>
|
||||
|
@ -270,6 +273,12 @@
|
|||
<data name="PixelNeighborhoodTooltip" xml:space="preserve">
|
||||
<value>Size of the pixel neighborhood.</value>
|
||||
</data>
|
||||
<data name="ProcessLabel" xml:space="preserve">
|
||||
<value>Process</value>
|
||||
</data>
|
||||
<data name="ProcessTooltip" xml:space="preserve">
|
||||
<value>Process the video. This may be a long process.</value>
|
||||
</data>
|
||||
<data name="PyramidScaleLabel" xml:space="preserve">
|
||||
<value>Pyramid Scale Factor</value>
|
||||
</data>
|
||||
|
|
|
@ -71,12 +71,13 @@
|
|||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.5*" />
|
||||
<ColumnDefinition Width="0.5*"/>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<GroupBox Grid.ColumnSpan="4" Grid.Row="0" Header="{x:Static loc:Localization.FileInputGroupBox}">
|
||||
<StackPanel Grid.ColumnSpan="3" Grid.Row="0">
|
||||
<GroupBox Header="{x:Static loc:Localization.FileInputGroupBox}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
|
@ -88,6 +89,25 @@
|
|||
<Button Grid.Column="2" MinWidth="25" Name="btnFilePicker" Click="btnFilePicker_Click">...</Button>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Header="{x:Static loc:Localization.FileOutputGroupBox}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0" Content="{x:Static loc:Localization.FileLabel}"/>
|
||||
<TextBox Name="txtFileOutputName" Grid.Column="1" IsReadOnly="True" Text="{Binding OptionsConfiguration.VideoOutput, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
<Button Grid.Column="2" MinWidth="25" Name="btnFileOutputPicker" Click="btnFileOutputPicker_Click">...</Button>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</StackPanel>
|
||||
<Button Grid.Column="4" Grid.Row="0" Name="btnProcess" ToolTip="{x:Static loc:Localization.ProcessTooltip}" Click="btnProcess_Click">
|
||||
<StackPanel>
|
||||
<ContentControl MaxWidth="32" HorizontalAlignment="Center" Name="btnRun" Template="{StaticResource RadarIcon}" />
|
||||
<Label Content="{x:Static loc:Localization.ProcessLabel}" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<GroupBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Header="{x:Static loc:Localization.CommonOptionsGroupBox}">
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
|
@ -115,7 +135,7 @@
|
|||
<RadioButton GroupName="PlaybackRate" Checked="PlaybackRateRadioButton_Checked" Content="{x:Static loc:Localization._120fpsLabel}" Tag="120" />
|
||||
</butterflow_ui:ButterflowOption>
|
||||
<butterflow_ui:ButterflowOption LabelValue="{x:Static loc:Localization.CustomPlaybackRateLabel}" DescriptionValue="{x:Static loc:Localization.PlaybackRateDescription}">
|
||||
<TextBox Text="{Binding OptionsConfiguration.PlaybackRate, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged}" GotFocus="TextBox_GotFocus" />
|
||||
<TextBox Name="txtPlaybackRate" Text="{Binding OptionsConfiguration.PlaybackRate, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged}" GotFocus="txtPlaybackRate_GotFocus" />
|
||||
</butterflow_ui:ButterflowOption>
|
||||
</StackPanel>
|
||||
</butterflow_ui:ButterflowOption>
|
||||
|
@ -288,7 +308,7 @@
|
|||
</ItemsPanelTemplate>
|
||||
</StatusBar.ItemsPanel>
|
||||
<StatusBarItem Grid.Column="0">
|
||||
<Button>
|
||||
<Button Name="btnCopyArguments" Click="btnCopyArguments_Click">
|
||||
<ContentControl Template="{StaticResource CopyIcon}" />
|
||||
</Button>
|
||||
</StatusBarItem>
|
||||
|
|
|
@ -113,16 +113,29 @@ namespace butterflow_ui
|
|||
{
|
||||
this.OptionsConfiguration.VideoInput = ofd.FileName;
|
||||
|
||||
//this.ButterflowWrapper.ConsoleOutputRecieved += (o, ce) => this.txtConsoleOutput.Text = ce.ConsoleOutput;
|
||||
this.ButterflowWrapper.Probe(ofd.FileName);
|
||||
|
||||
//Hack to get the first frame to display in the media preview element.
|
||||
//This also triggers the MediaOpened event so we can get the metadata from the element.
|
||||
mediaPreview.Play();
|
||||
mediaPreview.PausePlayback();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Event handler. Called by btnFileOutputPicker for click events. </summary>
|
||||
/// <param name="sender"> Source of the event. </param>
|
||||
/// <param name="e"> Routed event information. </param>
|
||||
private void btnFileOutputPicker_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var sfd = new SaveFileDialog();
|
||||
sfd.Filter = "MPEG 4|*.mp4";
|
||||
|
||||
var result = sfd.ShowDialog(this);
|
||||
if (result.HasValue && result.Value)
|
||||
{
|
||||
this.OptionsConfiguration.VideoOutput = sfd.FileName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Event handler. Called by PlaybackRate radio buttons for checked events. </summary>
|
||||
/// <param name="sender"> Source of the event. </param>
|
||||
/// <param name="e"> Routed event information. </param>
|
||||
|
@ -268,20 +281,36 @@ namespace butterflow_ui
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary> Event handler. Called by TextBox for got focus events. </summary>
|
||||
/// <summary> Event handler. Called by txtPlaybackRate for got focus events. </summary>
|
||||
/// <param name="sender"> Source of the event. </param>
|
||||
/// <param name="e"> Routed event information. </param>
|
||||
private void TextBox_GotFocus(object sender, RoutedEventArgs e)
|
||||
private void txtPlaybackRate_GotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//Clear all the radio buttons because we got focus from the user in the playbackrate textbox.
|
||||
var playbackRateRadioButtons = GetRecursiveChildren<RadioButton>(this.butterflowUIWindow);
|
||||
|
||||
foreach(var radioButton in playbackRateRadioButtons)
|
||||
foreach (var radioButton in playbackRateRadioButtons)
|
||||
{
|
||||
radioButton.IsChecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Event handler. Called by btnCopyArguments for click events. </summary>
|
||||
/// <param name="sender"> Source of the event. </param>
|
||||
/// <param name="e"> Routed event information. </param>
|
||||
private void btnCopyArguments_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Clipboard.SetText(this.OptionsConfiguration.CommandLineOutput);
|
||||
}
|
||||
|
||||
/// <summary> Event handler. Called by btnProcess for click events. </summary>
|
||||
/// <param name="sender"> Source of the event. </param>
|
||||
/// <param name="e"> Routed event information. </param>
|
||||
private void btnProcess_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.ButterflowWrapper.Run(this.OptionsConfiguration);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -450,8 +450,6 @@ namespace butterflow_ui
|
|||
if (this.KeepAudio) stringBuilder.Append("-audio ");
|
||||
if (this.LosslessQuality) stringBuilder.Append("-l ");
|
||||
|
||||
stringBuilder.AppendFormat("\"{0}\"", this.VideoInput);
|
||||
|
||||
if (this.Subregions.Any())
|
||||
{
|
||||
foreach (var anon in this.Subregions.Select((sr, index) => new { Index = index, Subregion = sr }))
|
||||
|
@ -487,6 +485,9 @@ namespace butterflow_ui
|
|||
if (this.pixelNeighborhood != DEFAULT_PIXEL_NEIGHBORHOOD) stringBuilder.AppendFormat("--poly-n {0} ", this.PixelNeighborhood);
|
||||
if (this.smoothDerivativeStandardDeviation != DEFAULT_SMOOTH_DERIVATIVE_STANDARD_DEVIATION) stringBuilder.AppendFormat("--poly-s {0} ", this.SmoothDerivativeStandardDeviation);
|
||||
if (this.FlowFilterType != DEFAULT_FLOW_FILTER_TYPE) stringBuilder.AppendFormat("-ff {0} ", this.FlowFilterType);
|
||||
if (!string.IsNullOrWhiteSpace(this.VideoOutput)) stringBuilder.AppendFormat("-o \"{0}\" ", this.VideoOutput);
|
||||
|
||||
stringBuilder.AppendFormat("\"{0}\"", this.VideoInput);
|
||||
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue