asp.net中使用ffmpeg
protected void Button1_Click(object sender, EventArgs e)
{
string FFmpegArguments = @" -i D:\离歌.wmv -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 D:\离歌.flv ";
//ProcessStartInfo info = new ProcessStartInfo("D:/ffmpeg/ffmpeg", FFmpegArguments);
//Process.Start(info); Process p = new Process(); //Process類有一個StartInfo屬性,這個是ProcessStartInfo類,包括了一些屬性和方法,下面我們用到了他的幾個屬性:
p.StartInfo.FileName = "D:/ffmpeg/ffmpeg.exe";//設定程序名
p.StartInfo.Arguments = FFmpegArguments; //設定程式執行參數
p.StartInfo.UseShellExecute = false; //關閉Shell的使用
p.StartInfo.RedirectStandardInput = true; //重定向標準輸入
p.StartInfo.RedirectStandardOutput = true; //重定向標準輸出
p.StartInfo.RedirectStandardError = true; //重定向錯誤輸出
p.StartInfo.CreateNoWindow = true; //設置不顯示窗口
p.Start(); //啟動
//p.StandardInput.WriteLine(FFmpegArguments);//也可以用這種方式輸入要執行的命令
//p.StandardInput.WriteLine("exit"); //不過要記得加上Exit要不然下一行程式執行的時候會當機
} /// 视频(avi,mov等等格式)转换为flv格式视频
/// </summary>
/// <param name="FromName">被转换的视频文件</param>
/// <param name="ExportName">转换flv后的文件名</param>
/// <param name="ExportName">视频大小的尺寸</param>
/// <returns></returns>
public string VideoConvertFlv(string FromName,string ExportName,string WidthAndHeight)
{
string ffmpeg=@"D:\ffmpeg\ffmpeg.exe";
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);
startInfo.Arguments = " -i " + FromName + " -ab 56 -ar 22050 -b 500 -r 15 -s " + WidthAndHeight + " " + ExportName;
try
{
System.Diagnostics.Process.Start(startInfo);
return ExportName;
}
catch(Exception err)
{
return err.Message;
}
} /// <summary>
/// 从视频画面中截取一帧画面为图片
/// </summary>
/// <param name="VideoName">视频文件pic/guiyu.mov</param>
/// <param name="WidthAndHeight">图片的尺寸如:240*180</param>
/// <param name="CutTimeFrame">开始截取的时间如:"1"</param>
/// <returns></returns>
public string GetPicFromVideo(string VideoName,string WidthAndHeight,string CutTimeFrame)
{ string ffmpeg=@"C:Inetpubwwwrootdemopic fmpeg.exe";
string PicName =Server.MapPath(Guid.NewGuid().ToString().Replace("-","")+".jpg");
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.Arguments = " -i " + Server.MapPath(VideoName) + " -y -f image2 -ss "+CutTimeFrame+" -t 0.001 -s " + WidthAndHeight + " " + PicName ;
try
{
System.Diagnostics.Process.Start(startInfo);
return PicName;
}
catch(Exception err)
{
return err.Message;
}
}
asp.net中使用ffmpeg的更多相关文章
- ASP.NET中常用的优化性能的方法
1. 数据库访问性能优化 数据库的连接和关闭 访问数据库资源需要创建连接.打开连接和关闭连接几个操作.这些过程需要多次与数据库交换信息以通过身份验证,比较耗费服务器资源.ASP.NET中提供了连接池( ...
- asp.net中ashx生成验证码代码放在Linux(centos)主机上访问时无法显示问题
最近有个项目加入了验证码功能,就从自己博客以前的代码中找到直接使用,直接访问验证码页面报错如下: 源代码:asp.net中使用一般处理程序生成验证码 Application Exception Sys ...
- ASP.NET中Session的sessionState 4种mode模式
1. sessionState的4种mode模式 在ASP.NET中Session的sessionState的4中mode模式:Off.InProc.StateServer及SqlServer. 2. ...
- Asp.net中存储过程拖拽至dbml文件中,提示无法获得返回值
Asp.net中存储过程拖拽至dbml文件中,提示无法获得返回值,去属性表中设置这时候会提示你去属性表中更改返回类型. 其实存储过程返回的也是一张表,只不过有时候存储过程有点复杂或者写法不规范的话不能 ...
- ASP.NET中后台数据和前台控件的绑定
关于ASP.NET中后台数据库和前台的数据控件的绑定问题 最近一直在学习个知识点,自己创建了SQL Server数据库表,想在ASP.NET中连接数据库,并把数据库中的数据显示在前台,注意,这里的数据 ...
- asp.net中缓存的使用介绍一
asp.net中缓存的使用介绍一 介绍: 在我解释cache管理机制时,首先让我阐明下一个观念:IE下面的数据管理.每个人都会用不同的方法去解决如何在IE在管理数据.有的会提到用状态管理,有的提到的c ...
- ASP.NET中Ajax的用法
在ASP.NET中应用Ajax的格式如下: 前台代码(用JQuery库) $.ajax({ type: "POST", async: true, url: "../Aja ...
- Asp.Net中使用OpenRowSet操作Excel表,导入Sql Server(实例)
有两种接口可供选择:Microsoft.Jet.OLEDB.4.0(以下简称 Jet 引擎)和Microsoft.ACE.OLEDB.12.0(以下简称 ACE 引擎). Jet 引擎大家都很熟悉,可 ...
- Asp.net中static变量和viewstate的使用方法(谨慎)
在.Net平台下进行CS软件开发时,我们经常遇到以后还要用到某些变量上次修改后的值,为了简单起见,很多人都习惯用static来定义这些变量,我也是.这样非常方便,下一次调用某个函数时该变量仍然保存的是 ...
随机推荐
- Spring MVC中注解的简介
参考网址: https://blog.csdn.net/a67474506/article/details/46361195 @RequestMapping映射请求 SpringMVC 使用 @Re ...
- python基础-三元运算和bytes数据
三元运算 进制 二进制,01 八进制,01234567 十进制,0123456789 十六进制,0123456789ABCDEF bytes类型 http://www.cnblogs. ...
- sql server 2016新特性 查询存储(Query Store)的性能影响
前段时间给客户处理性能问题,遇到一个新问题, 客户的架构用的是 alwayson ,并且硬件用的是4路96核心,内存1T ,全固态闪存盘,sql server 2016 . 问题 描述 客户经常出现 ...
- [Asp.Net] Global.asax
Global.asax.cs文件会被编译到对应的dll 但部署是还需要Global.asax文件 class Global中的方法才会在程序启动时执行
- openstack RuntimeError: Unable to create a new session key. It is likely that the cache
[Mon Apr 15 01:02:31.654247 2019] [:error] [pid 19433:tid 139790082479872] Login successful for user ...
- IOS AppDelegate常用方法
// 当应用程序启动完毕的时候就会调用(系统自动调用) - (BOOL)application:(UIApplication *)application didFinishLaunchingWithO ...
- PageHelper 记录总条数不正确问题处理
//PageHelper.startPage会返回一个page对象,这个对象在查询结果出来后会把页数,记录总数给page对象,用page.getPages()和getTotal()获取页数和记录总数. ...
- angular4 学习日志(一 依赖注入)
1.创建一个服务,为了好管理建一个名叫services的文件夹管理所有服务: ng g service services\person 2.在服务中定义一个person 类 : 3.在app.mdul ...
- SAP系统管理中常见问题解答(转载)
1.如何查看SAP系统的位数? system——status看 Platform ID Platform 32-bit 64-bit --------------------------------- ...
- 爬虫学习(四)——post请求爬取
百度翻译爬取数据 import urllib.requestimport urllib.parsepost_url = "https://fanyi.baidu.com/sug"h ...