c#利用lame.exe实现mp3编码

参考:VB.NET LameMP3 Shell 1.c#调用非c#编写的EXE:Process   引用空间: System.Diagnostics;   process.StartInfo.FileName="lame.exe";  //设置要启动的应用程序   process.StartInfo.Arguments=" -h --abr 128  test.wav  testO
摘要由CSDN通过智能技术生成

参考:VB.NET LameMP3 Shell

1.c#调用非c#编写的EXE:Process

   引用空间: System.Diagnostics;

   process.StartInfo.FileName="lame.exe";  //设置要启动的应用程序

   process.StartInfo.Arguments=" -h --abr 128  test.wav  testOut.mp3 ";//设置启动应用程序时的命令行参数

2.正则表达式匹配lame.exe输出的信息

   引用空间:System.Text.RegularExpressions;

   @"(/d+)/(/d+)/D+(/d+)/D+([/d:]+)/D+([/d:]+)/D+([/d:]+)/D+([/d:]+)/D+([/d/.]+)/D+([/d:]+)"

3.事件、委托、线程

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Text.RegularExpressions;
  5. using System.Diagnostics ;
  6. using System.Threading ;
  7. using System.Windows.Forms;
  8. namespace CSharpShell
  9. {
  10.     public delegate void eventDone();
  11.     public delegate void eventProgress(LameProgress Progress);
  12.     public delegate void eventIgnoredLine(string Line);
  13.     public delegate void eventCanceled();
  14.     public class Shell
  15.     {
  16.         private Process _lameProcess = new Process();
  17.         private Thread _lameThread;
  18.         private int _percentDone;
  19.         private bool _isRunning = false;
  20.         private ProcessStartInfo _startInfo = new ProcessStartInfo();
  21.         private Regex _regLine=new Regex (@"(/d+)/(/d+)/D+(/d+)/D+([/d:]+)/D+([/d:]+)/D+([/d:]+)/D+([/d:]+)/D+([/d/.]+)/D+([/d:]+)", RegexOptions.IgnoreCase 
  22.                 | RegexOptions.CultureInvariant 
  23.                 | RegexOptions.IgnorePatternWhitespace 
  24.                 | RegexOptions.Compiled );
  25.      
  26.         private string _inFile;
  27.         private string _outFile;
  28.         private string _options;
  29.         public event eventDone Done;
  30.         public event eventProgress Progress;
  31.         public event eventIgnoredLine IgnoredLine;
  32.         public event eventCanceled Canceled;
  33.         public Shell()
  34.         {
  35.             DefStartInfo();
  36.             _startInfo.WorkingDirectory = Application.StartupPath;
  37.         }
  38.         public Shell(string InFile, string OutFile, string LamePath, string Options)
  39.         {
  40.             DefStartInfo();
  41.             if (string.IsNullOrEmpty(LamePath))
  42.                 _startIn
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值