用摄象头录制的视频太大了,想写程序压缩下传输到服务器,然后再解压缩播放.有相关源码参考吗?谢谢.
解决方案 »
- 还需要什么,ViewStateDecode!
- 正则表达式问题
- c#操作cmd时,怎么向其中输入Ctrl+C组合键
- 关于修改dataGridView中一个数据问题
- C#中如何获取listbox中选中的文本值???急!!!!
- Wince FTP WinAPI 大放送
- 求一段清除所有Temporary Internet Files 的c#代码!!!!!
- winform获取所有控件遇到toolStrip怎么办
- c#和jscript
- .NET 找不到 System.DirectoryServices 这个 namespace 咋办?
- 请问,这个ListView添加子项为什么不正确
- c# 如何获取网页的内容而非此网页的源代码 (特急)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
using System.IO;public partial class Admin_UpLoad : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack) return;
}
protected void Button_UpLoad_Click(object sender, EventArgs e)
{
if (InputFile1.ContentLength > 0)
{
try
{
string User_name = Context.User.Identity.Name;
string ExtenName = System.IO.Path.GetExtension(this.InputFile1.FileName);//获取扩展名
string temp = DateTime.Now.ToString("yyyy-MM-dd-HHmmssfff");
//合并两个路径为上传到服务器上的全路径
string SaveFileName = System.IO.Path.Combine
(System.Web.HttpContext.Current.Request.MapPath("../uploads/UpLoadFiles/Admin"), temp + ExtenName);
//文件保存的路径
string url = "";
if (DropDownList1.SelectedItem.Text == "视频教程")
{
url = "uploads/UpLoadFiles/Admin/" + temp + ".flv";
if (ExtenName == ".flv")
{
InputFile1.MoveTo(Server.MapPath("~/"+url), Brettle.Web.NeatUpload.MoveToOptions.Overwrite);
}
else
{
string tempurl = Server.MapPath("~/uploads/UpLoadFiles/Admin/temp/1.a");
InputFile1.MoveTo(tempurl, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);
MEConvertVideo(tempurl, Server.MapPath("~/"+url));
}
}
else
{
url = "uploads/UpLoadFiles/Admin/" + temp + ExtenName;
InputFile1.MoveTo(SaveFileName, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);
}
//获取文件大小并保留小数点后一位,单位是M
float FileSize = (float)System.Math.Round((float)InputFile1.ContentLength / 1024 / 1024, 3); string FileSize1 = FileSize.ToString("f3");//fN 保留N位,四舍五入
DBClass db = new DBClass();
db.Conn.Open();
db.Comm.Connection = db.Conn;
db.Comm.CommandText = "INSERT INTO tFiles (FileName,FileSize,FileUpLoadtime,Fileinfo,FileUpLoadMan,FileRelativelyPath,FileClassID) VALUES" +
"(@FileName,@FileSize,@FileUpLoadtime,@Fileinfo,@FileUpLoadMan,@FileRelativelyPath,@FileClassID)";
db.Comm.Parameters.AddWithValue("@FileName", TextBox_title.Text);
db.Comm.Parameters.AddWithValue("@FileSize", FileSize1);
db.Comm.Parameters.AddWithValue("@FileUpLoadtime", DateTime.Now.ToString());
db.Comm.Parameters.AddWithValue("@Fileinfo", TextBox_information.Text);
db.Comm.Parameters.AddWithValue("@FileUpLoadMan", User_name);
db.Comm.Parameters.AddWithValue("@FileRelativelyPath", url);
db.Comm.Parameters.AddWithValue("@FileClassID", DropDownList1.SelectedValue);
db.Comm.ExecuteNonQuery();
Response.Write("<script language=javascript>alert('上传成功');</script>");
}
catch (Exception ex)
{
Response.Write("<script language=javascript>alert('"+ex.Message+"');</script>");
} }
} public void MEConvertVideo(string vFileName, string playFile)
{
string tool = Server.MapPath("~/Tool/mencoder/mencoder.exe");
if ((!System.IO.File.Exists(tool)) || (!System.IO.File.Exists(vFileName)))
{
return;
}
System.Diagnostics.ProcessStartInfo FilestartInfo = new System.Diagnostics.ProcessStartInfo(tool);
FilestartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
FilestartInfo.Arguments = " " + vFileName + " -o " + playFile + " -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=200:mbd=2:mv0:trell:v4mv:cbp:last_pred=1:dia=-1:cmp=0:vb_strategy=1 -vf scale=320:240 -ofps 12 -srate 22050";
//FilestartInfo.Arguments = " -vf scale=320:240 -ffourcc FLV1 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -ovc lavc -lavcopts vcodec=flv:vbitrate=200 -srate 22050 -oac lavc -lavcopts acodec=mp3:abitrate=56 " + vFileName + " -o " + playFile;
System.Diagnostics.Process.Start(FilestartInfo);
}
}