New setting for using FFMPEG to extract audio

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@2200 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2013-11-18 07:31:55 +00:00
parent d29c1db188
commit 8082189103
8 changed files with 185 additions and 20 deletions

View File

@ -36,6 +36,7 @@
this.labelSourcevideoFile = new System.Windows.Forms.Label();
this.labelVideoFileName = new System.Windows.Forms.Label();
this.buttonCancel = new System.Windows.Forms.Button();
this.labelInfo = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// labelPleaseWait
@ -105,11 +106,22 @@
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// labelInfo
//
this.labelInfo.ForeColor = System.Drawing.Color.Gray;
this.labelInfo.Location = new System.Drawing.Point(427, 6);
this.labelInfo.Name = "labelInfo";
this.labelInfo.Size = new System.Drawing.Size(120, 13);
this.labelInfo.TabIndex = 18;
this.labelInfo.Text = "label1";
this.labelInfo.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// AddWareForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(550, 138);
this.Controls.Add(this.labelInfo);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.labelVideoFileName);
this.Controls.Add(this.labelSourcevideoFile);
@ -143,5 +155,6 @@
private System.Windows.Forms.Label labelSourcevideoFile;
private System.Windows.Forms.Label labelVideoFileName;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Label labelInfo;
}
}

View File

@ -25,6 +25,7 @@ namespace Nikse.SubtitleEdit.Forms
InitializeComponent();
labelProgress.Text = string.Empty;
buttonCancel.Visible = false;
labelInfo.Text = string.Empty;
}
public WavePeakGenerator WavePeak { get; private set; }
@ -48,23 +49,23 @@ namespace Nikse.SubtitleEdit.Forms
{
buttonRipWave.Enabled = false;
_cancel = false;
bool runningOnWindows = false;
SourceVideoFileName = labelVideoFileName.Text;
string targetFile = Path.GetTempFileName() + ".wav";
// string parameters = "-I dummy -vvv \"" + SourceVideoFileName + "\" --sout=#transcode{vcodec=none,acodec=s16l}:file{dst=\"" + targetFile + "\"} vlc://quit";
string parameters = "-I dummy -vvv --no-sout-video --audio-track=" + _audioTrackNumber.ToString() + " --sout #transcode{" + _encodeParamters + "}:std{mux=wav,access=file,dst=\"" + targetFile + "\"} \"" + SourceVideoFileName + "\" vlc://quit";
string vlcPath;
string exeFilePath;
if (Utilities.IsRunningOnLinux() || Utilities.IsRunningOnMac())
{
vlcPath = "cvlc";
exeFilePath = "cvlc";
parameters = "-vvv --no-sout-video --audio-track=" + _audioTrackNumber.ToString() + " --sout '#transcode{" + _encodeParamters + "}:std{mux=wav,access=file,dst=" + targetFile + "}' \"" + SourceVideoFileName + "\" vlc://quit";
}
else // windows
{
vlcPath = Nikse.SubtitleEdit.Logic.VideoPlayers.LibVlc11xDynamic.GetVlcPath("vlc.exe");
if (!System.IO.File.Exists(vlcPath))
runningOnWindows = true;
exeFilePath = Nikse.SubtitleEdit.Logic.VideoPlayers.LibVlc11xDynamic.GetVlcPath("vlc.exe");
if (!System.IO.File.Exists(exeFilePath))
{
if (MessageBox.Show(Configuration.Settings.Language.AddWaveForm.VlcMediaPlayerNotFound + Environment.NewLine +
Environment.NewLine +
@ -78,10 +79,22 @@ namespace Nikse.SubtitleEdit.Forms
}
}
labelInfo.Text = "VCL";
if (Configuration.Settings.General.UseFFMPEGForWaveExtraction && File.Exists(Configuration.Settings.General.FFMPEGLocation) && !string.IsNullOrEmpty(Configuration.Settings.General.FFMPEGWaveTranscodeSettings))
{
exeFilePath = Configuration.Settings.General.FFMPEGLocation;
parameters = string.Format(Configuration.Settings.General.FFMPEGWaveTranscodeSettings, SourceVideoFileName, targetFile);
//-i indicates the input
//-ab indicates the bit rate (in this example 160kb/sec)
//-vn means no video ouput
//-ac 2 means 2 channels
//-ar 44100 indicates the sampling frequency.
labelInfo.Text = "FFMPEG";
}
labelPleaseWait.Visible = true;
Process process = new Process();
process.StartInfo = new ProcessStartInfo(vlcPath, parameters);
process.StartInfo = new ProcessStartInfo(exeFilePath, parameters);
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
progressBar1.Style = ProgressBarStyle.Marquee;
@ -116,6 +129,30 @@ namespace Nikse.SubtitleEdit.Forms
DialogResult = DialogResult.Cancel;
return;
}
if (seconds > 1 && Convert.ToInt32(seconds) % 60 == 0 && runningOnWindows)
{
try
{
var drive = new DriveInfo("c");
if (drive.IsReady)
{
if (drive.AvailableFreeSpace < 50 * 1000000) // 50 mb
{
labelInfo.ForeColor = Color.Red;
labelInfo.Text = "LOW DISC SPACE!";
}
else if (labelInfo.ForeColor == Color.Red)
{
labelInfo.Text = Utilities.FormatBytesToDisplayFileSize(drive.AvailableFreeSpace) + " free";
}
}
}
catch
{
}
}
}
buttonCancel.Visible = false;
progressBar1.Visible = false;
@ -132,7 +169,7 @@ namespace Nikse.SubtitleEdit.Forms
MessageBox.Show("Could not find extracted wave file! This feature requires VLC media player 1.1.x or newer (32-bit)." + Environment.NewLine
+ Environment.NewLine +
"Command line: " + vlcPath + " " + parameters);
"Command line: " + exeFilePath + " " + parameters);
labelPleaseWait.Visible = false;
labelProgress.Text = string.Empty;
@ -145,7 +182,7 @@ namespace Nikse.SubtitleEdit.Forms
{
MessageBox.Show("Sorry! VLC was unable to extract audio to wave file via this command line:" + Environment.NewLine
+ Environment.NewLine +
"Command line: " + vlcPath + " " + parameters);
"Command line: " + exeFilePath + " " + parameters);
labelPleaseWait.Visible = false;
labelProgress.Text = string.Empty;

