分享

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

 悟静 2013-03-09

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

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多