src/: fail --load-tape-create-video if video encoding fails.
Also fail video encoding if output file already exists.
This commit is contained in:
parent
dd7cbf56cc
commit
dd9f4ac890
3 changed files with 45 additions and 18 deletions
|
@ -1783,13 +1783,15 @@ bool loadTapeContinuous(
|
|||
{
|
||||
continuous->m_replay_fixed_dt_prev = -1;
|
||||
}
|
||||
if (continuous->m_replay_create_video)
|
||||
|
||||
bool ok = true;
|
||||
if (ok && continuous->m_replay_create_video)
|
||||
{
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "Replaying with create-video");
|
||||
auto view_mgr = globals->get_subsystem<FGViewMgr>();
|
||||
if (view_mgr)
|
||||
{
|
||||
view_mgr->video_start(
|
||||
ok = view_mgr->video_start(
|
||||
"" /*name*/,
|
||||
"" /*codec*/,
|
||||
-1 /*quality*/,
|
||||
|
@ -1797,9 +1799,14 @@ bool loadTapeContinuous(
|
|||
0 /*bitrate*/
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "Cannot handle create_video=true because FGViewMgr not available");
|
||||
ok = false;
|
||||
}
|
||||
replay_internal.start(true /*new_tape*/);
|
||||
return true;
|
||||
}
|
||||
if (ok) ok = replay_internal.start(true /*new_tape*/);
|
||||
return ok;
|
||||
}
|
||||
|
||||
/** Read a flight recorder tape with given filename from disk.
|
||||
|
|
|
@ -366,7 +366,7 @@ FGViewMgr::add_view( flightgear::View * v )
|
|||
v->init();
|
||||
}
|
||||
|
||||
void FGViewMgr::video_start(
|
||||
bool FGViewMgr::video_start(
|
||||
const std::string& name_in,
|
||||
const std::string& codec_in,
|
||||
double quality,
|
||||
|
@ -413,6 +413,11 @@ void FGViewMgr::video_start(
|
|||
SGPath path = SGPath(fgGetString("/sim/video/directory"));
|
||||
SGPath path_link = path;
|
||||
path.append(name);
|
||||
if (path.exists())
|
||||
{
|
||||
videoEncodingError("Video encoding failure, output file already exists: " + path.str());
|
||||
return false;
|
||||
}
|
||||
path_link.append(name_link);
|
||||
path_link.remove();
|
||||
bool ok = path_link.makeLink(path.file());
|
||||
|
@ -464,7 +469,9 @@ void FGViewMgr::video_start(
|
|||
catch (std::exception& e)
|
||||
{
|
||||
videoEncodingError(e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void FGViewMgr::video_stop()
|
||||
|
|
|
@ -94,25 +94,38 @@ public:
|
|||
|
||||
void add_view( flightgear::View * v );
|
||||
|
||||
// Start video encoding to <path>.
|
||||
// Start video encoding of main window.
|
||||
//
|
||||
// If <name> is "" we generate a name containing current date and time.
|
||||
//
|
||||
// If <codec> is "" we use /sim/video/codec.
|
||||
//
|
||||
// If quality is -1 we use /sim/video/quality; similarly for speed. If
|
||||
// bitrate is 0 we use /sim/video/bitrate.
|
||||
// name
|
||||
// Name of output file or "" to generate a name containing current
|
||||
// date and time and /sim/video/container. List of supported
|
||||
// containers can be found with 'ffmpeg -formats'.
|
||||
// codec_name
|
||||
// Name of codec or "" to use /sim/video/codec. Passed to
|
||||
// avcodec_find_encoder_by_name(). List of supported codecs can be
|
||||
// found with 'ffmpeg -codecs'.
|
||||
// quality
|
||||
// Encoding quality in range 0..1 or -1 to use /sim/video/quality.
|
||||
// speed:
|
||||
// Encoding speed in range 0..1 or -1 to use /sim/video/speed.
|
||||
// bitrate
|
||||
// Target bitratae in bits/sec or -1 to use /sim/video/bitrate.
|
||||
//
|
||||
// We show popup warning if values are out of range - quality and speed
|
||||
// must be -1 or 0-1, bitrate must be >= 0.
|
||||
//
|
||||
void video_start(
|
||||
const std::string& name,
|
||||
const std::string& codec,
|
||||
double quality,
|
||||
double speed,
|
||||
int bitrate
|
||||
// Returns false if we fail to start video encoding.
|
||||
//
|
||||
bool video_start(
|
||||
const std::string& name="",
|
||||
const std::string& codec="",
|
||||
double quality=-1,
|
||||
double speed=-1,
|
||||
int bitrate=0
|
||||
);
|
||||
|
||||
// Stop video encoding of main window.
|
||||
//
|
||||
void video_stop();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue