ffmpeg.exe与mencoder.exe实例转换操作

using System.Diagnostics;


string ffmpegPath = Configure.ffmpegPath();              //ffmpeg.exe文件所在位置
string mencoderPath = Configure.mencoderPath();    //mencoder.exe文件所在位置

 

string orginalFile = strBaseLocation + @"old/" + fileName;   //转换前文件所在全路径
string targetFile = strBaseLocation + itemID + ".flv";           //转换后文件所在全路径

 

string argu = "";
if(fileName.ToUpper().EndsWith(".FLV"))  //不同文件类型使用不同转换参数


                argu = "-i /"" + orginalFile + "/" -ab 56 -ar 22050 -b 500 -r 15 -s 500x350 /"" + targetFile + "/"";

else if (fileName.ToUpper().EndsWith(".WMV"))


                argu = @"-ffourcc FLV1 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -of lavf -oac mp3lame -lameopts aq=9:cbr:br=64:vol=2 -ovc lavc -lavcopts vcodec=flv:vbitrate=300:acodec=mp3:abitrate=56 -vf scale=320:290,expand=320:290:::1,crop=320:290:0:0 -ofps 18 -srate 22050 " + orginalFile + " -o " + targetFile;

else if (fileName.ToUpper().EndsWith(".AVI"))


                argu = "-i " + orginalFile + " -f flv -vcodec flv -ab 56 -ar 22050 -b 100 -r 15 -s 500x350 -qscale 7 " + targetFile;

 

//根据不同类型的文件进行不同的转换

if (!fileName.ToUpper().EndsWith(".FLV"))

{
        if (fileName.ToUpper().EndsWith(".WMV"))    //利用mencoder.exe将wmv文件转换成flv文件
        {                       
                        System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(mencoderPath, argu);
                        startInfo.WindowStyle = ProcessWindowStyle.Hidden;

                        System.Diagnostics.Process.Start(startInfo);
        }

        if (fileName.ToUpper().EndsWith(".AVI"))     //利用ffmpeg.exe将avi文件转换成flv文件
        {
                        System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(ffmpegPath, argu);
                        startInfo.WindowStyle = ProcessWindowStyle.Hidden;

                        System.Diagnostics.Process.Start(startInfo);    //隐藏dos转换页面
       }
}

else
{
         System.IO.File.Copy(orginalFile, targetFile);
}

 

if (System.IO.File.Exists(targetFile) && (new System.IO.FileInfo(targetFile)).Length > 10000)
{
       return "成功";

}
else

{

      return "失败";

}

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值