62,243
社区成员




public string ChangeFilePhy(string fileName, string playFile, string imgFile)
{
//取得ffmpeg.exe的路径,路径配置在Web.Config中,如:<add key="ffmpeg" value="E:\51aspx\ffmpeg.exe" />
string ffmpeg = Server.MapPath(PublicMethod.ffmpegtool);
if ((!System.IO.File.Exists(ffmpeg)) || (!System.IO.File.Exists(fileName)))
{
return "";
}
//获得图片和(.flv)文件相对路径/最后存储到数据库的路径,如:/Web/User1/00001.jpg
string flv_file = System.IO.Path.ChangeExtension(playFile, ".flv");
//截图的尺寸大小,配置在Web.Config中,如:<add key="CatchFlvImgSize" value="240x180" />
string FlvImgSize = PublicMethod.sizeOfImg;
System.Diagnostics.ProcessStartInfo FilestartInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
FilestartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
FilestartInfo.Arguments = " -i " + fileName + " -ab 56 -ar 22050 -b 500 -r 15 -s " + widthOfFile + "x" + heightOfFile + " " + flv_file;
//ImgstartInfo.Arguments = " -i " + fileName + " -y -f image2 -t 0.05 -s " + FlvImgSize + " " + flv_img;
FilestartInfo.UseShellExecute = false;
FilestartInfo.CreateNoWindow = true;
try
{
//转换
System.Diagnostics.Process.Start(FilestartInfo);
//截图
CatchImg(fileName, imgFile);
}
catch
{
return "";
}
return "";
}
// MP3转换amr
this.StartProcess(
Path.Combine(this.converterPath, "ffmpeg.exe"),
string.Format(@"-i {0} -ac 1 -ar 8000 -ab 7950 -y {1}",
args.Mp3FileFullName,
args.AmrFileFullName));
// 压缩MP3
this.StartProcess(
Path.Combine(this.compressPath, "ffmpeg.exe"),
string.Format(@"-i {0} -ac 1 -ar 8000 -ab 7950 -y {1}",
args.Mp3FileFullName, args.Mp3FileCompressName));
private void StartProcess(string fileName, string args)
{
Process process = Process.Start(new ProcessStartInfo
{
FileName = fileName,
Arguments = args,
UseShellExecute = false,
RedirectStandardInput = false,
RedirectStandardOutput = false,
CreateNoWindow = true
});
process.WaitForExit();
process.Close();
}