asp.net中将各种视频文件转换成.flv格式
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-04-12
.Web.UI.Page { // 扩展名定义 string[] strArrFfmpeg = new string[] {"asf","avi","mpg","3gp","mov" }; string[] strArrMencoder = new string[] {"wmv","rm","rmvb" }; protected void Page_Load(object sender, EventArgs e) { } // protected void btnUpload_Click(object sender, EventArgs e) { string upFileName = ""; if (this.FileUpload1.HasFile) { string fileName = PublicMethod.GetFileName(this.FileUpload1.FileName);// GetFileName(); if ((string)Session["file"] == fileName) { return; } upFileName = Server.MapPath(PublicMethod.upFile + fileName); this.FileUpload1.SaveAs(upFileName); string saveName = DateTime.Now.ToString("yyyyMMddHHmmssffff") ; string playFile = Server.MapPath(PublicMethod.playFile + saveName); string imgFile = Server.MapPath(PublicMethod.imgFile + saveName); //System.IO.File.Copy(Server.MapPath(PublicMethod.playFile + "00000002.jpg"), Server.MapPath(PublicMethod.imgFile+"aa.jpg")); PublicMethod pm = new PublicMethod(); string m_strExtension = PublicMethod.GetExtension(this.FileUpload1.PostedFile.FileName).ToLower(); if (m_strExtension == "flv") {//直接拷贝到播放文件夹下 System.IO.File.Copy(upFileName, playFile+".flv"); pm.CatchImg(upFileName, imgFile); } string Extension = CheckExtension(m_strExtension); if (Extension == "ffmpeg") { pm.ChangeFilePhy(upFileName, playFile, imgFile); } else if (Extension == "mencoder") { pm.MChangeFilePhy(upFileName, playFile, imgFile); } InsertData(this.txtTitle.Text, fileName,saveName); Session["file"] = fileName; } } // private string CheckExtension(string extension) { string m_strReturn = ""; foreach (string var in this.strArrFfmpeg) { if (var == extension) { m_strReturn = "ffmpeg"; break; } } if (m_strReturn == "") { foreach (string var in strArrMencoder) { if (var == extension) { m_strReturn = "mencoder"; break; } } } return m_strReturn; } #region 插入数据到数据库中 private void InsertData(string MediaName,string fileName,string saveName) { //string name=fileName.Substring(0, fileName.LastIndexOf(''.'')); string imgName = saveName + ".jpg";//图片文件名; string playName = saveName + ".flv"; string sqlstr = "insert into Media(FMediaName,FMediaUpPath,FMediaPlayPath,FMediaImgPath) values(@MName,@MUppath,@MPlaypath,@MImgpath)"; //string constr = ConfigurationManager.ConnectionStrings["sqlcon"].ToString(); SqlDataSource1.InsertCommand = sqlstr; SqlDataSource1.InsertCommandType = SqlDataSourceCommandType.Text;// CommandType.Text; SqlDataSource1.InsertParameters.Add("MName",MediaName); SqlDataSource1.InsertParameters.Add("MUppath",PublicMethod.upFile+fileName); SqlDataSource1.InsertParameters.Add("MPlaypath",PublicMethod.playFile+playName); SqlDataSource1.InsertParameters.Add("MImgpath",PublicMethod.imgFile+imgNa |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于asp.net中将各种视频文件转换成.flv格式的所有评论