View File

@ -175,6 +175,7 @@
this.checkBoxWaveFormShowGrid = new System.Windows.Forms.CheckBox();
this.tabPageTools = new System.Windows.Forms.TabPage();
this.groupBoxSpellCheck = new System.Windows.Forms.GroupBox();
this.checkBoxTreatINQuoteAsING = new System.Windows.Forms.CheckBox();
this.checkBoxSpellCheckOneLetterWords = new System.Windows.Forms.CheckBox();
this.checkBoxSpellCheckAutoChangeNames = new System.Windows.Forms.CheckBox();
this.groupBoxFixCommonErrors = new System.Windows.Forms.GroupBox();
@ -259,7 +260,12 @@
this.colorDialogSSAStyle = new System.Windows.Forms.ColorDialog();
this.fontDialogSSAStyle = new System.Windows.Forms.FontDialog();
this.labelStatus = new System.Windows.Forms.Label();
this.checkBoxTreatINQuoteAsING = new System.Windows.Forms.CheckBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.checkBoxUseFFMPEG = new System.Windows.Forms.CheckBox();
this.labelFFMPEGPath = new System.Windows.Forms.Label();
this.textBoxFFMPEGPath = new System.Windows.Forms.TextBox();
this.buttonBrowseToFFMPEG = new System.Windows.Forms.Button();
this.openFileDialogFFMPEG = new System.Windows.Forms.OpenFileDialog();
this.tabControlSettings.SuspendLayout();
this.tabPageGenerel.SuspendLayout();
this.groupBoxMiscellaneous.SuspendLayout();
@ -313,6 +319,7 @@
this.tabPageSyntaxColoring.SuspendLayout();
this.groupBoxListViewSyntaxColoring.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSyntaxColorTextMoreThanXLines)).BeginInit();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// buttonOK
@ -1702,6 +1709,7 @@
//
// tabPageWaveForm
//
this.tabPageWaveForm.Controls.Add(this.groupBox3);
this.tabPageWaveForm.Controls.Add(this.groupBoxSpectrogram);
this.tabPageWaveForm.Controls.Add(this.groupBox1);
this.tabPageWaveForm.Controls.Add(this.groupBoxWaveFormAppearence);
@ -1761,7 +1769,7 @@
this.groupBox1.Controls.Add(this.labelWaveFormsFolderInfo);
this.groupBox1.Location = new System.Drawing.Point(6, 325);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(813, 116);
this.groupBox1.Size = new System.Drawing.Size(394, 116);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
//
@ -1994,6 +2002,16 @@
this.groupBoxSpellCheck.TabStop = false;
this.groupBoxSpellCheck.Text = "Spell check";
//
// checkBoxTreatINQuoteAsING
//
this.checkBoxTreatINQuoteAsING.AutoSize = true;
this.checkBoxTreatINQuoteAsING.Location = new System.Drawing.Point(16, 66);
this.checkBoxTreatINQuoteAsING.Name = "checkBoxTreatINQuoteAsING";
this.checkBoxTreatINQuoteAsING.Size = new System.Drawing.Size(253, 17);
this.checkBoxTreatINQuoteAsING.TabIndex = 2;
this.checkBoxTreatINQuoteAsING.Text = "Treat word ending \" in\' \" as \" ing \" (English only)";
this.checkBoxTreatINQuoteAsING.UseVisualStyleBackColor = true;
//
// checkBoxSpellCheckOneLetterWords
//
this.checkBoxSpellCheckOneLetterWords.AutoSize = true;
@ -3014,15 +3032,58 @@
this.labelStatus.TabIndex = 3;
this.labelStatus.Text = "labelStatus";
//
// checkBoxTreatINQuoteAsING
// groupBox3
//
this.checkBoxTreatINQuoteAsING.AutoSize = true;
this.checkBoxTreatINQuoteAsING.Location = new System.Drawing.Point(16, 66);
this.checkBoxTreatINQuoteAsING.Name = "checkBoxTreatINQuoteAsING";
this.checkBoxTreatINQuoteAsING.Size = new System.Drawing.Size(253, 17);
this.checkBoxTreatINQuoteAsING.TabIndex = 2;
this.checkBoxTreatINQuoteAsING.Text = "Treat word ending \" in\' \" as \" ing \" (English only)";
this.checkBoxTreatINQuoteAsING.UseVisualStyleBackColor = true;
this.groupBox3.Controls.Add(this.buttonBrowseToFFMPEG);
this.groupBox3.Controls.Add(this.textBoxFFMPEGPath);
this.groupBox3.Controls.Add(this.labelFFMPEGPath);
this.groupBox3.Controls.Add(this.checkBoxUseFFMPEG);
this.groupBox3.Location = new System.Drawing.Point(406, 325);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(416, 116);
this.groupBox3.TabIndex = 3;
this.groupBox3.TabStop = false;
//
// checkBoxUseFFMPEG
//
this.checkBoxUseFFMPEG.AutoSize = true;
this.checkBoxUseFFMPEG.Location = new System.Drawing.Point(6, 20);
this.checkBoxUseFFMPEG.Name = "checkBoxUseFFMPEG";
this.checkBoxUseFFMPEG.Size = new System.Drawing.Size(201, 17);
this.checkBoxUseFFMPEG.TabIndex = 1;
this.checkBoxUseFFMPEG.Text = "Use FFMPEG for wave file extraction";
this.checkBoxUseFFMPEG.UseVisualStyleBackColor = true;
//
// labelFFMPEGPath
//
this.labelFFMPEGPath.AutoSize = true;
this.labelFFMPEGPath.Location = new System.Drawing.Point(6, 49);
this.labelFFMPEGPath.Name = "labelFFMPEGPath";
this.labelFFMPEGPath.Size = new System.Drawing.Size(71, 13);
this.labelFFMPEGPath.TabIndex = 2;
this.labelFFMPEGPath.Text = "FFMPEG path";
//
// textBoxFFMPEGPath
//
this.textBoxFFMPEGPath.Location = new System.Drawing.Point(9, 65);
this.textBoxFFMPEGPath.MaxLength = 1000;
this.textBoxFFMPEGPath.Name = "textBoxFFMPEGPath";
this.textBoxFFMPEGPath.Size = new System.Drawing.Size(366, 21);
this.textBoxFFMPEGPath.TabIndex = 22;
//
// buttonBrowseToFFMPEG
//
this.buttonBrowseToFFMPEG.Location = new System.Drawing.Point(381, 65);
this.buttonBrowseToFFMPEG.Name = "buttonBrowseToFFMPEG";
this.buttonBrowseToFFMPEG.Size = new System.Drawing.Size(29, 21);
this.buttonBrowseToFFMPEG.TabIndex = 23;
this.buttonBrowseToFFMPEG.Text = "...";
this.buttonBrowseToFFMPEG.UseVisualStyleBackColor = true;
this.buttonBrowseToFFMPEG.Click += new System.EventHandler(this.buttonBrowseToFFMPEG_Click);
//
// openFileDialogFFMPEG
//
this.openFileDialogFFMPEG.FileName = "openFileDialog1";
//
// Settings
//
@ -3118,6 +3179,8 @@
this.groupBoxListViewSyntaxColoring.ResumeLayout(false);
this.groupBoxListViewSyntaxColoring.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSyntaxColorTextMoreThanXLines)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -3357,5 +3420,11 @@
private System.Windows.Forms.CheckBox checkBoxSsaOpaqueBox;
private System.Windows.Forms.CheckBox checkBoxSpellCheckOneLetterWords;
private System.Windows.Forms.CheckBox checkBoxTreatINQuoteAsING;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button buttonBrowseToFFMPEG;
private System.Windows.Forms.TextBox textBoxFFMPEGPath;
private System.Windows.Forms.Label labelFFMPEGPath;
private System.Windows.Forms.CheckBox checkBoxUseFFMPEG;
private System.Windows.Forms.OpenFileDialog openFileDialogFFMPEG;
}
}

