跨机器的视频录制(ASP.net+FMS)

  根据项目进展需要,我以前做的视频录制的程序(asp.net1.1+Ajaxpro)要部署到内部服务器上,并且程序转化为asp.net2.0+atlas,并架在两个机器上,WEB服务器+FMS。那面临的问题是视频缩略放在哪台服务器上,当然是放在WEB上最好了。
   我决定在FMS上开webservice来解决两太机器协作问题:
 
ContractedBlock.gif ExpandedBlockStart.gif webservice代码
  1None.gifusing System;
  2None.gifusing System.Web;
  3None.gifusing System.Collections;
  4None.gifusing System.Web.Services;
  5None.gifusing System.Web.Services.Protocols;
  6None.gifusing System.Data;
  7None.gifusing System.Data.SqlClient;
  8None.gifusing System.IO;
  9None.gifusing System.Text;
 10None.gifusing System.Configuration;
 11None.gifusing System.Drawing;
 12None.gif
 13None.gif
 14ExpandedBlockStart.gifContractedBlock.gif/**//// <summary>
 15InBlock.gif/// 生成图片 下载 视频上传 生成图片 格式转换
 16ExpandedBlockEnd.gif/// </summary>

 17None.gif[WebService(Namespace = "http://tempuri.org/")]
 18None.gif[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
 19ExpandedBlockStart.gifContractedBlock.gifpublic class WsVideo : System.Web.Services.WebService dot.gif{
 20InBlock.gif
 21InBlock.gif    private string fname;
 22InBlock.gif    private string fpath;
 23InBlock.gif
 24InBlock.gif    public WsVideo()
 25ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 26InBlock.gif        //如果使用设计的组件,请取消注释以下行 
 27InBlock.gif        //InitializeComponent(); 
 28ExpandedSubBlockEnd.gif    }

 29InBlock.gif    [WebMethod]
 30InBlock.gif    public string nn()
 31ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 32InBlock.gif        return fname;
 33ExpandedSubBlockEnd.gif    }

 34ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
 35InBlock.gif    /// 用ffmpeg.exe生成缩略图
 36InBlock.gif    /// </summary>
 37InBlock.gif    /// <param name="flvName"></param>
 38ExpandedSubBlockEnd.gif    /// <returns></returns>

 39InBlock.gif    [WebMethod]
 40InBlock.gif    public string flvImage(string na, string pa)
 41ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 42InBlock.gif        fname = na;
 43InBlock.gif        fpath = pa;
 44InBlock.gif        string flvName = fpath + "\\" + fname;
 45InBlock.gif        flvName = @"C:\Program Files\Macromedia\Flash Media Server 2\applications\record\streams\_definst_\"
 46InBlock.gif            + flvName + ".flv";
 47InBlock.gif        string ffmpeg = @"ffmpeg\ffmpeg.exe";
 48InBlock.gif        ffmpeg = Server.MapPath(ffmpeg);
 49InBlock.gif        if (!File.Exists(ffmpeg))
 50ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 51InBlock.gif            return "ffmpeg not found!";
 52ExpandedSubBlockEnd.gif        }

 53InBlock.gif        if (!File.Exists(flvName))
 54ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 55InBlock.gif            return "flvimg not found";
 56ExpandedSubBlockEnd.gif        }

 57InBlock.gif
 58ExpandedSubBlockStart.gifContractedSubBlock.gif        /**/////改变后缀名 和相对路径  存入数据库的路径名
 59InBlock.gif        //string flvImg = Path.ChangeExtension(flvName, ".jpg");
 60InBlock.gif        //flvImg = flvImg.Substring(flvImg.LastIndexOf('\\') + 1);
 61InBlock.gif
 62InBlock.gif        //图片绝对路径
 63InBlock.gif        string PathFlvImg = Server.MapPath(@"flvImg\" + fname + ".jpg");
 64InBlock.gif
 65InBlock.gif        //截图的尺寸大小
 66InBlock.gif        string FlvImgSize = "120*90";
 67InBlock.gif
 68InBlock.gif        System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
 69InBlock.gif        startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
 70InBlock.gif
 71InBlock.gif        //ffmpeg.exe文件需要的参数
 72InBlock.gif        startInfo.Arguments = " -i \"" + flvName + "\" -y -f image2 -t 1 -s " + FlvImgSize + " \"" + PathFlvImg + "\"";
 73InBlock.gif
 74InBlock.gif        try
 75ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 76InBlock.gif            System.Diagnostics.Process.Start(startInfo);
 77ExpandedSubBlockEnd.gif        }

 78InBlock.gif        catch
 79ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 80InBlock.gif            return "false";
 81ExpandedSubBlockEnd.gif        }

 82InBlock.gif        return "true";
 83ExpandedSubBlockEnd.gif    }

 84ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
 85InBlock.gif    /// 查看缩略图是否已经生成
 86InBlock.gif    /// </summary>
 87InBlock.gif    /// <param name="flvName"></param>
 88ExpandedSubBlockEnd.gif    /// <returns></returns>

 89InBlock.gif    [WebMethod]
 90InBlock.gif    public bool ExistsImage(string na)
 91ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 92InBlock.gif        if (File.Exists(Server.MapPath(@"flvImg\" + na + ".jpg")))
 93ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 94InBlock.gif            return true;
 95ExpandedSubBlockEnd.gif        }

 96InBlock.gif        return false;
 97ExpandedSubBlockEnd.gif    }

 98ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
 99InBlock.gif    /// 图片二进制数组
100InBlock.gif    /// </summary>
101InBlock.gif    /// <param name="flvName"></param>
102ExpandedSubBlockEnd.gif    /// <returns></returns>

103InBlock.gif    [WebMethod]
104InBlock.gif    public byte[] ImageByte(string na)
105ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
106InBlock.gif        string file = Server.MapPath(@"flvImg\" + na + ".jpg");
107InBlock.gif        if (File.Exists(file))
108ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
109InBlock.gif            try
110ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
111InBlock.gif                FileStream s = File.OpenRead(file);
112InBlock.gif                return ConvertStreamToByteBuffer(s);
113ExpandedSubBlockEnd.gif            }

114InBlock.gif            catch
115ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
116InBlock.gif                return new byte[0];
117ExpandedSubBlockEnd.gif            }

