日期:2014-05-17 浏览次数:20569 次
using System; using System.Configuration; public class PublicMethod:System.Web.UI.Page { public PublicMethod() { } //文件路径 public static string ffmpegtool = "ffmpeg/ffmpeg.exe"; public static string mencodertool = "mencoder/mencoder.exe"; public static string flvtool = "flvtool/flvtool2.exe"; //flv标记工具 public static string upFile = "UpFiles" + "/"; //上传文件夹 public static string imgFile = "ImgFile" + "/"; //图片文件夹 public static string playFile = "PlayFiles" + "/"; //flv文件夹 public static string xmlFile = "xmlFiles" + "/"; //xml文件夹 public static string sizeOfImg = "240x180"; //图片的宽与高 public static string widthOfFile = "400"; //flv文件的宽度 public static string heightOfFile = "350"; //flv文件的高度 //public static string ffmpegtool = ConfigurationManager.AppSettings["ffmpeg"]; //public static string mencodertool = ConfigurationManager.AppSettings["mencoder"]; //public static string upFile = ConfigurationManager.AppSettings["upfile"] + "/"; //public static string imgFile = ConfigurationManager.AppSettings["imgfile"] + "/"; //public static string playFile = ConfigurationManager.AppSettings["playfile"] + "/"; //文件图片大小 //public static string sizeOfImg = ConfigurationManager.AppSettings["CatchFlvImgSize"]; //文件大小 //public static string widthOfFile = ConfigurationManager.AppSettings["widthSize"]; //public static string heightOfFile = ConfigurationManager.AppSettings["heightSize"]; // // //获取文件的名字 private System.Timers.Timer myTimer = new System.Timers.Timer(3000);//记时器 public static string flvName = ""; public static string imgName = ""; public static string flvXml = ""; public static int pId = 0; public static string GetFileName(string fileName) { int i = fileName.LastIndexOf("\\") + 1; string Name = fileName.Substring(i); return Name; } //获取文件扩展名 public static string GetExtension(string fileName) { int i = fileName.LastIndexOf(".")+1; string Name = fileName.Substring(i); return Name; } // #region //运行FFMpeg的视频解码,(这里是绝对路径) /// <summary> /// 转换文件并保存在指定文件夹下面(这里是绝对路径) /// </summary> /// <param name="fileName">上传视频文件的路径(原文件)</param> /// <param name="playFile">转换后的文件的路径(网络播放文件)</param> /// <param name="imgFile">从视频文件中抓取的图片路径</param> /// <returns>成功:返回图片虚拟地址; 失败:返回空字符串</returns> public void ChangeFilePhy(string fileName, string playFile, string imgFile) { //取得ffmpeg.exe的路径,路径配置在Web.Config中,如:<add key="ffmpeg" value="E:\aspx1\ffmpeg.exe" /> string ffmpeg = Server.MapPath(