View File

@ -319,6 +319,12 @@ namespace Nikse.SubtitleEdit.Forms
buttonWaveFormsFolderEmpty.Text = language.WaveformAndSpectrogramsFolderEmpty;
InitializeWaveformsAndSpectrogramsFolderEmpty(language);
if (!string.IsNullOrEmpty(language.WaveformFFMPEGPath)) //TODO: Remove in SE 3.4
{
checkBoxUseFFMPEG.Text = language.WaveformUseFFMPEG;
labelFFMPEGPath.Text = language.WaveformFFMPEGPath;
}
groupBoxSsaStyle.Text = language.SubStationAlphaStyle;
buttonSSAChooseFont.Text = language.ChooseFont;
buttonSSAChooseColor.Text = language.ChooseColor;
@ -517,6 +523,8 @@ namespace Nikse.SubtitleEdit.Forms
if (Configuration.Settings.VideoControls.WaveformBorderHitMs >= numericUpDownWaveformBorderHitMs.Minimum &&
Configuration.Settings.VideoControls.WaveformBorderHitMs <= numericUpDownWaveformBorderHitMs.Maximum)
numericUpDownWaveformBorderHitMs.Value = Configuration.Settings.VideoControls.WaveformBorderHitMs;
checkBoxUseFFMPEG.Checked = Configuration.Settings.General.UseFFMPEGForWaveExtraction;
textBoxFFMPEGPath.Text = Configuration.Settings.General.FFMPEGLocation;
var generalNode = new TreeNode(Configuration.Settings.Language.General.GeneralText);
generalNode.Nodes.Add(language.GoToFirstSelectedLine + GetShortcutText(Configuration.Settings.Shortcuts.GeneralGoToFirstSelectedLine));
@ -1049,6 +1057,8 @@ namespace Nikse.SubtitleEdit.Forms
Configuration.Settings.VideoControls.WaveFormMouseWheelScrollUpIsForward = checkBoxReverseMouseWheelScrollDirection.Checked;
Configuration.Settings.VideoControls.WaveFormAllowOverlap = checkBoxAllowOverlap.Checked;
Configuration.Settings.VideoControls.WaveformBorderHitMs = Convert.ToInt32(numericUpDownWaveformBorderHitMs.Value);
Configuration.Settings.General.UseFFMPEGForWaveExtraction = checkBoxUseFFMPEG.Checked;
Configuration.Settings.General.FFMPEGLocation = textBoxFFMPEGPath.Text;
//Main General
foreach (TreeNode node in treeViewShortcuts.Nodes[0].Nodes)
@ -2463,5 +2473,16 @@ namespace Nikse.SubtitleEdit.Forms
UpdateSsaExample();
}
private void buttonBrowseToFFMPEG_Click(object sender, EventArgs e)
{
openFileDialogFFMPEG.Title = Configuration.Settings.Language.Settings.WaveformBrowseToFFMPEG;
if (!Utilities.IsRunningOnLinux() && !Utilities.IsRunningOnMac())
{
openFileDialogFFMPEG.Filter = "FFMPEG.exe|FFMPEG.exe";
}
if (openFileDialogFFMPEG.ShowDialog(this) == DialogResult.OK)
textBoxFFMPEGPath.Text = openFileDialogFFMPEG.FileName;
}
}
}

