请问如何上传视频,并且更改视频的文件名,最后生成缩略图阿

cqxue 2007-06-20 01:10:36
请问各位adp.net中如何上传视频,最后生成缩略图啊。
能给个源代码吗?
...全文
952 20 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
my021010 2012-06-05
  • 打赏
  • 举报
回复
标记一下
xinqinglhj 2010-12-26
  • 打赏
  • 举报
回复
收藏
呵呵~!收益非浅
kzbbadboy 2007-11-19
  • 打赏
  • 举报
回复
收藏
yitian130 2007-09-20
  • 打赏
  • 举报
回复
呵呵~!收益非浅
zjysky 2007-09-10
  • 打赏
  • 举报
回复
上传视频难道不和上传文件一样啊。一样的道理。晕。
生成缩率图可以看一个方法
weir55 2007-09-10
  • 打赏
  • 举报
回复
用ffmpeg
weir55 2007-09-10
  • 打赏
  • 举报
回复
private void btAdd_Click(object sender, System.EventArgs e)
{
if(this.txtTitle.Text.Trim().Length ==0)
{
this.lblMsg.Text = "标题不能为空";
return;
}

string strBaseLocation = System.Configuration.ConfigurationSettings.AppSettings["TargetFolder"] ;
string filename = "";

if (null != uplTheFile.PostedFile && uplTheFile.PostedFile.ContentLength > 0 )
{
if(uplTheFile.PostedFile.ContentLength> 4 * 1024 * 1024)
{
lblMsg.Text = "文件大小超过4M!";
return;
}
System.IO.FileInfo fi = new System.IO.FileInfo(uplTheFile.PostedFile.FileName);
if(fi.Extension.ToLower() != ".avi" && fi.Extension.ToLower() != ".wmv" && fi.Extension.ToLower() != ".flv")
{
lblMsg.Text = "文件格式应为AVI, WMV, FLV视频! 现在格式为:" + fi.Extension.ToLower();
return;
}

filename = Guid.NewGuid().ToString() + fi.Name;

try
{
uplTheFile.PostedFile.SaveAs(strBaseLocation + @"old\" + filename);
}
catch (Exception ee)
{
throw ee;
}
}

string itemID = Framework.AddNewItem(this._userID,CMS.HandleString(this.txtTitle.Text),
CMS.HandleString(this.txtDesc.Text), CMS.HandleString(this.txtDesc.Text));

string fileName = System.Configuration.ConfigurationSettings.AppSettings["FFMpeg"];

string orginalFile = strBaseLocation + @"old\" + filename;
string targetFile = strBaseLocation + itemID + ".flv";
string argu = @"-i " + orginalFile + " -ab 56 -ar 22050 -b 500 -r 15 -s 480x360 " + targetFile;

try
{
if(! fileName.EndsWith(".flv"))
{
try
{
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(fileName,argu);
System.Diagnostics.Process.Start(startInfo);
}
catch
{
throw;
}

System.Threading.Thread.Sleep(6000);
}
else
{
System.IO.File.Copy(orginalFile, targetFile);
}

//picture
argu = @"-i " + targetFile + " -y -f image2 -ss 08.010 -t 0.001 -s 352x240 " + strBaseLocation + itemID + ".jpg";
System.Diagnostics.ProcessStartInfo startInfo1 = new System.Diagnostics.ProcessStartInfo(fileName,argu);
System.Diagnostics.Process.Start(startInfo1);
System.Threading.Thread.Sleep(2000);

if(! System.IO.File.Exists(strBaseLocation + itemID + ".jpg"))
{
System.IO.File.Copy(strBaseLocation + "17.jpg", strBaseLocation + itemID + ".jpg");
}

}
catch(Exception ee)
{
throw ee;
}

if(System.IO.File.Exists(targetFile) && (new System.IO.FileInfo(targetFile)).Length>10000)
{
this.lblMsg.Text = "<a href='viewitem.aspx?itemid=" + itemID + "'>添加成功!</a>";
}
else
{
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(fileName,argu);
System.Diagnostics.Process.Start(startInfo);

if(System.IO.File.Exists(targetFile) && (new System.IO.FileInfo(targetFile)).Length>10000)
{
this.lblMsg.Text = "<a href='viewitem.aspx?itemid=" + itemID + "'>添加成功!</a>";
}
else
{
Framework.DeleteItem(itemID, this._userID);
this.lblMsg.Text = "此文件格式添加失败!";
}
}

}
heqi915 2007-09-10
  • 打赏
  • 举报
回复
关注,
shrinerain 2007-09-10
  • 打赏
  • 举报
回复
Google "ffmpeg"
jiangmin168168 2007-09-10
  • 打赏
  • 举报
回复
最后生成缩略图,这个只能用别的工具生成了,一般是第三方软件.
jiangmin168168 2007-09-10
  • 打赏
  • 举报
回复
/// <summary>
/// 检查图片的保存路径是否存在
/// </summary>
/// <returns></returns>
public string CheckProductPictureML(string sSavePath)
{
string strml=this.Server.MapPath(sSavePath);


if(Directory.Exists(strml)==false)
{
Directory.CreateDirectory(strml);
}

#region maybe Use

/*****************************************************************

//年
strml+="\\"+DateTime.Now.Year.ToString();
if(Directory.Exists(strml)==false)
{
Directory.CreateDirectory(strml);
}
//月
strml+="\\"+DateTime.Now.Month.ToString();
if(Directory.Exists(strml)==false)
{
Directory.CreateDirectory(strml);
}
//日
strml+="\\"+DateTime.Now.Day.ToString();
if(Directory.Exists(strml)==false)
{
Directory.CreateDirectory(strml);
}
*****************************************************************/
#endregion

return strml;
}
jiangmin168168 2007-09-10
  • 打赏
  • 举报
回复
这是我上传视频的方法:
/// <summary>
/// 上传视频
/// </summary>
/// <param name="Fileup"></param>
/// <param name="sSavePath"></param>
/// <param name="preFileName"></param>
/// <param name="iMaxSize"></param>
/// <returns></returns>
public string[] upVideo(ref System.Web.UI.HtmlControls.HtmlInputFile Fileup, string sSavePath, string preFileName, int iMaxSize)
{
HttpFileCollection files = HttpContext.Current.Request.Files;
string strfileoldpath; //上传文件的保存路径
string strfileoldname;//保存后名称

string fileName, fileExtension;
string[] arrayImageUrl = new string[4] { "", "", "", "" };
try
{
//没有文件上传
if (Fileup.PostedFile.FileName == "")
{
arrayImageUrl[2] = "errorNoFile";
return arrayImageUrl;

}
HttpPostedFile postedFile = Fileup.PostedFile;
fileName = System.IO.Path.GetFileName(postedFile.FileName);
if (fileName == "")
{
arrayImageUrl[2] = "errorNoFile";
return arrayImageUrl;

}
fileExtension = System.IO.Path.GetExtension(fileName);
//判断上传文件类型
string filetype = Fileup.PostedFile.ContentType;
//判断是视频
bool legal=false;
string res = fileExtension.Trim().ToLower();
string[] allKinds=".3gp/.wmv/.asx/.asf/.rm/.rmvb/.ram/.mpg/.mpeg/.mpe/.dat/.vob/.dv/.mov/.mp4/.m4v/.avi/.mkv/.flv".Split('/');
for(int i=0;i<allKinds.Length;i++)
{
if(res==allKinds[i])
{
legal=true;
break;
}

}
if (!legal)
{
arrayImageUrl[2] = "errorT";
return arrayImageUrl;
}

//判断是否大小超过上限
int MaxFile = 0;
MaxFile = Fileup.PostedFile.ContentLength;
if (MaxFile > (iMaxSize * 1024))
{
arrayImageUrl[2] = "errorb";
return arrayImageUrl;
}

//检查保存文件的目录是否存在,否则创建
strfileoldpath = CheckProductPictureML(sSavePath);
//为文件命名,然后保存
Random ra = new Random();

strfileoldname = preFileName + ra.Next(100000, 999999).ToString() + fileExtension;

strfileoldpath += "\\" + strfileoldname;

//保存文件
postedFile.SaveAs(strfileoldpath);

arrayImageUrl[0] = sSavePath + "/" + strfileoldname;

return arrayImageUrl;
}
catch(Exception ex)
{
arrayImageUrl[2] = "error";
return arrayImageUrl;
}
}
Mondevideo 2007-09-10
  • 打赏
  • 举报
回复
帮忙顶了。
cqxue 2007-06-20
  • 打赏
  • 举报
回复
各位大侠们,来看看啊。
全部的分都给了。
如何上传视频阿
cqxue 2007-06-20
  • 打赏
  • 举报
回复
我不会啊,能不能帮帮忙,给段代码看看啊
cqxue 2007-06-20
  • 打赏
  • 举报
回复
怎么没有人接啊
WNASP 2007-06-20
  • 打赏
  • 举报
回复
那就是上传达文件了,你可以使用FTP类,应该可以的,我以前做过,但代码找不到了
cqxue 2007-06-20
  • 打赏
  • 举报
回复
帮帮忙啊.各位大侠.
我只有100分了.全散了.
cqxue 2007-06-20
  • 打赏
  • 举报
回复
那做过上传视频吗?
WNASP 2007-06-20
  • 打赏
  • 举报
回复
只做过图片的缩率图,没做过视频的
帮顶

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