Skip to content

Commit

Permalink
audio copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Anime4000 committed Apr 29, 2020
1 parent 50db571 commit 0a29fcd
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
20 changes: 14 additions & 6 deletions IFME/MediaEncoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,33 @@ internal static void Extract(MediaQueue queue, string tempDir)

internal static void Audio(MediaQueue queue, string tempDir)
{
var i = 0;
foreach (var item in queue.Audio)
for (int i = 0; i < queue.Audio.Count; i++)
{
var item = queue.Audio[i];

Console2.WriteLine("[INFO] Extract audio file...");
if (item.Copy && queue.OutputFormat == MediaContainer.MKV)
{
ProcessManager.Start(tempDir, $"\"{FFmpeg}\" -hide_banner -v error -i \"{item.File}\" -map 0:{item.Id} -c:a copy -y \"audio{i:D4}_{item.Lang}.mka\"");
continue;
}

Console2.WriteLine("[INFO] Encoding audio file...");
if (Plugins.Items.Audio.TryGetValue(item.Encoder.Id, out PluginsAudio codec))
{
var ac = codec.Audio;
var md = item.Encoder.Mode;
var en = Path.Combine(codec.FilePath, ac.Encoder);
var m = item.Encoder.Mode;

var trim = (queue.Trim.Enable ? $"-ss {queue.Trim.Start} -t {queue.Trim.Duration}" : string.Empty);

var qfix = $"{ac.Mode[m].QualityPrefix}{item.Encoder.Quality}{ac.Mode[m].QualityPostfix}";
var qfix = $"{ac.Mode[md].QualityPrefix}{item.Encoder.Quality}{ac.Mode[md].QualityPostfix}";

var qu = (string.IsNullOrEmpty(ac.Mode[m].Args) ? string.Empty : $"{ac.Mode[m].Args} {qfix}");
var qu = (string.IsNullOrEmpty(ac.Mode[md].Args) ? string.Empty : $"{ac.Mode[md].Args} {qfix}");
var hz = (item.Encoder.SampleRate == 0 ? string.Empty : $"-ar {item.Encoder.SampleRate}");
var ch = (item.Encoder.Channel == 0 ? string.Empty : $"-ac {item.Encoder.Channel}");

var outfile = $"audio{i++:D4}_{item.Lang}.{ac.Extension}";
var outfile = $"audio{i:D4}_{item.Lang}.{ac.Extension}";

if (ac.Args.Pipe)
{
Expand Down
6 changes: 3 additions & 3 deletions IFME/frmMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions IFME/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,8 @@ private void chkAdvTrim_CheckedChanged(object sender, EventArgs e)

private void cboFormat_SelectedIndexChanged(object sender, EventArgs e)
{
chkAudioCopy.Enabled = string.Equals(cboFormat.Text.ToLowerInvariant(), "mkv");

if ((sender as Control).Focused)
{
cboProfile.SelectedIndex = -1;
Expand All @@ -1727,6 +1729,9 @@ private void cboProfile_SelectedIndexChanged(object sender, EventArgs e)

private void btnProfileSaveLoad_Click(object sender, EventArgs e)
{
var message = "Please choose item that has both video and audio in order to save profile preset";
var title = "Unable to save profile preset";

if (lstFile.SelectedItems.Count > 0)
{
var videoEnc = new MediaQueueVideoEncoder();
Expand All @@ -1738,6 +1743,11 @@ private void btnProfileSaveLoad_Click(object sender, EventArgs e)
videoPix = (lstFile.SelectedItems[0].Tag as MediaQueue).Video[0].Quality;
videoDei = (lstFile.SelectedItems[0].Tag as MediaQueue).Video[0].DeInterlace;
}
else
{
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}

var audioCps = false;
var audioEnc = new MediaQueueAudioEncoder();
Expand All @@ -1750,6 +1760,11 @@ private void btnProfileSaveLoad_Click(object sender, EventArgs e)
audioCmd = (lstFile.SelectedItems[0].Tag as MediaQueue).Audio[0].Command;
audioFil = (lstFile.SelectedItems[0].Tag as MediaQueue).Audio[0].CommandFilter;
}
else
{
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}

var ib = new InputBox("Save encoding configuration profile", "Enter new profile name:", 4);
if (ib.ShowDialog() == DialogResult.OK)
Expand All @@ -1775,6 +1790,10 @@ private void btnProfileSaveLoad_Click(object sender, EventArgs e)
InitializeProfiles();
}
}
else
{
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}

private void btnProfileSaveLoad_MouseUp(object sender, MouseEventArgs e)
Expand Down
3 changes: 0 additions & 3 deletions IFME/frmMain.resx
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,6 @@
<metadata name="grpAdvTrim.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="grpAdvTrim.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblAdvTimeEqual.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
Expand Down

0 comments on commit 0a29fcd

Please sign in to comment.