View File

@ -123,4 +123,7 @@
<metadata name="fontDialogSSAStyle.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>130, 17</value>
</metadata>
<metadata name="openFileDialogFFMPEG.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>287, 17</value>
</metadata>
</root>

View File

@ -1688,6 +1688,9 @@ can edit in same subtitle file (collaboration)",
SpectrogramAppearance = "Spectrogram appearance",
SpectrogramOneColorGradient = "One color gradient",
SpectrogramClassic = "Classic",
WaveformUseFFMPEG = "Use FFMPEG for wave extraction",
WaveformFFMPEGPath = "Path to FFMPEG",
WaveformBrowseToFFMPEG = "Browse to FFMPEG",
SubStationAlphaStyle = "Sub Station Alpha style",
ChooseFont = "Choose font",
ChooseColor = "Choose color",

View File

@ -1586,6 +1586,9 @@
public string SpectrogramAppearance { get; set; }
public string SpectrogramOneColorGradient { get; set; }
public string SpectrogramClassic { get; set; }
public string WaveformUseFFMPEG { get; set; }
public string WaveformFFMPEGPath { get; set; }
public string WaveformBrowseToFFMPEG { get; set; }
public string SubStationAlphaStyle { get; set; }
public string ChooseFont { get; set; }
public string ChooseColor { get; set; }

