如何在C#中使用aforge ffmpeg启动音频和视频捕获/合并音频和视频 [英] How to start audio and video capture /merge audio and video using aforge ffmpeg in C#

查看:1617
本文介绍了如何在C#中使用aforge ffmpeg启动音频和视频捕获/合并音频和视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了音频和视频捕获方法并将两个文件保存到我的位置。之后这两个文件合并为一个avi格式文件。在最终输出文件中音频先运行,视频延迟。如何解决它。我使用ffmpeg.exe进行合并。





有多个捕获音频和视频的系统一次没有在c#中单独捕获申请?



我的尝试:



这里是合并方法。



 私人  void  mergefile( string  wavefilepath, string  videofilepath)
{
string Path_FFMPEG = Application.StartupPath + \\\ \\ffmpeg.exe;
string Wavefile = wavefilepath;
string video1 = videofilepath;
// string file = @D:\Developments\video\text.txt;
string strResult = @ C:\Users\aa\Desktop\video\Test1output.avi;

System.Diagnostics.Process proc = new System.Diagnostics.Process();

尝试
{
// ffmpeg -i clip.mp4 -itsoffset 0.150 -i clip.mp4 -vcodec copy -acodec copy -map 0:0 -map 1:1 output.mp4
< span class =code-comment> //
proc.StartInfo.Arguments = string.Format( - i {0} -itsoffset 0.000 -i {1} - vcodec copy -acodec copy -map 0:0 -map 1:0 {2},video1,Wavefile,strResult);
proc.StartInfo.Arguments = string .Format( - i {0} -i {1} -acodec copy -vcodec copy {2},Wavefile,video1,strResult);
proc.StartInfo.UseShellExecute = false ;
proc.StartInfo.CreateNoWindow = false ;
proc.StartInfo.RedirectStandardOutput = true ;
proc.StartInfo.RedirectStandardError = true ;
proc.StartInfo.FileName = Path_FFMPEG;
proc.Start();

string StdOutVideo = proc.StandardOutput.ReadToEnd();
string StdErrVideo = proc.StandardError.ReadToEnd();
}
catch {}
finally
{
proc.WaitForExit();
proc.Close();
}

}

解决方案

使用此

 proc.StartInfo.Arguments = string.Format( -  i {0} -i {1} -acodec copy -vcodec copy -map 0:0 -map 0:1 {2},Wavefile,video1, strResult); 


I have Created audio and video capture method and Save thee two file in to my location.after these two file merge in to one avi format file.in the final output file audio run first and video take delay. how to fix it. I used ffmpeg.exe for merge.


are there many system for capture audio and the video in one time without separate capture in c# application?

What I have tried:

here is the merge method.

private void mergefile(string wavefilepath, string videofilepath)
        {
            string Path_FFMPEG = Application.StartupPath + "\\ffmpeg.exe";
            string Wavefile = wavefilepath;
            string video1 = videofilepath;
            //string file = @"D:\Developments\video\text.txt";
            string strResult = @"C:\Users\aa\Desktop\video\Test1output.avi";

            System.Diagnostics.Process proc = new System.Diagnostics.Process();

            try
            {
                //ffmpeg -i clip.mp4 -itsoffset 0.150 -i clip.mp4 -vcodec copy -acodec copy -map 0:0 -map 1:1 output.mp4
               // proc.StartInfo.Arguments = string.Format("-i {0} -itsoffset 0.000 -i {1} -vcodec copy -acodec copy -map 0:0 -map 1:0 {2}", video1, Wavefile, strResult);
                proc.StartInfo.Arguments = string.Format("-i {0} -i {1} -acodec copy -vcodec copy {2}", Wavefile, video1, strResult);
                proc.StartInfo.UseShellExecute = false;
                proc.StartInfo.CreateNoWindow = false;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.RedirectStandardError = true;
                proc.StartInfo.FileName = Path_FFMPEG;
                proc.Start();

                string StdOutVideo = proc.StandardOutput.ReadToEnd();
                string StdErrVideo = proc.StandardError.ReadToEnd();
            }
            catch { }
            finally
            {
                proc.WaitForExit();
                proc.Close();
            }
            
        }

解决方案

use this

proc.StartInfo.Arguments = string.Format("-i {0} -i {1} -acodec copy -vcodec copy -map 0:0 -map 0:1 {2}", Wavefile, video1, strResult);


这篇关于如何在C#中使用aforge ffmpeg启动音频和视频捕获/合并音频和视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