using System.Diagnostics;
string ffmpegPath = Configure.ffmpegPath(); //ffmpeg.exe文件所在位置
string mencoderPath = Configure.mencoderPath(); //mencoder.exe文件所在位置
string orginalFile = strBaseLocation + @"old/" + fileName; //轉(zhuǎn)換前文件所在全路徑
string targetFile = strBaseLocation + itemID + ".flv"; //轉(zhuǎn)換后文件所在全路徑
string argu = "";
if(fileName.ToUpper().EndsWith(".FLV")) //不同文件類型使用不同轉(zhuǎn)換參數(shù)
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;
//根據(jù)不同類型的文件進(jìn)行不同的轉(zhuǎn)換
if (!fileName.ToUpper().EndsWith(".FLV"))
{
if (fileName.ToUpper().EndsWith(".WMV")) //利用mencoder.exe將wmv文件轉(zhuǎn)換成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文件轉(zhuǎn)換成flv文件
{
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(ffmpegPath, argu);
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
System.Diagnostics.Process.Start(startInfo); //隱藏dos轉(zhuǎn)換頁(yè)面
}
}
else
{
System.IO.File.Copy(orginalFile, targetFile);
}
if (System.IO.File.Exists(targetFile) && (new System.IO.FileInfo(targetFile)).Length > 10000)
{
return "成功";
}
else
{
return "失敗";
}