none
FFMPEG merge video side by side not working? RRS feed

  • Question

  • The method i have used to merge two video clips side by side not throwing any errors and not executing either iam new to using FFMPEG with c# can anybody help me to find what i have been doing wrong here thanks in advance

    public void mergefiles(string vid1, string vid2) { string inputvideo1=vid1; string inputvideo2=vid2; string strResult = HttpRuntime.AppDomainAppPath+"RESULT\\test.mp4"; string parametros = "ffmpeg -i '"+inputvideo1+"' -i '"+inputvideo2+"' -filter_complex \\'[0:v]pad=iw*2:ih[int];[int][1:v]overlay=W/2:0[vid]'\\-map [vid] -c:v libx264 -crf 23 -preset veryfast '"+strResult+"'"; string strFFMpeg=HttpRuntime.AppDomainAppPath+"bin\\ffmpeg.exe"; Process pProcess = new Process(); pProcess.StartInfo.FileName = strFFMpeg; pProcess.StartInfo.Arguments = parametros; pProcess.StartInfo.UseShellExecute = false; pProcess.StartInfo.CreateNoWindow = true; pProcess.StartInfo.RedirectStandardError = true; pProcess.StartInfo.RedirectStandardOutput = true; pProcess.Start(); StreamReader srOutput = pProcess.StandardError; string output = srOutput.ReadToEnd(); pProcess.WaitForExit(); }


    Wednesday, August 7, 2019 5:22 AM

All replies

  • Hi Marcelo127,

    Thank you for posting here.

    You could try the following code to merge video successfully by using FFMPEG.

         public 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 ";
    
                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.FileName = "D:\\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:\\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:\\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(); 
                p.WaitForExit();
                File.Delete(strTmp1);
                File.Delete(strTmp2);
    
                if (System.IO.File.Exists(DstFile))
                {
                    return DstFile;
                }
                return "";
            }

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, August 7, 2019 8:10 AM
    Moderator