View File

@ -451,6 +451,9 @@ namespace Nikse.SubtitleEdit.Logic
public int ListViewTextWidth { get; set; }
public string VlcWaveTranscodeSettings { get; set; }
public string VlcLocation { get; set; }
public bool UseFFMPEGForWaveExtraction { get; set; }
public string FFMPEGWaveTranscodeSettings { get; set; }
public string FFMPEGLocation { get; set; }
public bool UseTimeFormatHHMMSSFF { get; set; }
public int ClearStatusBarAfterSeconds { get; set; }
public string Company { get; set; }
@ -530,6 +533,7 @@ namespace Nikse.SubtitleEdit.Logic
OpenSubtitleExtraExtensions = "*.mp4;*.m4v;*.mkv;"; // matroska/mp4/m4v files (can contain subtitles)
ListViewColumsRememberSize = true;
VlcWaveTranscodeSettings = "acodec=s16l"; // "acodec=s16l,channels=1,ab=64,samplerate=8000";
FFMPEGWaveTranscodeSettings = "-i \"{0}\" -vn -ar 44100 -ac 2 -ab 128 -vol 320 -f wav \"{1}\""; // -vol 512 will boot volume... 256 is normal
UseTimeFormatHHMMSSFF = false;
ClearStatusBarAfterSeconds = 10;
MoveVideo100Or500MsPlaySmallSample = false;
@ -1307,6 +1311,15 @@ namespace Nikse.SubtitleEdit.Logic
subNode = node.SelectSingleNode("VlcLocation");
if (subNode != null)
settings.General.VlcLocation = subNode.InnerText.Trim();
subNode = node.SelectSingleNode("UseFFMPEGForWaveExtraction");
if (subNode != null)
settings.General.UseFFMPEGForWaveExtraction = Convert.ToBoolean(subNode.InnerText.Trim());
subNode = node.SelectSingleNode("FFMPEGWaveTranscodeSettings");
if (subNode != null)
settings.General.FFMPEGWaveTranscodeSettings = subNode.InnerText.Trim();
subNode = node.SelectSingleNode("FFMPEGLocation");
if (subNode != null)
settings.General.FFMPEGLocation = subNode.InnerText.Trim();
subNode = node.SelectSingleNode("UseTimeFormatHHMMSSFF");
if (subNode != null)
settings.General.UseTimeFormatHHMMSSFF = Convert.ToBoolean(subNode.InnerText.Trim());
@ -2387,6 +2400,9 @@ namespace Nikse.SubtitleEdit.Logic
textWriter.WriteElementString("ListViewTextWidth", settings.General.ListViewTextWidth.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("VlcWaveTranscodeSettings", settings.General.VlcWaveTranscodeSettings);
textWriter.WriteElementString("VlcLocation", settings.General.VlcLocation);
textWriter.WriteElementString("UseFFMPEGForWaveExtraction", settings.General.UseFFMPEGForWaveExtraction.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("FFMPEGWaveTranscodeSettings", settings.General.FFMPEGWaveTranscodeSettings);
textWriter.WriteElementString("FFMPEGLocation", settings.General.FFMPEGLocation);
textWriter.WriteElementString("UseTimeFormatHHMMSSFF", settings.General.UseTimeFormatHHMMSSFF.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("ClearStatusBarAfterSeconds", settings.General.ClearStatusBarAfterSeconds.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("Company", settings.General.Company);