118ExpandedSubBlockEnd.gif        }

119InBlock.gif        else
120ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
121InBlock.gif            return new byte[0];
122ExpandedSubBlockEnd.gif        }
        
123ExpandedSubBlockEnd.gif    }

124ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
125InBlock.gif    /// ConvertStreamToByteBuffer:把给定的文件流转换为二进制字节数组。
126InBlock.gif    /// </summary>
127InBlock.gif    /// <param name="theStream"></param>
128ExpandedSubBlockEnd.gif    /// <returns></returns>

129InBlock.gif    public byte[] ConvertStreamToByteBuffer(System.IO.Stream theStream)
130ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
131InBlock.gif        int b1;
132InBlock.gif        System.IO.MemoryStream tempStream = new System.IO.MemoryStream();
133InBlock.gif        while ((b1 = theStream.ReadByte()) != -1)
134ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
135InBlock.gif            tempStream.WriteByte(((byte)b1));
136ExpandedSubBlockEnd.gif        }

137InBlock.gif        return tempStream.ToArray();
138InBlock.gif

这里工具还是以前选择的ffmpeg.exe来生成缩略图  这里放在了项目根目录ffmpeg\文件夹下
继续处理web程序 是在录制成功后跳转的页面 用到了timer控件
ContractedBlock.gif ExpandedBlockStart.gif
  1ExpandedBlockStart.gifContractedBlock.gif<%dot.gif@ Page Language="C#" AutoEventWireup="true" CodeFile="VideoInf.aspx.cs" Inherits="_Default" Async="true" %>
  2None.gif
  3None.gif<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  4None.gif<html xmlns="http://www.w3.org/1999/xhtml">
  5None.gif<head runat="server">
  6None.gif    <title>第二步:填写视频相关信息</title>
  7ExpandedBlockStart.gifContractedBlock.gif    <style type="text/css">dot.gif
  8InBlock.gif    .table1
  9ExpandedSubBlockStart.gifContractedSubBlock.gif{dot.gif}{
 10InBlock.gif    BORDER-RIGHT: #62d9ff 1px solid;
 11InBlock.gif    BORDER-TOP: #62d9ff 1px solid; 
 12InBlock.gif    FONT-SIZE: 14px; 
 13InBlock.gif    BORDER-LEFT: #62d9ff 1px solid; 
 14InBlock.gif    COLOR: #333366; 
 15InBlock.gif    BORDER-BOTTOM: #62d9ff 1px solid;
 16InBlock.gif    border-top-width: 1px;
 17InBlock.gif    border-right-width: 1px;
 18InBlock.gif    border-bottom-width: 1px;
 19InBlock.gif    border-left-width: 1px;
 20InBlock.gif    TABLE-LAYOUT:fixed; 
 21ExpandedSubBlockEnd.gif}

 22InBlock.gif.tdbg1
 23ExpandedSubBlockStart.gifContractedSubBlock.gif{dot.gif}{
 24InBlock.giffont-weight: bold; font-size: 14px; color: #000066; background-color: #33ccff;
 25ExpandedSubBlockEnd.gif}

 26InBlock.gif.input1
 27ExpandedSubBlockStart.gifContractedSubBlock.gif{dot.gif}{
 28InBlock.gif    BORDER-RIGHT: #000099 1px solid; 
 29InBlock.gif    BORDER-TOP: #000099 1px solid; 
 30InBlock.gif    FONT-SIZE: 14px;
 31InBlock.gif    BORDER-LEFT: #000099 1px solid; 
 32InBlock.gif    WIDTH: 235px; COLOR: #330066; 
 33InBlock.gif    BORDER-BOTTOM: #000099 1px solid; 
 34InBlock.gif    BACKGROUND-COLOR: #fff8f0;
 35InBlock.gif    border-top-width: 1px;
 36InBlock.gif    border-right-width: 1px;
 37InBlock.gif    border-bottom-width: 1px;
 38InBlock.gif    border-left-width: 1px;
 39ExpandedSubBlockEnd.gif}

 40InBlock.gif.txtArea
 41ExpandedSubBlockStart.gifContractedSubBlock.gif{dot.gif}{
 42InBlock.gif    overflow:visible;
 43InBlock.gif    BORDER-RIGHT: #000099 1px solid; 
 44InBlock.gif    BORDER-TOP: #000099 1px solid; 
 45InBlock.gif    FONT-SIZE: 14px;
 46InBlock.gif    BORDER-LEFT: #000099 1px solid; 
 47InBlock.gif    WIDTH: 235px; COLOR: #330066; 
 48InBlock.gif    BORDER-BOTTOM: #000099 1px solid; 
 49InBlock.gif    HEIGHT: 25px; 
 50InBlock.gif    BACKGROUND-COLOR: #fff8f0;
 51InBlock.gif    border-top-width: 1px;
 52InBlock.gif    border-right-width: 1px;
 53InBlock.gif    border-bottom-width: 1px;
 54InBlock.gif    border-left-width: 1px;
 55ExpandedSubBlockEnd.gif}

 56ExpandedBlockEnd.gif    
