First put the latest ffmpeg.exe in the debug path, http://www.ffmpeg.org/download.html
Then call this method
Public voidCombinemp4withouttxt (stringSTRMP4A,stringSTRMP4B,stringStroutmp4path) {Process P=NewProcess ();//establishing an external calling threadp.StartInfo.FileName = System.Windows.Forms.Application.StartupPath +"\\ffmpeg.exe";//the absolute path of the external program to invoke stringStrarg ="- I. concat:\ ""+ strmp4a +"|"+ strmp4b +"\ "-vcodec copy-acodec copy"+ Stroutmp4path +"- y"; P.startinfo.arguments=Strarg; P.startinfo.useshellexecute=false;//start thread without using the operating system shell (must be false, see MSDN for details)P.startinfo.redirectstandarderror =true;//Write the external program error output to the StandardError stream (this must be noted that all output information of the ffmpeg is an error output stream, with StandardOutput is not capturing any messages ...) This is the experience I have spent for 2 months ... mencoder is captured with StandardOutput)P.startinfo.createnowindow =true;//do not create process windowP.errordatareceived + =NewDatareceivedeventhandler (Output);//the event generated by the external program (here is the ffmpeg) output stream, here is the process of transferring the stream to the following method, please refer to MSDNP.start ();//Start ThreadP.beginerrorreadline ();//start Asynchronous Readp.WaitForExit ();//blocking wait process endP.close ();//Close ProcessP.dispose ();//Freeing Resources}
This code is exception-throwing processing, please add your own code
Private void Output (object sendprocess, Datareceivedeventargs output) { if (! String.IsNullOrEmpty (output. Data) {// processing method ... } }
which
STRMP4A represents a pre-video physical path such as D:\A.MP4,STRMP4B, which represents the physical path of a video after a physical path such as D:\b.mp4,stroutmp4path represents a composite video, such as D:\AB.mp4.
If the effect of the composition is not ideal, such as only merging the former video, or only after the combination of sound, please follow the fmpeg.exe cmd instruction (please do your own Baidu command), the test is complete to modify this line
String Strarg = "-I concat:\" "+ strmp4a +" | "+ strmp4b +" \ "-vcodec copy-acodec copy" + Stroutmp4path + "-y"
Using FFmpeg to merge video in C #