<summary> @ From video file screenshot, generate in folder of video files Two predecessor configuration items are required in Web.config: Path to 1.ffmpeg.exe file <add key= "FFmpeg" value= "E:ffmpegffmpeg.exe"/> 2. The size of the screenshot <add key= "catchflvimgsize" value= "240x180"/> 3. Video processing program Ffmpeg.exe </summary> <param name= "Vfilename" > video file address, such as:/web/flvfile/user1/00001.flv</param> <returns> success: Return the virtual address of the picture; Failure: Returning an empty string </returns> public string catchimg (string vfilename) { Gets the path of the Ffmpeg.exe, where the path is configured in web.config, such as: <add key= "FFmpeg" value= "E:ffmpegffmpeg.exe"/> String ffmpeg=system.configuration.configurationsettings.appsettings["FFmpeg"]; if (! System.IO.File.Exists (ffmpeg)) | | (! System.IO.File.Exists (Vfilename)) { Return ""; } Get the picture relative path/Last store to the database path, such as:/web/flvfile/user1/00001.jpg String flv_img = System.IO.Path.ChangeExtension (Vfilename, ". jpg"); Picture absolute path, such as: d:videowebflvfileuser1001.jpg String flv_img_p = HttpContext.Current.Server.MapPath (flv_img); Screenshot size, configured in web.config, such as: <add key= "catchflvimgsize" value= "240x180"/> String flvimgsize=system.configuration.configurationsettings.appsettings["Catchflvimgsize"]; System.Diagnostics.ProcessStartInfo startinfo = new System.Diagnostics.ProcessStartInfo (ffmpeg); Startinfo.windowstyle = System.Diagnostics.ProcessWindowStyle.Hidden; This is the parameter that can be combined into a ffmpeg.exe file, where the command is ffmpeg 0.4.9 debugging through startinfo.arguments = "I" + vfilename + "-y-f image2-t 0.001-s" + flvimgsize + "" + flv_img_p ; Try { System.Diagnostics.Process.Start (StartInfo); } Catch { Return ""; } Note: After the successful capture of the image, the data from the memory cache to disk will take a long time, probably 3, 4 seconds or longer; Here need to delay after detection, I server delay 8 seconds, that is, if more than 8 seconds picture still does not exist, that the screenshot failed; The delay code is omitted here. If the one who knows how to capture the Ffmpeg.exe screenshot failure message, please inform, first thanks! if (System.IO.File.Exists (flv_img_p)) { return flv_img; } Return ""; } There is a problem is that the screenshot failed after we do not get the message of failure, the problem is still waiting for the master to solve |