1. Project structure:
2. Code:
usingSystem;usingSystem.Collections.Generic;usingSystem.Diagnostics;usingsystem.web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;namespacewebffmpeg{ Public Partial class_default:system.web.ui.page {protected voidPage_Load (Objectsender, EventArgs e) { } protected voidButton1_Click (Objectsender, EventArgs e) { stringPathString =AppDomain.CurrentDomain.SetupInformation.ApplicationBase; Process P=NewProcess (); p.StartInfo.FileName= PathString +"\\FFmpeg\\ffmpeg.exe"; P.startinfo.arguments=@"-y-r 1-i"+pathstring+@"ffmpeg\pic\img%2d.jpg-i"+pathstring+@"ffmpeg\music\02.mp3-s 800x800-vcodec MPEG4"+pathstring+@"Ffmpeg\vedio\out.mp4"; P.startinfo.useshellexecute=false; P.startinfo.redirectstandarderror=true; P.startinfo.crea Tenowindow=true; P.errordatareceived+=NewDatareceivedeventhandler (s, message) = {Response.Write (message). Data); });//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 ResourcesResponse.Write ("<a href= ' ffmpeg/vedio/out.mp4 ' > Downloads </a>"); } }}
3.Demo Connection
Http://url.cn/P64rFI
C # call FFmpeg to synthesize video based on pictures