C#使用ffmpeg转换格式,截图,旋转
C#使用ffmpeg转换格式,截图,旋转
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 24364544 2013-10-21 07:52 VideoCenterffmpegffmpeg.exe
文件 4529 2015-12-04 16:23 VideoCenterimg20151204042349.jpg
文件 4529 2015-12-04 16:23 VideoCenterimg20151204042354.jpg
文件 4529 2015-12-04 16:23 VideoCenterimg20151204042358.jpg
文件 8752428 2015-12-18 11:10 VideoCenterUpload p158435105622626.mp4
文件 1725402 2015-12-18 16:31 VideoCenterUpload p1584351056226261.mp4
文件 736 2015-12-18 16:46 VideoCenterVideoUpload.aspx
文件 3941 2015-12-18 16:46 VideoCenterVideoUpload.aspx.cs
文件 431 2010-11-01 11:01 VideoCenterweb.config
文件 171 2010-11-19 09:59 VideoCenter说明.txt
目录 0 2015-12-04 16:14 VideoCenterffmpeg
目录 0 2010-11-19 09:50 VideoCenterflv
目录 0 2015-12-18 16:30 VideoCenterimg
目录 0 2015-12-18 16:30 VideoCenterUpload
目录 0 2015-12-18 16:46 VideoCenter
----------- --------- ---------- ----- ----
34861240 15
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
public partial class VideoUpload : System.Web.UI.Page
{
protected void Page_Load(object sender EventArgs e)
{
}
#region
///
/// 视频格式转换
///
/// 原文件相对路径
/// 转换后保存路径
public string VideoConvertFlv(string FromName)
{
string ffmpeg = Server.MapPath(“.“) + “ \ffmpeg\ffmpeg.exe“;
string ExportName = “flv“ + “\“ + DateTime.Now.ToString(“yyyyMMddhhmmss“) + “.flv“;
string WidthAndHeight = “320x240“;
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
startInfo.Windowstyle = System.Diagnostics.ProcessWindowstyle.Hidden;
startInfo.Arguments = “ -i “ + Server.MapPath(FromName) + “ -ab 56 -ar 22050 -b 500 -r 15 -s “ + WidthAndHeight + “ “ + Server.MapPath(ExportName);
Process proc = Process.Start(startInfo);
proc.WaitForExit();
return ExportName ;
}
/**/
///
/// 从视频画面中截取一帧画面为图片
///
/// 视频文件pic/guiyu.mov
/// 图片的尺寸如:240*180
/// ame“>开始截取的时间如:“1“
///
public string GetPicFromVideo(string VideoName string WidthAndHeight string CutTimeframe)
{
string ffmpeg = Server.MapPath(“.“) + “ \ffmpeg\ffmpeg.exe“;
string PicName = Server.MapPath(“img\“ + DateTime.Now.ToString(“yyyyMMddhhmmss“) + “.jpg“);
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
startInfo.Windowstyle = System.Diagnostics.ProcessWindowstyle.Minimized;
startInfo.Arguments = “ -i “ + Server.MapPath(VideoName) + “ -y -f image2 -ss “ + CutTimeframe + “ -t 0.001 -s “ + WidthAndHeight + “ “ + PicName;
try
{
Process proc = Process.Start(startInfo);
proc.WaitForExit();
return PicName;
}
catch (Exception err)
{
return err.Message;
}
}
public string GetPicFromVideo1(string VideoName)
{
string VideoName1 = “Upload\tp1584351056226261.mp4“;
string ffmpeg = Server.MapPath(“.“) + “ \ffmpeg\ffmpeg.exe“;
string PicName = Server.MapPath(“img\“ + DateTime.Now.ToString(“yyyyMMddhhmmss“) + “.jpg“);
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
startInfo.Windowstyle = System.Diagnostics.ProcessWindowstyle.Minimized;
string sed=““rotate = 90 * PI / 180““;
string sdgf = ““transpose=1““;
startInfo.Arguments = “ -i “ + Server.MapPath(VideoName) + “ -vf “+ sdgf + “ “ + Serv
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 24364544 2013-10-21 07:52 VideoCenterffmpegffmpeg.exe
文件 4529 2015-12-04 16:23 VideoCenterimg20151204042349.jpg
文件 4529 2015-12-04 16:23 VideoCenterimg20151204042354.jpg
文件 4529 2015-12-04 16:23 VideoCenterimg20151204042358.jpg
文件 8752428 2015-12-18 11:10 VideoCenterUpload p158435105622626.mp4
文件 1725402 2015-12-18 16:31 VideoCenterUpload p1584351056226261.mp4
文件 736 2015-12-18 16:46 VideoCenterVideoUpload.aspx
文件 3941 2015-12-18 16:46 VideoCenterVideoUpload.aspx.cs
文件 431 2010-11-01 11:01 VideoCenterweb.config
文件 171 2010-11-19 09:59 VideoCenter说明.txt
目录 0 2015-12-04 16:14 VideoCenterffmpeg
目录 0 2010-11-19 09:50 VideoCenterflv
目录 0 2015-12-18 16:30 VideoCenterimg
目录 0 2015-12-18 16:30 VideoCenterUpload
目录 0 2015-12-18 16:46 VideoCenter
----------- --------- ---------- ----- ----
34861240 15
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)