Protected Void Button#click ( Object Sender, eventargs E)
{
String Ffmpegarguments = @" -I d: \ Li Ge. wmv-AB 56-ar 22050-B 500-R 15-s 320x240 D: \ Li Ge. FLV " ;
// Processstartinfo info = new processstartinfo ("D:/FFMPEG", ffmpegarguments );
// Process. Start (Info );
PROCESS p = New Process (); // The process class has a startinfo atomicity. This is processstartinfo class, which includes some attention and Methods. Below we use its attention:
P. startinfo. filename = " D:/FFMPEG/ffmpeg.exe " ; // SetProgramName
P. startinfo. Arguments = ffmpegarguments; // Set the number of dynamic rows in the program
P. startinfo. useshellexecute = False ; // Use of Shell
P. startinfo. redirectstandardinput = True ; // Redirect to ingress
P. startinfo. redirectstandardoutput = True ; // Redirect to outbound
P. startinfo. redirectstandarderror = True ; // Redirect zookeeper outbound
P. startinfo. createnowindow = True ; // Display window for setting no parameters
P. Start (); // Operation
// P. standardinput. writeline (ffmpegarguments ); // You can also use this method to export the command to be executed.
// P. standardinput. writeline ("exit "); // But remember to add exit, or else the next line of program will become available when the program crashes.
}
/**/ /// Convert video (AVI, mov, etc.) to FLV format
/// </Summary>
/// <Param name = "fromname"> Converted video file </Param>
/// <Param name = "exportname"> Name of the converted FLV File </Param>
/// <Param name = "exportname"> Video size </Param>
/// <Returns> </returns>
Public String Videoconvertflv ( String Fromname, String Exportname, String Widthandheight)
{
String FFmpeg = @" D: \ FFMPEG \ ffmpeg.exe " ;
System. Diagnostics. processstartinfo startinfo =New System. Diagnostics. processstartinfo (FFMPEG );
Startinfo. windowstyle = system. Diagnostics. processwindowstyle. hidden;
// Startinfo. arguments = "-I" + server. mappath (fromname) + "-AB 56-ar 22050-B 500-R 15-s" + widthandheight + "" + server. mappath (exportname );
Startinfo. Arguments = " -I " + Fromname + " -AB 56-ar 22050-B 500-R 15-S " + Widthandheight +" " + Exportname;
Try
{
System. Diagnostics. process. Start (startinfo );
Return Exportname;
}
Catch (Exception ERR)
{
Return Err. message;
}
}
/**/ /// <Summary>
/// Capture a frame from the video screen as an image
/// </Summary>
/// <Param name = "videoname"> Video file PIC/Guiyu. mov </Param>
/// <Param name = "widthandheight"> The image size is 240*180. </Param>
/// <Param name = "cuttimeframe"> The start time of the screenshot, for example, "1" </Param>
/// <Returns> </returns>
Public String Getpicfromvideo ( String Videoname, String Widthandheight,String Cuttimeframe)
{
String FFmpeg = @" C: inetpubwwwrootdemopic fmpeg.exe " ;
String Picname = server. mappath (guid. newguid (). tostring (). Replace ( " - " , "" ) + " . Jpg " );
System. Diagnostics. processstartinfo startinfo = New System. Diagnostics. processstartinfo (FFMPEG );
Startinfo. windowstyle = system. Diagnostics. processwindowstyle. hidden;
Startinfo. Arguments = " -I " + Server. mappath (videoname) + " -Y-F image2-SS " + Cuttimeframe + " -T 0.001-S " + Widthandheight + " " + Picname;
Try
{
System. Diagnostics. process. Start (startinfo );
Return Picname;
}
Catch (Exception ERR)
{
Return Err. message;
}
}