博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
音频视频压缩ffmpeg
阅读量:7114 次
发布时间:2019-06-28

本文共 1120 字,大约阅读时间需要 3 分钟。

  hot3.png

1、下载ffmpeg.exe。

2、将ffmpeg.exe放在某个目录下 eg:D:\\开发工具\\ffmpeg\\ffmpeg.exe。

3、app.config配置一个key=Vrffmpeg,value="D:\\开发工具\\ffmpeg\\ffmpeg.exe"。

4、调用下面代码即可。

public static compressVideo(string filePath){

 string file_name = filePath;

            //ffmpeg.exe -s 176*144 -i test.yuv -vcodec mpeg4 -qscale 0.1~255 test.mp4
            string command_line = " -s 176*144 -i " + file_name + " -vcodec mpeg4 -qscale 0.1~255 " + file_name.Replace(".avi", "") + ".mp4";
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.StartInfo.WorkingDirectory = ConfigurationManager.AppSettings["VrBodyDataPath"];
            proc.StartInfo.UseShellExecute = false; //use false if you want to hide the window  
            proc.StartInfo.CreateNoWindow = true;
            proc.StartInfo.FileName = ConfigurationManager.AppSettings["Vrffmpeg"];
            proc.StartInfo.Arguments = command_line; 
            proc.Start();
            proc.WaitForExit();
            proc.Close();

//附加,根据实际情况

  // 删除原始avi文件  

            FileInfo file = new FileInfo(filePath);
            if (file.Exists)
            {
                try
                {
                    file.Delete(); //删除单个文件  
                }
                catch (Exception e)
                {
                   // Common.writeLog("删除视频文件“" + file_name + "”出错!" + e.Message);
                }
            }

}

转载于:https://my.oschina.net/u/933229/blog/908535

你可能感兴趣的文章
Blockchain和Tangle哪一个是未来?
查看>>
github 上有趣又实用的前端项目(持续更新,欢迎补充)
查看>>
【Under-the-hood-ReactJS-Part6】React源码解读
查看>>
matlab绘制peano(皮亚诺)曲线和koch(科赫曲线,雪花曲线)分形曲线
查看>>
Mybatis之设计模式之迭代器模式
查看>>
小程序TAB列表切换内容动态变化,scrollview高度根据内容动态获取
查看>>
swoole_table 实现原理剖析
查看>>
你需要知道面试中的10个JavaScript概念
查看>>
Java源码阅读之HashMap - JDK1.8
查看>>
Dell服务器系统安装后无法正常进入系统
查看>>
Silverlight/Windows8/WPF/WP7/HTML5周学习导读(9月17日-9月23日)
查看>>
Tap-Ahead:让移动搜索更加便捷的解决之道
查看>>
华为vlan划分,单臂路由以及静态路由
查看>>
3.VMware vsphere 5.0新体验-安装VMware Center
查看>>
趣题: 一道面试题的解法
查看>>
Android应用程序启动过程源代码分析(5)
查看>>
查询整个数据库中某个特定值所在的表和字段的方法
查看>>
在存储过程中编写正确的事务处理代码(SQL Server 2000 & 2005)
查看>>
数据库邮件
查看>>
adstrtal.sh报超时错误 ERROR : Timed out( 100000 ): Interrupted Exception
查看>>