</style>
 57None.gif</head>
 58None.gif<body>
 59None.gif    <form id="form1" runat="server">
 60None.gif        <asp:ScriptManager ID="ScriptManager1" runat="server" />
 61None.gif        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
 62None.gif            <ContentTemplate>
 63None.gif                <asp:Timer ID="Timer1" runat="server" Interval="500" OnTick="Timer1_Tick">
 64None.gif                </asp:Timer>
 65None.gif                <asp:Panel ID="Panel1" runat="server">
 66None.gif                <table class="table1" id="Table1" style="WIDTH: 163px; HEIGHT: 32px">
 67None.gif                <tr>
 68None.gif                    <td id="load" align="center"><img alt="loading" src="img/load.gif">
 69None.gif                        <asp:Label ID="msg" runat="server" Text="正在处理,请稍候!"></asp:Label></td>
 70None.gif                </tr>
 71None.gif                </table>
 72None.gif                </asp:Panel>
 73None.gif                <asp:Panel ID="Panel2" runat="server">
 74None.gif                <div class="tdbg1" style="WIDTH:561px;height:20px">
 75None.gif                    第二步:填写视频相关信息</div>
 76None.gif                <table class="table1" style="WIDTH:550px" cellspacing="3" cellpadding="0" border="0">
 77None.gif                <tr><td style="width: 100px;">
 78None.gif                    视频缩略图</td>
 79None.gif                <td style="width: 450px;">
 80None.gif                    <asp:Image ID="Image1" runat="server" /></td>
 81None.gif                </tr>
 82None.gif                <tr><td>
 83None.gif                    视频标题</td>
 84None.gif                <td>
 85None.gif                    <asp:TextBox ID="tbTitle" runat="server" Width="247px" CssClass="input1"></asp:TextBox></td>
 86None.gif                </tr>
 87None.gif                <tr><td>
 88None.gif                    tag/标签</td>
 89None.gif                <td style="height: 16px">
 90None.gif                    <asp:TextBox ID="tbTag" runat="server" Width="247px" CssClass="input1"></asp:TextBox></td>
 91None.gif                </tr>
 92None.gif                <tr><td>
 93None.gif                    视频分类</td>
 94None.gif                <td>
 95None.gif                    <asp:DropDownList ID="DropDownList1" runat="server" Width="63px">
 96None.gif                        <asp:ListItem>自拍</asp:ListItem>
 97None.gif                        <asp:ListItem>翻唱</asp:ListItem>
 98None.gif                        <asp:ListItem>生活</asp:ListItem>
 99None.gif                        <asp:ListItem>搞笑</asp:ListItem>
