首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

哇啦的,FLV视频截图老是搞不好

2013-12-13 
哇哇的,FLV视频截图老是搞不好。本帖最后由 woyaodubo 于 2013-12-10 13:04:02 编辑protected void bntup_C

哇哇的,FLV视频截图老是搞不好。
本帖最后由 woyaodubo 于 2013-12-10 13:04:02 编辑

        protected void bntup_Click(object sender, EventArgs e)
        {
            string getdatetime = DateTime.Now.ToString("yyMMddHHmmssfff");
            string fileName = "Teacher\\Video\" + getdatetime + System.IO.Path.GetExtension(uploadfile.FileName);
            string sql = "insert into Video(Video_Name,Video_Path,Video_PostDate,TeacherName,College,Profession,Subject,Is_Rec,Is_Top) values('" + this.uploadfile.FileName + "','" + getdatetime + System.IO.Path.GetExtension(uploadfile.FileName) + "','" + DateTime.Now.ToString("yy/MM/dd HH:mm") + "','" + Session["UserName"].ToString() + "','" + this.DropDownList_college.SelectedValue + "','" + this.DropDownList_profession.SelectedValue + "','" + this.DropDownList_subject.SelectedValue + "','" + cbox + "','" + cbox2 + "')";

            string filePath = uploadfile.PostedFile.FileName;
            string fileExt = filePath.Substring(filePath.LastIndexOf(".") + 1);
            if (uploadfile.FileName != "")
            {
                if (fileExt.ToLower() == "rmvb" || fileExt.ToLower() == "wmv" || fileExt.ToLower() == "swf" || fileExt.ToLower() == "flv")
                {
                    string playFile = "Teacher/playFile/" + getdatetime + ".flv"; //playFile *1*
                    string videoImg = "Teacher/videoImg/" + getdatetime + ".jpg";
                    if (fileExt.ToLower() == "flv")
                    {
                        bool add = mydata.ExceSQL(sql);  //不能放到if外面,否则即使不能上传文件,但数据库仍然会插入记录。
                        if (add)
                        {
                            uploadfile.SaveAs(Server.MapPath("~/" + fileName));//
                            File.Copy(uploadfile.PostedFile.FileName, Server.MapPath("../" + playFile));//复制一份到playFile *1*
                            bool ok = catchImg(Server.MapPath("../" + playFile), Server.MapPath("../" + videoImg));

                            if (ok)
                            {

                                Response.Write("<script language=javascript>alert('上传成功');</script>");
                                this.CheckBox1.Checked = false;
                                this.CheckBox2.Checked = false;
                            }
                            else
                            {


                                Response.Write("<script language=javascript>alert('视频截图失败!');</script>");
                            }
                        }
                    }
                }

                else
                {
                    Response.Write("<script language=javascript>alert('只能上传后缀为rmvb,wmv,swf,flv的视频文件!');</script>");
                    this.CheckBox1.Checked = false;
                    this.CheckBox2.Checked = false;

                }
            }
            else
            {
                Response.Write("<script language=javascript>alert('请选择视频文件!');</script>");
                this.CheckBox1.Checked = false;
                this.CheckBox2.Checked = false;
            }
        }









        //获取转换工具路径
        public static string ffmpegtool = "tool/ffmpeg.exe";
        //视频截图大小
        public static string sizeOfImg = "240x180";
        public static bool catchImg(string fileName, string imgFile)
        {
            //获取截图工具路径
            string ffmpeg = System.Web.HttpContext.Current.Server.MapPath("../") + ffmpegtool;
            Process pss = new Process();
            //设置启动程序的路径
            pss.StartInfo.FileName = ffmpeg;
            pss.StartInfo.Arguments = "   -i   " + fileName + "  -y  -f  image2   -ss 2 -vframes 1  -s   " + sizeOfImg + "   " + imgFile;
            //启动进程
            pss.Start();

            return true;
        }



[解决办法]
弹出上传成功,就是说errormsg是""吧?
你为什么说 弹出上传成功 errormsg就是""
我看你代码只要是没报错都是返回ture啊,所以你为什么说errormsg是“”;
errormsg是把错误信息保存到这里,但整个执行过程中不会抛异常

热点排行