zoukankan      html  css  js  c++  java
  • ffmpeg 视频合并

            /// <summary>
            /// 视频合并
            /// </summary>
            /// <param name="File1">第一个视频地址</param>
            /// <param name="File2">第二个视频地址</param>
            /// <param name="DstFile">合成后存放路径</param>
            /// <returns></returns>
            static string Combine(string File1, string File2, string DstFile)
            {
                string strTmp1 = File1 + ".ts";
                string strTmp2 = File2 + ".ts";
                string strCmd1 = " -i " + File1 + " -c copy -bsf:v h264_mp4toannexb -f mpegts " + strTmp1 + " -y ";
                string strCmd2 = " -i " + File2 + " -c copy -bsf:v h264_mp4toannexb -f mpegts " + strTmp2 + " -y ";
    
    
                //string strCmd = " -i concat:"" + strTmp1 + "|" +
                //strTmp2 + "" -c copy -bsf:a aac_adtstoasc -movflags +faststart " + DstFile + " -y ";
                string strCmd = " -i "concat:" + strTmp1 + "|" + strTmp2 + "" -c copy -bsf:a aac_adtstoasc -movflags +faststart " + DstFile + " -y ";
    
    
    
                //转换文件类型,由于不是所有类型的视频文件都支持直接合并,需要先转换格式
                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.FileName = "D:\Work\tpp20190322\uploadtemp\ffmpeg.exe";//要执行的程序名称 
                p.StartInfo.Arguments = " " + strCmd1;
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardInput = false;//可能接受来自调用程序的输入信息 
                p.StartInfo.RedirectStandardOutput = false;//由调用程序获取输出信息 
                p.StartInfo.RedirectStandardError = false;//重定向标准错误输出
                p.StartInfo.CreateNoWindow = false;//不显示程序窗口
    
    
                p.Start();//启动程序 
                p.WaitForExit();
    
    
                //转换文件类型,由于不是所有类型的视频文件都支持直接合并,需要先转换格式
                p = new System.Diagnostics.Process();
                p.StartInfo.FileName = "D:\Work\tpp20190322\uploadtemp\ffmpeg.exe";//要执行的程序名称 
                p.StartInfo.Arguments = " " + strCmd2;
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardInput = false;//可能接受来自调用程序的输入信息 
                p.StartInfo.RedirectStandardOutput = false;//由调用程序获取输出信息 
                p.StartInfo.RedirectStandardError = false;//重定向标准错误输出
                p.StartInfo.CreateNoWindow = false;//不显示程序窗口
    
    
                p.Start();//启动程序 
                p.WaitForExit();
    
    
    
    
                //合并
                p = new System.Diagnostics.Process();
                p.StartInfo.FileName = "D:\Work\tpp20190322\uploadtemp\ffmpeg.exe";//要执行的程序名称 
                p.StartInfo.Arguments = " " + strCmd;
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardInput = false;//可能接受来自调用程序的输入信息 
                p.StartInfo.RedirectStandardOutput = false;//由调用程序获取输出信息 
                p.StartInfo.RedirectStandardError = false;//重定向标准错误输出
                p.StartInfo.CreateNoWindow = false;//不显示程序窗口
    
    
                p.Start();//启动程序
    
    
                //向CMD窗口发送输入信息: 
                // p.StandardInput.Write("ipconfig");
    
    
                //string output = p.StandardOutput.ReadToEnd();
                p.WaitForExit();//等待程序执行完退出进程
                //-ss表示搜索到指定的时间 -i表示输入的文件 -y表示覆盖输出 -f表示强制使用的格式
    
    
                if (System.IO.File.Exists(DstFile))
                {
                    return DstFile;
                }
                return "";
            }
  • 相关阅读:
    mongodb 添加用户
    mongo 安装
    python 操作redis
    python 安装 redis
    redis 命令文档网址
    redis 事务
    Redis key命令
    手动卸载的vs2010
    个人封装JavaScript函数
    女学-温砚如老师的人生女学
  • 原文地址:https://www.cnblogs.com/Mzg121584668/p/10937906.html
Copyright © 2011-2022 走看看