Explorar o código

Add Timeout to FFMPEG commands

JDierkse %!s(int64=2) %!d(string=hai) anos
pai
achega
cacf6cfdca

+ 1 - 1
Recorder/FoscamRecorder.cpp

@@ -128,7 +128,7 @@ std::string FoscamRecorder::Video(ctpl::thread_pool* pThreadPool, const std::str
 	std::string fileName = GetFileName(m_settings, "mp4", dateTimeString);
 
 	std::stringstream command;
-	command << ffmpeg << " -i \"" << url.str() << "\" -t 30 -c:v copy -an -strict experimental " << fileName << " > /dev/null 2>&1 ; " << ffmpeg << " -i " << fileName << " -vf \"select=eq(n\\,0)\" -q:v 3 " << fileName << ".jpg > /dev/null 2>&1";
+	command << ffmpeg << " -i \"" << url.str() << "\" -t 30 -timeout 60 -c:v copy -an -strict experimental " << fileName << " > /dev/null 2>&1 ; " << ffmpeg << " -i " << fileName << " -vf \"select=eq(n\\,0)\" -q:v 3 " << fileName << ".jpg > /dev/null 2>&1";
 
 	std::string cmd(command.str());
 	Logging::Log(Logging::Severity::Debug, cmd);

+ 1 - 1
Recorder/RTSPRecorder.cpp

@@ -120,7 +120,7 @@ std::string RTSPRecorder::Video(ctpl::thread_pool* pThreadPool, const std::strin
 	std::string fileName = GetFileName(m_settings, "mp4", dateTimeString, 0);
 
 	std::stringstream command;
-	command << ffmpeg << " -rtsp_transport tcp -i \"" << url.str() << "\" -t 30 -c:v copy -strict experimental " << fileName << " > /dev/null 2>&1 ; " << ffmpeg << " -i " << fileName << " -vf \"select=eq(n\\,0)\" -q:v 3 " << fileName << ".jpg > /dev/null 2>&1";
+	command << ffmpeg << " -rtsp_transport tcp -i \"" << url.str() << "\" -t 30 -timeout 60 -c:v copy -strict experimental " << fileName << " > /dev/null 2>&1 ; " << ffmpeg << " -i " << fileName << " -vf \"select=eq(n\\,0)\" -q:v 3 " << fileName << ".jpg > /dev/null 2>&1";
 
 	std::string cmd(command.str());
 	Logging::Log(Logging::Severity::Debug, cmd);

+ 1 - 1
Recorder/VStarCamRecorder.cpp

@@ -123,7 +123,7 @@ std::string VStarCamRecorder::Video(ctpl::thread_pool* pThreadPool, const std::s
 	std::string fileName = GetFileName(m_settings, "mp4", dateTimeString, 0);
 
 	std::stringstream command;
-	command << ffmpeg << " -i \"" << url.str() << "\" -t 30 -c:v copy -c:a aac -strict experimental " << fileName << " > /dev/null 2>&1 ; " << ffmpeg << " -i " << fileName << " -vf \"select=eq(n\\,0)\" -q:v 3 " << fileName << ".jpg > /dev/null 2>&1";
+	command << ffmpeg << " -i \"" << url.str() << "\" -t 30 -timeout 60 -c:v copy -c:a aac -strict experimental " << fileName << " > /dev/null 2>&1 ; " << ffmpeg << " -i " << fileName << " -vf \"select=eq(n\\,0)\" -q:v 3 " << fileName << ".jpg > /dev/null 2>&1";
 
 	std::string cmd(command.str());
 	Logging::Log(Logging::Severity::Debug, cmd);

+ 1 - 1
Recorder/WatchBotRecorder.cpp

@@ -125,7 +125,7 @@ std::string WatchBotRecorder::Video(ctpl::thread_pool* pThreadPool, const std::s
 	std::string fileName = GetFileName(m_settings, "mp4", dateTimeString);
 
 	std::stringstream command;
-	command << ffmpeg << " -i \"" << url.str() << "\" -t 30 -c:v libx264 -pix_fmt yuv420p -profile:v main -level:v 3.1 -c:a aac -strict experimental " << fileName << " > /dev/null 2>&1 ; " << ffmpeg << " -i " << fileName << " -vf \"select=eq(n\\,0)\" -q:v 3 " << fileName << ".jpg > /dev/null 2>&1";
+	command << ffmpeg << " -i \"" << url.str() << "\" -t 30 -timeout 60 -c:v libx264 -pix_fmt yuv420p -profile:v main -level:v 3.1 -c:a aac -strict experimental " << fileName << " > /dev/null 2>&1 ; " << ffmpeg << " -i " << fileName << " -vf \"select=eq(n\\,0)\" -q:v 3 " << fileName << ".jpg > /dev/null 2>&1";
 
 	std::string cmd(command.str());
 	Logging::Log(Logging::Severity::Debug, cmd);