|
馬上註冊,結交更多好友,享用更多功能,讓你輕鬆玩轉社區。
您需要 登錄 才可以下載或查看,沒有賬號?註冊
x
本文章最後由 acerx 於 2012-11-19 00:10 編輯
- private string LocalDirectory = System.Environment.CurrentDirectory;
-
- private byte[] ReadBuffer = new byte[4096];
- private System.Diagnostics.Process Decoder = new System.Diagnostics.Process();
- private System.Diagnostics.Process Encoder = new System.Diagnostics.Process();
- private System.IO.BinaryWriter EncoderRawInput;
- //Create WAV temp file for testing
- private System.IO.Stream AS = new System.IO.FileStream("D:\\temporary.wav", System.IO.FileMode.Create);
- private System.IO.BinaryWriter DecoderOutputRaw;
-
- public void AudioDecoding()
- {
- string INPUT = '"' + tbInputMedia.Text + '"';
- string FFmpegOpts = "";
- string FFmpegCL = String.Format("-i {0} -y -vn {1} -f wav - ", INPUT, FFmpegOpts);
- tbResult.AppendText("FFmpeg " + FFmpegCL + "\r\n\r\n");
- System.Diagnostics.ProcessStartInfo FFmpegPSI = new System.Diagnostics.ProcessStartInfo(Coder.FullName("FFmpeg"), FFmpegCL);
- FFmpegPSI.UseShellExecute = false;
- FFmpegPSI.Arguments = FFmpegCL;
- FFmpegPSI.CreateNoWindow = true;
- FFmpegPSI.RedirectStandardOutput = true;
- FFmpegPSI.RedirectStandardError = true;
-
- Decoder.StartInfo = FFmpegPSI;
- Decoder.Exited += new EventHandler(Decoder_Exited);
- Decoder.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(Decoder_ErrorDataReceived);
- Decoder.Start();
-
- DecoderOutputRaw = new System.IO.BinaryWriter(AS);
- Decoder.BeginErrorReadLine();
- Decoder.StandardOutput.BaseStream.BeginRead(ReadBuffer, 0, ReadBuffer.Length, new AsyncCallback(ReadCallBack), null);
- }
- private void ReadCallBack(IAsyncResult asyncResult)
- {
- int read = Decoder.StandardOutput.BaseStream.EndRead(asyncResult);
- if (read > 0)
- {
- EncoderRawInput.Write(ReadBuffer);
- EncoderRawInput.Flush();
- DecoderOutputRaw.Write(ReadBuffer);
- DecoderOutputRaw.Flush();
- Decoder.StandardOutput.BaseStream.Flush();
- Decoder.StandardOutput.BaseStream.BeginRead(ReadBuffer, 0, ReadBuffer.Length, new AsyncCallback(ReadCallBack), null);
- }
- else
- {
- Decoder.StandardOutput.BaseStream.Close();
- DecoderOutputRaw.Close();
- EncoderRawInput.Close();
- }
- }
-
- private void Decoder_Exited(object sender, System.EventArgs e)
- {
- Console.WriteLine("Exit");
- }
- private void Decoder_ErrorDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs errLine)
- {
- Console.WriteLine("Error");
- if (String.IsNullOrEmpty(errLine.Data)) return;
- this.Invoke(new MethodInvoker(() =>
- {
- tbResult.AppendText(errLine.Data + "\r\n");
- }));
- }
-
- public void AudioEncoding()
- {
- //Encoder Settings
- string EncoderFullName = Coder.FullName("qaac");
- string Input = "-";
- string Output = "-o" + ' ' + '"' + tbOutputPath.Text + "\\Test.aac" + '"';
- string Opts = "-q 2 --tvbr 100 --ignorelength";
- string EncoderCL = String.Format("{0} {2} {1}", Input, Output, Opts);
- System.Diagnostics.ProcessStartInfo EncoderPSI = new System.Diagnostics.ProcessStartInfo(EncoderFullName);
- EncoderPSI.UseShellExecute = false;
- EncoderPSI.Arguments = EncoderCL;
- EncoderPSI.CreateNoWindow = false;
- EncoderPSI.RedirectStandardInput = true;
- EncoderPSI.RedirectStandardError = false;
- Encoder.StartInfo = EncoderPSI;
- Encoder.Start();
- EncoderRawInput = new System.IO.BinaryWriter(Encoder.StandardInput.BaseStream);
- }
複製代碼 經過 pipe 後 聲道 Layout 完全亂掉
雖然可以在 qaac 內指定 輸入RAW 的 Layout
但其他的 Encoder 則不一定有這項能,neroAacEnc 似乎就沒有
求各位前輩賜教
|
|