100None.gif                        <asp:ListItem>娱乐</asp:ListItem>
101None.gif                        <asp:ListItem>绝活</asp:ListItem>
102None.gif                        <asp:ListItem>广告</asp:ListItem>
103None.gif                        <asp:ListItem>舞秀</asp:ListItem>
104None.gif                        <asp:ListItem>游戏</asp:ListItem>
105None.gif                        <asp:ListItem>体育</asp:ListItem>
106None.gif                        <asp:ListItem>艺术</asp:ListItem>
107None.gif                        <asp:ListItem>综艺</asp:ListItem>
108None.gif                    </asp:DropDownList></td>
109None.gif                </tr>
110None.gif                <tr><td style="vertical-align: top">
111None.gif                    视频描述</td>
112None.gif                <td>
113None.gif                    <asp:TextBox CssClass="txtArea" ID="tbDisc" runat="server" Width="247px" TextMode="MultiLine"></asp:TextBox></td>
114None.gif                </tr>
115None.gif                    <tr>
116None.gif                        <td>
117None.gif                        </td>
118None.gif                        <td>
119None.gif                            <asp:Button ID="Button1" runat="server" Text="ok! 确定发布" OnClick="Button1_Click" /></td>
120None.gif                    </tr>
121None.gif                </table>
122None.gif                </asp:Panel>
123None.gif            </ContentTemplate>
124None.gif        </asp:UpdatePanel>
125None.gif    </form>
126None.gif</body>
127None.gif</html>

