From 9ba8166ae8c0a8974496ebda0689ca384a18bbbf Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 22 Dec 2020 22:21:48 +0100 Subject: [PATCH] Cache ffmpeg/transcoder paths This significantly speeds up loading export formats that use ffmpeg. A single call to ::transcoder_exe() took 300-400ms on Windows. With multiple formats using an external transcoder, showing the export dialog could take to 2-3 sec. --- libs/ardour/video_tools_paths.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libs/ardour/video_tools_paths.cc b/libs/ardour/video_tools_paths.cc index 4a663da07a..2fab46cc46 100644 --- a/libs/ardour/video_tools_paths.cc +++ b/libs/ardour/video_tools_paths.cc @@ -144,6 +144,16 @@ ArdourVideoToolPaths::xjadeo_exe (std::string &xjadeo_exe) bool ArdourVideoToolPaths::transcoder_exe (std::string &ffmpeg_exe, std::string &ffprobe_exe) { + static bool _cached = false; + static std::string _ffmpeg_exe; + static std::string _ffprobe_exe; + + if (_cached) { + ffmpeg_exe = _ffmpeg_exe; + ffprobe_exe = _ffprobe_exe; + return true; + } + #ifdef PLATFORM_WINDOWS std::string reg; std::string program_files = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILES); @@ -201,6 +211,11 @@ ArdourVideoToolPaths::transcoder_exe (std::string &ffmpeg_exe, std::string &ffpr if (ffmpeg_exe.empty() || ffprobe_exe.empty()) { return false; } + + _cached = true; + _ffmpeg_exe = ffmpeg_exe; + _ffprobe_exe = ffprobe_exe; + return true; }