1
0
Fork 0
mirror of https://github.com/wagesj45/butterflow-ui.git synced 2024-12-22 09:12:42 -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:
Jordan Wages 2018-07-04 00:16:54 -05:00
parent 3af7fd2b2c
commit da04af543b
7 changed files with 124 additions and 26 deletions

View file

@ -77,11 +77,14 @@ namespace butterflow_ui
process.StartInfo.CreateNoWindow = true; process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false; process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.EnableRaisingEvents = true; process.EnableRaisingEvents = true;
process.OutputDataReceived += Process_OutputDataReceived; ; process.OutputDataReceived += Process_OutputDataReceived;
process.ErrorDataReceived += Process_OutputDataReceived;
process.Start(); process.Start();
process.BeginOutputReadLine(); process.BeginOutputReadLine();
process.BeginErrorReadLine();
} }
/// <summary> /// <summary>

View file

@ -148,4 +148,13 @@
</Path> </Path>
</Viewbox> </Viewbox>
</ControlTemplate> </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> </ResourceDictionary>

View file

@ -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> /// <summary>
/// Looks up a localized string similar to Flow Filter. /// Looks up a localized string similar to Flow Filter.
/// </summary> /// </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> /// <summary>
/// Looks up a localized string similar to Pyramid Scale Factor. /// Looks up a localized string similar to Pyramid Scale Factor.
/// </summary> /// </summary>

View file

@ -240,6 +240,9 @@
<data name="FastPyramidsTooltip" xml:space="preserve"> <data name="FastPyramidsTooltip" xml:space="preserve">
<value /> <value />
</data> </data>
<data name="FileOutputGroupBox" xml:space="preserve">
<value>Output</value>
</data>
<data name="FlowFilterLabel" xml:space="preserve"> <data name="FlowFilterLabel" xml:space="preserve">
<value>Flow Filter</value> <value>Flow Filter</value>
</data> </data>
@ -270,6 +273,12 @@
<data name="PixelNeighborhoodTooltip" xml:space="preserve"> <data name="PixelNeighborhoodTooltip" xml:space="preserve">
<value>Size of the pixel neighborhood.</value> <value>Size of the pixel neighborhood.</value>
</data> </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"> <data name="PyramidScaleLabel" xml:space="preserve">
<value>Pyramid Scale Factor</value> <value>Pyramid Scale Factor</value>
</data> </data>

View file

@ -71,12 +71,13 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </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>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@ -88,6 +89,25 @@
<Button Grid.Column="2" MinWidth="25" Name="btnFilePicker" Click="btnFilePicker_Click">...</Button> <Button Grid.Column="2" MinWidth="25" Name="btnFilePicker" Click="btnFilePicker_Click">...</Button>
</Grid> </Grid>
</GroupBox> </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}"> <GroupBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Header="{x:Static loc:Localization.CommonOptionsGroupBox}">
<ScrollViewer> <ScrollViewer>
<StackPanel> <StackPanel>
@ -115,7 +135,7 @@
<RadioButton GroupName="PlaybackRate" Checked="PlaybackRateRadioButton_Checked" Content="{x:Static loc:Localization._120fpsLabel}" Tag="120" /> <RadioButton GroupName="PlaybackRate" Checked="PlaybackRateRadioButton_Checked" Content="{x:Static loc:Localization._120fpsLabel}" Tag="120" />
</butterflow_ui:ButterflowOption> </butterflow_ui:ButterflowOption>
<butterflow_ui:ButterflowOption LabelValue="{x:Static loc:Localization.CustomPlaybackRateLabel}" DescriptionValue="{x:Static loc:Localization.PlaybackRateDescription}"> <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> </butterflow_ui:ButterflowOption>
</StackPanel> </StackPanel>
</butterflow_ui:ButterflowOption> </butterflow_ui:ButterflowOption>
@ -288,7 +308,7 @@
</ItemsPanelTemplate> </ItemsPanelTemplate>
</StatusBar.ItemsPanel> </StatusBar.ItemsPanel>
<StatusBarItem Grid.Column="0"> <StatusBarItem Grid.Column="0">
<Button> <Button Name="btnCopyArguments" Click="btnCopyArguments_Click">
<ContentControl Template="{StaticResource CopyIcon}" /> <ContentControl Template="{StaticResource CopyIcon}" />
</Button> </Button>
</StatusBarItem> </StatusBarItem>

View file

@ -113,16 +113,29 @@ namespace butterflow_ui
{ {
this.OptionsConfiguration.VideoInput = ofd.FileName; this.OptionsConfiguration.VideoInput = ofd.FileName;
//this.ButterflowWrapper.ConsoleOutputRecieved += (o, ce) => this.txtConsoleOutput.Text = ce.ConsoleOutput;
this.ButterflowWrapper.Probe(ofd.FileName); this.ButterflowWrapper.Probe(ofd.FileName);
//Hack to get the first frame to display in the media preview element. //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.Play();
mediaPreview.PausePlayback(); 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> /// <summary> Event handler. Called by PlaybackRate radio buttons for checked events. </summary>
/// <param name="sender"> Source of the event. </param> /// <param name="sender"> Source of the event. </param>
/// <param name="e"> Routed event information. </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="sender"> Source of the event. </param>
/// <param name="e"> Routed event information. </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. //Clear all the radio buttons because we got focus from the user in the playbackrate textbox.
var playbackRateRadioButtons = GetRecursiveChildren<RadioButton>(this.butterflowUIWindow); var playbackRateRadioButtons = GetRecursiveChildren<RadioButton>(this.butterflowUIWindow);
foreach(var radioButton in playbackRateRadioButtons) foreach (var radioButton in playbackRateRadioButtons)
{ {
radioButton.IsChecked = false; 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 #endregion
} }
} }

View file

@ -450,8 +450,6 @@ namespace butterflow_ui
if (this.KeepAudio) stringBuilder.Append("-audio "); if (this.KeepAudio) stringBuilder.Append("-audio ");
if (this.LosslessQuality) stringBuilder.Append("-l "); if (this.LosslessQuality) stringBuilder.Append("-l ");
stringBuilder.AppendFormat("\"{0}\"", this.VideoInput);
if (this.Subregions.Any()) if (this.Subregions.Any())
{ {
foreach (var anon in this.Subregions.Select((sr, index) => new { Index = index, Subregion = sr })) 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.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.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 (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(); return stringBuilder.ToString();
} }