cs代码:
ContractedBlock.gif ExpandedBlockStart.gif
  1None.gifusing System;
  2None.gifusing System.Data;
  3None.gifusing System.Configuration;
  4None.gifusing System.Web;
  5None.gifusing System.Web.Security;
  6None.gifusing System.Web.UI;
  7None.gifusing System.Web.UI.WebControls;
  8None.gifusing System.Web.UI.WebControls.WebParts;
  9None.gifusing System.Web.UI.HtmlControls;
 10None.gifusing System.IO;
 11None.gif
 12None.gifpublic partial class _Default : System.Web.UI.Page 
 13ExpandedBlockStart.gifContractedBlock.gifdot.gif{
 14InBlock.gif    private fmss1.WsVideo fmsVideo = new fmss1.WsVideo();
 15InBlock.gif    string sqlcs = ConfigurationManager.ConnectionStrings["Ds10ConnectionString"].ToString();
 16InBlock.gif    
 17InBlock.gif    protected void Page_Load(object sender, EventArgs e)
 18ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 19InBlock.gif        if (!IsPostBack)
 20ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 21InBlock.gif            string path;
 22InBlock.gif            string fname;
 23InBlock.gif            Panel1.Visible = true;
 24InBlock.gif            Panel2.Visible = false;
 25InBlock.gif            try
 26ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 27InBlock.gif                path = Request.QueryString["pa"];
 28InBlock.gif                fname = Request.QueryString["na"];
 29ExpandedSubBlockEnd.gif            }

 30InBlock.gif            catch
 31ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 32InBlock.gif                msg.Text = "非法操作!";
 33InBlock.gif                Timer1.Visible = false;
 34InBlock.gif                return;
 35ExpandedSubBlockEnd.gif            }

 36InBlock.gif            if (CheckVideo(path, fname))
 37ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 38InBlock.gif                //异步操作webservice
 39InBlock.gif                fmsVideo.flvImageCompleted += new fmss1.flvImageCompletedEventHandler(flvImage_Finished);
 40InBlock.gif                fmsVideo.flvImageAsync(fname,path);
 41ExpandedSubBlockEnd.gif            }

 42InBlock.gif            else 
 43ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 44InBlock.gif                msg.Text = "不要重复操作!";
 45InBlock.gif                Timer1.Visible = false;
 46ExpandedSubBlockEnd.gif            }

 47ExpandedSubBlockEnd.gif        }

 48ExpandedSubBlockEnd.gif    }

 49InBlock.gif    protected void flvImage_Finished(object sender,fmss1.flvImageCompletedEventArgs e)
 50ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 51InBlock.gif        if (e.Result == "false")
 52ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 53InBlock.gif            System.Drawing.Image m = System.Drawing.Image.FromFile(Server.MapPath("flvImg\\失败.jpg"));
 54InBlock.gif            m.Save(Server.MapPath("flvImg\\" + Request.QueryString["na"+ ".jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
 55ExpandedSubBlockEnd.gif        }

 56InBlock.gif        else 
 57ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{            
 58InBlock.gif            while (!CreateImg())
 59ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 60InBlock.gif                System.Threading.Thread.Sleep(1000);
 61ExpandedSubBlockEnd.gif            }

 62ExpandedSubBlockEnd.gif        }

 63ExpandedSubBlockEnd.gif    }

 64InBlock.gif    protected void Button1_Click(object sender, EventArgs e)
 65ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 66InBlock.gif        int userID = 1;        //@@
 67InBlock.gif        string sql = "relVideo " + userID + ",'原创','" + DropDownList1.SelectedValue + "','" 
 68InBlock.gif            + tbTitle.Text + "','" +tbTag.Text + "','" + tbDisc.Text + "','"
 69InBlock.gif            + Request.QueryString["na"+ "','" + Request.QueryString["pa"+ "'";
 70InBlock.gif        MyCommonSQL Csql = new MyCommonSQL(sqlcs);
 71InBlock.gif        if (Csql.Return_exec_If(sql))
 72ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 73InBlock.gif            string script = "alert('录制成功,页面跳转!');window.location.replace('partyaddif.aspx?if=')";
 74InBlock.gif            Microsoft.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "click", script, true);
 75ExpandedSubBlockEnd.gif        }

 76ExpandedSubBlockEnd.gif    }

 77ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
 78InBlock.gif    /// timer的触发器
 79InBlock.gif    /// </summary>
 80InBlock.gif    /// <param name="sender"></param>
 81ExpandedSubBlockEnd.gif    /// <param name="e"></param>

 82InBlock.gif    protected void Timer1_Tick(object sender, EventArgs e)
 83ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 84InBlock.gif        if (File.Exists(Server.MapPath("flvImg\\" + Request.QueryString["na"+ ".jpg")))
 85ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 86InBlock.gif            Timer1.Visible = false;
 87InBlock.gif            Panel1.Visible = false;
 88InBlock.gif            Panel2.Visible = true;
 89InBlock.gif            Image1.ImageUrl = "flvImg/" + Request.QueryString["na"+ ".jpg";
 90ExpandedSubBlockEnd.gif        }

 91ExpandedSubBlockEnd.gif    }

 92ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
 93InBlock.gif    /// 查看数据库中是否存在
 94InBlock.gif    /// </summary>
 95InBlock.gif    /// <param name="pa"></param>
 96InBlock.gif    /// <param name="na"></param>
 97ExpandedSubBlockEnd.gif    /// <returns></returns>

 98InBlock.gif    private bool CheckVideo(string pa,string na)
 99ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
