-
-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Wasn't sure where to put this not actually a fork but a suggestion. I have added ffmpeg to the source in a folder. Now instead of having some search for ffmpeg.exe the code loads it automatically. I will show the code below. Note ffmpeg folder is not in the bin directory so I had to figure out a way to remove bin/ etc I am sure there is a better way but this worked for me.
` string executableName = Application.ExecutablePath;
FileInfo executableFileInfo = new FileInfo(executableName);
string executableDirectoryName = executableFileInfo.DirectoryName;
string parentName = executableFileInfo.Directory.Parent.FullName;
string PathName = parentName.Remove(parentName.LastIndexOf("\", parentName.Length));
String ffmpegPath = PathName + "\FFmpeg\ffmpeg.exe";
//Set the path to ffmpeg in app config based on the end users path which is unknown.
Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
config.AppSettings.Settings["FFMPEG_PATH"].Value = ffmpegPath;
config.Save(ConfigurationSaveMode.Modified);
var ffmpeg = ConfigurationManager.AppSettings["FFMPEG_PATH"];
//Eliminate all code below as its not needed any more
//if(!File.Exists(ffmpeg))
//{
// simpleLogger.LogMessage("No FFMpeg found, prompting user");
// MessageBox.Show(this, //Resources.Form1_Form1_This_application_uses_FFMPEG_for_it_s_conversion__Please_select_where_//ffmpeg_exe_can_be_found, Resources.Form1_Form1_Missing_FFMPEG, MessageBoxButtons.OK, //MessageBoxIcon.Error);
// var dialog = new OpenFileDialog();
// var result = dialog.ShowDialog();
// if (result == DialogResult.OK)
// {
// ffmpeg = dialog.FileName;
// ConfigurationManager.AppSettings["FFMPEG_PATH"] = ffmpeg;
// MessageBox.Show(this, $"To make this change permanent please write the //following text in the .config file at the "FFMPEG_PATH" key:\n{ffmpeg}");
// }
// else
// {
// MessageBox.Show(this, //Resources.Form1_Form1_Without_FFMPEG_this_application_is_useless__closing_down, //Resources.Form1_Form1_Missing_FFMPEG, MessageBoxButtons.OK, MessageBoxIcon.Error);
// return false;
// }
//}.
`
//Full form code loaded below in a file
Form1.zip