Skip to content

Commit 54a95c8

Browse files
committed
[GL] Deal with non existing path for ffmprg in VideoRecorderFFMPEG (#5870)
Take special case where given path isn't empty but doesn't point to a real file
1 parent 87f859e commit 54a95c8

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Sofa/GL/src/sofa/gl/VideoRecorderFFMPEG.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,23 @@ bool VideoRecorderFFMPEG::init(const std::string& ffmpeg_exec_filepath, const st
8787
m_ffmpegBuffer = new unsigned char [m_ffmpegBufferSize];
8888

8989
m_FrameCount = 0;
90-
90+
std::string extension;
91+
#ifdef WIN32
92+
extension = ".exe";
93+
#endif
9194
m_ffmpegExecPath = ffmpeg_exec_filepath;
9295
if(m_ffmpegExecPath.empty())
9396
{
94-
std::string extension;
95-
#ifdef WIN32
96-
extension = ".exe";
97-
#endif
9897
m_ffmpegExecPath = helper::Utils::getExecutablePath() + "/ffmpeg" + extension;
99-
if(!FileSystem::isFile(m_ffmpegExecPath, true))
100-
{
101-
msg_warning("VideoRecorderFFMPEG")<< "ffmpeg hasn't been found automatically. Falling back to simply calling ffmpeg"<< extension <<" and hope that the OS finds it on its own. " ;
102-
// Fallback to a relative FFMPEG (may be in system or exposed in PATH)
103-
m_ffmpegExecPath = "ffmpeg" + extension;
104-
}
98+
}
99+
if(!FileSystem::isFile(m_ffmpegExecPath, true))
100+
{
101+
msg_warning("VideoRecorderFFMPEG")<< "ffmpeg hasn't been found automatically. Falling back to simply calling ffmpeg"<< extension <<" and hope that the OS finds it on its own. " ;
102+
// Fallback to a relative FFMPEG (may be in system or exposed in PATH)
103+
m_ffmpegExecPath = "ffmpeg" + extension;
105104
}
106105

106+
107107
std::stringstream ss;
108108
ss << m_ffmpegExecPath
109109
<< " -r " << m_framerate
@@ -123,6 +123,7 @@ bool VideoRecorderFFMPEG::init(const std::string& ffmpeg_exec_filepath, const st
123123
#else
124124
m_ffmpeg = popen(command_line.c_str(), "w");
125125
#endif
126+
126127
if (m_ffmpeg == nullptr) {
127128
msg_error("VideoRecorderFFMPEG") << "ffmpeg process failed to open (error " << errno << "). Command line : " << command_line;
128129
return false;

0 commit comments

Comments
 (0)