Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.

C#
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();
            }
            
        }
Posted
Updated 16-May-16 17:36pm
v3
Comments
Sergey Alexandrovich Kryukov 16-May-16 22:07pm    
Excuse me, your question is unclear. Do you have any problems with your code? Other issues?
—SA
rashmirashmijoshi61@gmail.com 31-Aug-17 1:34am    
Can you share code for audio recording? I have created Video recording through aforge libraries but not sure is it possible to have audio recorded as well by using the same library. Please provide some direction to achieve this. thanks in advance.

1 solution

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);
 
Share this answer
 
Comments
Member 15912098 8-Feb-23 0:58am    
audio and video volume mix
Member 15912098 8-Feb-23 0:59am    
video volume not show

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900