Skip to content
This repository was archived by the owner on Jul 21, 2020. It is now read-only.

Commit c74b4a4

Browse files
committed
Added Enable - Disable specific Audio Tracks
1 parent 2dc6f42 commit c74b4a4

5 files changed

Lines changed: 304 additions & 26 deletions

File tree

NotEnoughEncodes/AudioEncode.cs

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace NotEnoughEncodes
77
{
88
internal class AudioEncode
99
{
10-
public static void EncodeAudio(string videoInput, bool logging, string audioBitrate, string audioCodec, string currentPath, string ffmpegPath)
10+
public static void EncodeAudio(string videoInput, bool logging, string audioBitrate, string audioCodec, string currentPath, string ffmpegPath, bool trackone, bool tracktwo, bool trackthree, bool trackfour)
1111
{
1212
if (logging == true)
1313
{
@@ -108,7 +108,87 @@ public static void EncodeAudio(string videoInput, bool logging, string audioBitr
108108
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
109109
startInfo.WorkingDirectory = ffmpegPath;
110110
startInfo.FileName = "cmd.exe";
111-
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath +"\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio2.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio3.mkv" + '\u0022';
111+
112+
if (trackone == true && tracktwo == true && trackthree == true && trackfour == true)
113+
{
114+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio2.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio3.mkv" + '\u0022';
115+
}
116+
//Only One out of Four Tracks
117+
//1st Track
118+
if (trackone == true && tracktwo == false && trackthree == false && trackfour == false)
119+
{
120+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022';
121+
}
122+
//2nd Track
123+
if (trackone == false && tracktwo == true && trackthree == false && trackfour == false)
124+
{
125+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022';
126+
}
127+
//3rd Track
128+
if (trackone == false && tracktwo == false && trackthree == true && trackfour == false)
129+
{
130+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio2.mkv" + '\u0022';
131+
}
132+
//4th Track
133+
if (trackone == false && tracktwo == false && trackthree == false && trackfour == true)
134+
{
135+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio3.mkv" + '\u0022';
136+
}
137+
138+
//Two out of Four Tracks
139+
//1st & 2nd // //
140+
if (trackone == true && tracktwo == true && trackthree == false && trackfour == false)
141+
{
142+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022';
143+
}
144+
//1st & 3rd // //
145+
if (trackone == true && tracktwo == false && trackthree == true && trackfour == false)
146+
{
147+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio2.mkv" + '\u0022';
148+
}
149+
//1st & 4th // //
150+
if (trackone == true && tracktwo == false && trackthree == false && trackfour == true)
151+
{
152+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio3.mkv" + '\u0022';
153+
}
154+
//2nd & 3rd // //
155+
if (trackone == false && tracktwo == true && trackthree == true && trackfour == false)
156+
{
157+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio2.mkv" + '\u0022';
158+
}
159+
//2nd & 4th // //
160+
if (trackone == false && tracktwo == true && trackthree == false && trackfour == true)
161+
{
162+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio3.mkv" + '\u0022';
163+
}
164+
//3rd & 4th // //
165+
if (trackone == false && tracktwo == false && trackthree == true && trackfour == true)
166+
{
167+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio2.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio3.mkv" + '\u0022';
168+
}
169+
170+
//Three out of Four Tracks
171+
//1st & 2nd & 3rd // // //
172+
if (trackone == true && tracktwo == true && trackthree == true && trackfour == false)
173+
{
174+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio2.mkv" + '\u0022';
175+
}
176+
//1st & 2nd & 4th // // //
177+
if (trackone == true && tracktwo == true && trackthree == false && trackfour == true)
178+
{
179+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio3.mkv" + '\u0022';
180+
}
181+
//1st & 3rd & 4th // // //
182+
if (trackone == true && tracktwo == false && trackthree == true && trackfour == true)
183+
{
184+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio2.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio3.mkv" + '\u0022';
185+
}
186+
//2nd & 3rd & 4th // // //
187+
if (trackone == false && tracktwo == true && trackthree == true && trackfour == true)
188+
{
189+
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio2.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio3.mkv" + '\u0022';
190+
}
191+
112192
Console.WriteLine(startInfo.Arguments);
113193
process.StartInfo = startInfo;
114194
process.Start();

NotEnoughEncodes/AudioSettings.xaml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
xmlns:local="clr-namespace:NotEnoughEncodes"
77
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2" x:Class="NotEnoughEncodes.AudioSettings"
88
mc:Ignorable="d"
9-
Title="Audio Settings" Height="242.667" Width="338" ResizeMode="NoResize">
9+
Title="Audio Settings" Height="268" Width="380.667" ResizeMode="NoResize">
1010
<Window.Resources>
1111
<Style x:Key="FocusVisual">
1212
<Setter Property="Control.Template">
@@ -295,7 +295,7 @@
295295
</Window.Background>
296296
<Grid>
297297

298-
<ComboBox x:Name="ComboBoxAudioCodec" Width="138" VerticalAlignment="Top" Style="{DynamicResource ComboBoxStyle1}" RenderTransformOrigin="0.5,0.5" OverridesDefaultStyle="True" Margin="130,22,0,0" HorizontalAlignment="Left" Foreground="White" Background="Black" BorderBrush="#FF4F4F4F" SelectionChanged="ComboBoxAudioCodec_SelectionChanged">
298+
<ComboBox x:Name="ComboBoxAudioCodec" Width="138" VerticalAlignment="Top" Style="{DynamicResource ComboBoxStyle1}" RenderTransformOrigin="0.5,0.5" OverridesDefaultStyle="True" Margin="155,23,0,0" HorizontalAlignment="Left" Foreground="White" Background="Black" BorderBrush="#FF4F4F4F" SelectionChanged="ComboBoxAudioCodec_SelectionChanged">
299299
<ComboBox.RenderTransform>
300300
<TransformGroup>
301301
<ScaleTransform />
@@ -321,9 +321,18 @@
321321
<ComboBoxItem Content="MP3 CBR" />
322322
<ComboBoxItem Content="MP3 VBR" />
323323
</ComboBox>
324-
<Label Content="Select Codec" HorizontalAlignment="Left" Margin="39,20,0,0" VerticalAlignment="Top" Foreground="White" Background="#99232323" />
325-
<TextBox x:Name="TextBoxAudioBitrate" HorizontalAlignment="Left" Height="25" Margin="131,59,0,0" TextWrapping="Wrap" Text="128" VerticalAlignment="Top" Width="137" Background="#7F232323" Foreground="White" SpellCheck.IsEnabled="True" TextAlignment="Center" TextDecorations="{x:Null}" VerticalContentAlignment="Center" />
326-
<Button Content="Save" HorizontalAlignment="Left" Margin="65,126,0,0" VerticalAlignment="Top" Width="176" Height="51" Background="#99232323" BorderBrush="White" Foreground="White" Click="Button_Click" />
327-
<Label x:Name="LabelBitrate" Content="Bitrate (kbps)" HorizontalAlignment="Left" Margin="39,59,0,0" VerticalAlignment="Top" Foreground="White" Background="#99232323" />
324+
<Label Content="Select Codec" HorizontalAlignment="Left" Margin="60,21,0,0" VerticalAlignment="Top" Foreground="White" Background="#99232323" />
325+
<TextBox x:Name="TextBoxAudioBitrate" HorizontalAlignment="Left" Height="25" Margin="156,60,0,0" TextWrapping="Wrap" Text="128" VerticalAlignment="Top" Width="137" Background="#7F232323" Foreground="White" SpellCheck.IsEnabled="True" TextAlignment="Center" TextDecorations="{x:Null}" VerticalContentAlignment="Center" />
326+
<Button Content="Save" HorizontalAlignment="Left" Margin="92,162,0,0" VerticalAlignment="Top" Width="176" Height="51" Background="#99232323" BorderBrush="White" Foreground="White" Click="Button_Click" />
327+
<Label x:Name="LabelBitrate" Content="Bitrate (kbps)" HorizontalAlignment="Left" Margin="60,60,0,0" VerticalAlignment="Top" Foreground="White" Background="#99232323" />
328+
<Rectangle HorizontalAlignment="Left" Height="52" Margin="25,98,0,0" Stroke="White" VerticalAlignment="Top" Width="322" Fill="#4C232323"/>
329+
<CheckBox x:Name="CheckBoxTrackOne" Content="" HorizontalAlignment="Left" Margin="81,100,0,0" VerticalAlignment="Top" Background="#7FFFFFFF" Foreground="White" BorderBrush="White" IsChecked="True"/>
330+
<CheckBox x:Name="CheckBoxTrackTwo" Content="" HorizontalAlignment="Left" Margin="141,100,0,0" VerticalAlignment="Top" Background="#7FFFFFFF" Foreground="White" BorderBrush="White" IsChecked="True"/>
331+
<CheckBox x:Name="CheckBoxTrackThree" Content="" HorizontalAlignment="Left" Margin="198,100,0,0" VerticalAlignment="Top" Background="#7FFFFFFF" Foreground="White" BorderBrush="White" IsChecked="True"/>
332+
<CheckBox x:Name="CheckBoxTrackFour" Content="" HorizontalAlignment="Left" Margin="260,100,0,0" VerticalAlignment="Top" Background="#7FFFFFFF" Foreground="White" BorderBrush="White" IsChecked="True"/>
333+
<Label Content="Track 1" HorizontalAlignment="Left" Margin="67,120,0,0" VerticalAlignment="Top" Foreground="White" Background="#99232323"/>
334+
<Label Content="Track 2" HorizontalAlignment="Left" Margin="127,120,0,0" VerticalAlignment="Top" Foreground="White" Background="#99232323"/>
335+
<Label Content="Track 3" HorizontalAlignment="Left" Margin="185,120,0,0" VerticalAlignment="Top" Foreground="White" Background="#99232323"/>
336+
<Label Content="Track 4" HorizontalAlignment="Left" Margin="246,120,0,0" VerticalAlignment="Top" Foreground="White" Background="#99232323" RenderTransformOrigin="0.596,0.513"/>
328337
</Grid>
329338
</Window>

NotEnoughEncodes/AudioSettings.xaml.cs

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Windows;
1+
using System;
2+
using System.Windows;
23
using System.Windows.Controls;
34

45
namespace NotEnoughEncodes
@@ -8,6 +9,11 @@ namespace NotEnoughEncodes
89
/// </summary>
910
public partial class AudioSettings : Window
1011
{
12+
string text;
13+
bool trackone;
14+
bool tracktwo;
15+
bool trackthree;
16+
bool trackfour;
1117
public AudioSettings()
1218
{
1319
InitializeComponent();
@@ -19,8 +25,41 @@ public AudioSettings()
1925
{
2026
TextBoxAudioBitrate.Text = MainWindow.audioBitrate;
2127
}
28+
if (MainWindow.trackoneactive == false)
29+
{
30+
CheckBoxTrackOne.IsChecked = false;
31+
32+
}else if (MainWindow.trackoneactive == true)
33+
{
34+
CheckBoxTrackOne.IsChecked = true;
35+
}
36+
if (MainWindow.tracktwoactive == false)
37+
{
38+
CheckBoxTrackTwo.IsChecked = false;
39+
}
40+
else if (MainWindow.tracktwoactive == true)
41+
{
42+
CheckBoxTrackTwo.IsChecked = true;
43+
}
44+
if (MainWindow.trackthreeactive == false)
45+
{
46+
CheckBoxTrackThree.IsChecked = false;
47+
}
48+
else if (MainWindow.trackthreeactive == true)
49+
{
50+
CheckBoxTrackThree.IsChecked = true;
51+
}
52+
if (MainWindow.trackfouractive == false)
53+
{
54+
CheckBoxTrackFour.IsChecked = false;
55+
}
56+
else if (MainWindow.trackfouractive == true)
57+
{
58+
CheckBoxTrackFour.IsChecked = true;
59+
}
60+
2261
}
23-
string text;
62+
2463
private void ComboBoxAudioCodec_SelectionChanged(object sender, SelectionChangedEventArgs e)
2564
{
2665

@@ -46,12 +85,17 @@ private void ComboBoxAudioCodec_SelectionChanged(object sender, SelectionChanged
4685

4786
private void Button_Click(object sender, RoutedEventArgs e)
4887
{
88+
trackone = CheckBoxTrackOne.IsChecked == true;
89+
tracktwo = CheckBoxTrackTwo.IsChecked == true;
90+
trackthree = CheckBoxTrackThree.IsChecked == true;
91+
trackfour = CheckBoxTrackFour.IsChecked == true;
92+
//Console.WriteLine(trackone + " " + tracktwo + " " + trackthree + " " + trackfour);
4993
SaveSettings();
5094
}
5195

5296
private void SaveSettings()
5397
{
54-
MainWindow.SaveAudioSettings(ComboBoxAudioCodec.Text, TextBoxAudioBitrate.Text);
98+
MainWindow.SaveAudioSettings(ComboBoxAudioCodec.Text, TextBoxAudioBitrate.Text, trackone, tracktwo, trackthree, trackfour);
5599
this.Close();
56100
}
57101
}

0 commit comments

Comments
 (0)