100InBlock.gif        MyCommonSQL Csql = new MyCommonSQL(sqlcs);
101InBlock.gif        string sql = "ExistsVideo '" + na + "','" + pa + "'";
102InBlock.gif        sql = Csql.Return_s(sql);
103InBlock.gif        if (sql != "0")
104ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
105InBlock.gif            return false;
106ExpandedSubBlockEnd.gif        }

107InBlock.gif        return true;
108ExpandedSubBlockEnd.gif    }

109ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
110InBlock.gif    /// 接收图片并生成
111InBlock.gif    /// </summary>
112ExpandedSubBlockEnd.gif    /// <returns></returns>

113InBlock.gif    private bool CreateImg()
114ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
115InBlock.gif        if (fmsVideo.ExistsImage(Request.QueryString["na"]))//检测图片在FMS上是否生成
116ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
117InBlock.gif            try
118ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
119ExpandedSubBlockStart.gifContractedSubBlock.gif                /**////定义并初始化文件对象;
120ExpandedSubBlockEnd.gif                ///得到二进制文件字节数组;

121InBlock.gif                byte[] image = fmsVideo.ImageByte(Request.QueryString["na"]);
122ExpandedSubBlockStart.gifContractedSubBlock.gif                /**////转换为支持存储区为内存的流
123InBlock.gif                System.IO.MemoryStream memStream = new System.IO.MemoryStream(image);
124InBlock.gif                System.Drawing.Image m = System.Drawing.Image.FromStream(memStream);
125ExpandedSubBlockStart.gifContractedSubBlock.gif                /**////保存
126InBlock.gif                m.Save(Server.MapPath("flvImg\\" + Request.QueryString["na"+ ".jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
127InBlock.gif                return true;
128ExpandedSubBlockEnd.gif            }

129InBlock.gif            catch
130ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
131InBlock.gif                System.Drawing.Image m = System.Drawing.Image.FromFile(Server.MapPath("flvImg\\失败.jpg"));
132InBlock.gif                m.Save(Server.MapPath("flvImg\\" + Request.QueryString["na"+ ".jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
133InBlock.gif                return true;
134ExpandedSubBlockEnd.gif            }

135ExpandedSubBlockEnd.gif        }

136InBlock.gif        return false;
137ExpandedSubBlockEnd.gif    }

138ExpandedBlockEnd.gif}

运行测试一下 图片成功生成
开始录制:
提交后页面在处理中:

视频缩略图生成后:

新Blog,第一贴  以后都在这里写。嘿嘿,写给自己看。

转载于:https://www.cnblogs.com/gugula/archive/2006/11/27/573917.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值