recently the company project required to achieve a panoramic camera video interception, but the interception of video demand transcoding upload. After studying the use of FFmpeg transcoding, a detailed introduction to the blog :
The simplest ffmpeg-based transcoding program
The main is the operation process of transcoding, can realize the MP4 converted from the camera to the normal player MP4 format;
1 //transcoding Method2 Private voidTest1 ()3 {4 5Process p =NewProcess ();6 7 8p.StartInfo.FileName = path +"Ffmpeg.exe";9 TenP.startinfo.useshellexecute =false; One stringSrcfilename =""; A stringdestFileName =""; -Srcfilename = path +"Initvideo1.mp4"; - thedestFileName = path +"Initvideo.mp4"; - -P.startinfo.arguments ="- I."+ Srcfilename +"-y-vcodec h264-b 500000"+ destFileName;//Execution Parameters - +P.startinfo.useshellexecute =false;////Do not use system shell to start process -P.startinfo.createnowindow =true;//do not show DOS program window + AP.startinfo.redirectstandardinput =true; at -P.startinfo.redirectstandardoutput =true; - -P.startinfo.redirectstandarderror =true;//writes the external program error output to the StandardError stream - -P.errordatareceived + =NewDatareceivedeventhandler (p_errordatareceived); in -P.outputdatareceived + =NewDatareceivedeventhandler (p_outputdatareceived); to +P.startinfo.useshellexecute =false; - the P.start (); * $P.startinfo.windowstyle =Processwindowstyle.hidden;Panax Notoginseng -P.beginerrorreadline ();//start Asynchronous Read the + A thep.WaitForExit ();//blocking wait process end + -P.close ();//Close Process $ $P.dispose ();//Freeing Resources -}
Test Demo program included:
Code download
C # implements FFmpeg video transcoding, playback