Skip to content

Commit

Permalink
Merge pull request #12 from fediachov/master
Browse files Browse the repository at this point in the history
Features for 1.5.4
  • Loading branch information
RadiumByte committed Apr 14, 2020
2 parents 09c7e53 + c89e353 commit 8b2eec2
Show file tree
Hide file tree
Showing 12 changed files with 3,333 additions and 2,804 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

## Features

- Converting Video to Audio.
- Sequential processing of multiple files.
- Joining several files into one (videos must be with the same resolution).
- Automatically determine the number of threads to encode based on the number of CPU cores.
Expand Down Expand Up @@ -36,8 +37,11 @@
## Audio conversion

- Source Audio File Formats: `*.mp3; *.m4a; *.wav; *.flac; *.ogg; *.ape; *.amr; *.acc`.
- Source Video File Formats: `*.avi; *.mov; *.mkv; *.mpg; *.3gp; *.flv; *.vob; *.mp4; *.ts; *.m2ts`.
- Convert to audio formats: `MP3, OGG Vorbis, FLAC, WAV`.
- Change the bitrate and sample rate of audio.
- Loudness: US Broadcast (ATSC A/A85), EU Broadcast (EBU R128), Podcasts, Dynamic
- Low-pass, High-pass filters.

## Requirements

Expand Down
40 changes: 40 additions & 0 deletions SevenConverter/Actions/ConvertAudio.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using SevenConverter.Forms;
using SevenConverter.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
Expand All @@ -19,6 +20,18 @@ public partial class Main : Form
"WAV"
};

private readonly string[] LoudnessTypes =
{
//US Broadcast (ATSC A/A85)
"loudnorm=I=-24:TP=-2:LRA=7",
//EU Broadcast (EBU R128)
"loudnorm=I=-23:TP=-1.5:LRA=16",
//Podcasts
"loudnorm=I=-10:TP=-0:LRA=16",
//Dynamic
"dynaudnorm"
};

private bool ConvertAudio(string sourceFile, string destFile, bool quoted = true)
{
bool result = false;
Expand All @@ -34,6 +47,8 @@ private bool ConvertAudio(string sourceFile, string destFile, bool quoted = true
if (cbFormat.SelectedIndex == 1)
command.Append(" -acodec libvorbis");

command.Append(GetAudioFilters());

if (cbFormat.SelectedIndex == 0 || cbFormat.SelectedIndex == 1)
command.AppendFormat(" -ab {0} -ar {1}", cbQuality.Text, cbFreq.Text);

Expand All @@ -53,6 +68,31 @@ private bool ConvertAudio(string sourceFile, string destFile, bool quoted = true
return result;
}

private string GetAudioFilters()
{
List<string> filters = new List<string>();

if (cbLoudness.SelectedIndex > 0)
{
filters.Add(LoudnessTypes[cbLoudness.SelectedIndex - 1]);
}

if (cbLowpass.SelectedIndex > 0)
{
filters.Add(String.Concat("lowpass=", cbLowpass.Text));
}

if (cbHighpass.SelectedIndex > 0)
{
filters.Add(String.Concat("highpass=", cbHighpass.Text));
}

if (filters.Count > 0)
return String.Concat(" -af \"", String.Join(",", filters), "\"");
else
return String.Empty;
}

private void TurnAudio()
{
openFileDialog.Filter = Properties.strings.AudioFileFilter;
Expand Down
6 changes: 6 additions & 0 deletions SevenConverter/Actions/ConvertVideo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ private bool ConvertVideo(string sourceFile, string destFile, bool quoted = true
command.AppendFormat(" -vf {0}{1}{2}", rows, delim, hdr);
}

command.Append(GetAudioFilters());

// bitrate
if (cbBitrate.SelectedIndex > 0)
{
Expand Down Expand Up @@ -209,6 +211,10 @@ private void TurnVideo()

btnVideoSet.Visible = true;

cbLoudness.SelectedIndex = 0;
cbLowpass.SelectedIndex = 0;
cbHighpass.SelectedIndex = 0;

cbAudioCodec.SelectedIndex = settings.outputAudioCodec;
cbVideoCodec.SelectedIndex = settings.outputVideoCodec;
cbFormat.SelectedIndex = settings.outputVideoFormat;
Expand Down
4 changes: 3 additions & 1 deletion SevenConverter/Forms/About.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ private void btnUpdates_Click(object sender, EventArgs e)
{
MessageBox.Show(
Properties.strings.SevenConverterIsUpToDate,
Properties.strings.UpToDate);
Properties.strings.UpToDate,
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
Expand Down
Loading

0 comments on commit 8b2eec2

Please sign in to comment.