public void Convert() { if (intStatus == ConvStates.Ready | intStatus == ConvStates.Finished | intStatus == ConvStates.Aborted) { bw.RunWorkerAsync(); //Start Conversion intStatus = ConvStates.Converting; } }
public void Cancel() { if (intStatus == ConvStates.Converting) { bw.CancelAsync(); intStatus = ConvStates.Aborted; prcFFMPEG.Kill(); //Done } }
private void CheckParameter() { if (intStatus == ConvStates.Aborted | intStatus == ConvStates.Finished | intStatus == ConvStates.ConvError) { intStatus = ConvStates.Idle; } if (intStatus == ConvStates.Idle | intStatus == ConvStates.WaitingForParams) { if ((strInFile == "" & sImageList == "") | (strInFile != "" & File.Exists(strInFile) == false) | strOutFile == "" | File.Exists(strFFMPEGPath) == false) { intStatus = ConvStates.WaitingForParams; } else { intStatus = ConvStates.Ready; } } }
private object ConvertFile() { //Function To Convert File // Dim cmd As String = " -i """ & input & """ -ar " & strOutAudio & " -b 64k -r 24 -s " & strVidSize & "-qscale " & intQuality & " -y """ & output & """" 'ffmpeg commands -y replace System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; //Disable Illegal Crossthread Calls From Controls string strOutput = strOutFile; //Output File Name string strFFMPEGOut; //Lines Read From Input / Source File strOutExt = OutTypeToStr(OutFormat); string strSource = strInFile; //ffmpeg -y -f image2 -i "C:\Users\ccumbrowski\AppData\Local\Temp\ANSIToVideoTemp\ACID-TR.ANS_%05d.PNG" -r 30 -vframes 373 -map 0:0 -pix_fmt rgb24 -s 640x400 "F:\ANSI\ANI\ACID-TR.ANS.GIF" string strFFMPEGCmd = ""; strFFMPEGCmd += " -y"; if (OutType != OutTypes.GIF) { strFFMPEGCmd += " -b:v 64k"; } if (sImageList != "") { strFFMPEGCmd += " -f image2 -i \"" + sImageList + "\" "; } else { strFFMPEGCmd += " -i \"" + strSource + "\" "; } if (dFPS != 0) { strFFMPEGCmd += " -r " + dFPS; if (OutType != OutTypes.GIF) { strFFMPEGCmd += " -force_fps"; } } if (iNumFrames != 0) { if (OutType == OutTypes.GIF) { strFFMPEGCmd += " -vframes " + iNumFrames + " -map 0:0 -pix_fmt rgb24"; } else { strFFMPEGCmd += " -frames " + iNumFrames; } } if (iHeight != 0 & iWidth != 0) { strFFMPEGCmd += " -s " + iWidth + "x" + iHeight; } if (sVCodec != "") { strFFMPEGCmd += " -vcodec " + LCase(sVCodec); } strFFMPEGCmd += " \"" + strOutput + "\""; Console.WriteLine("FFMPEG Parameters: " + strFFMPEGCmd); System.Diagnostics.ProcessStartInfo psiProcInfo = new System.Diagnostics.ProcessStartInfo(); //Proc Info Object For FFMPEG.EXE StreamReader srFFMPEG; //Reads Source File's Lines // Dim cmd As String = " -i """ & input & """ -ar " & strOutAudio & " -b 64k -r 24 -s " & strVidSize & "-qscale " & intQuality & " -y """ & output & """" 'ffmpeg commands -y replace if (strFinalOutput != "" & strFWOE != "" & strOutExt != "" & strOutAudio != "" & strVidSize != "") { strOutput = strFinalOutput + strFWOE + strOutExt; } else { //MessageBox.Show("Ensure all settings are properly made!") 'If Something Not Set //Exit Function } psiProcInfo.FileName = strFFMPEGPath; //Location Of FFMPEG.EXE psiProcInfo.Arguments = strFFMPEGCmd; //Command String psiProcInfo.UseShellExecute = false; psiProcInfo.WindowStyle = ProcessWindowStyle.Hidden; psiProcInfo.RedirectStandardError = true; psiProcInfo.RedirectStandardOutput = true; psiProcInfo.CreateNoWindow = true; prcFFMPEG.StartInfo = psiProcInfo; prcFFMPEG.Start(); //Start Process // srFFMPEG = prcFFMPEG.StandardError; //Enable Error Checking For FFMPEG.EXE //Me.btnStart.Enabled = False do { //Cancelled? if (bw.CancellationPending) { return(1); } strFFMPEGOut = srFFMPEG.ReadLine(); //Read Source File Line By Line } while (!(prcFFMPEG.HasExited & strFFMPEGOut == null | strFFMPEGOut == "")); //Read Until There Is Nothing Left intStatus = ConvStates.Finished; return(0); }
public VideoConverterFFMPEG() { strFFMPEGPath = "C:\\Documents\\VisualStudioProjects\\DirectShowVideoTest\\ffmpeg.exe"; intStatus = ConvStates.WaitingForParams; }