Dump to arbitrary URLs.

This commit is contained in:
Vlad Firoiu 2017-02-21 11:37:36 -08:00
parent 21e66e60e3
commit f82e3de763
3 changed files with 26 additions and 18 deletions

View File

@ -58,6 +58,7 @@ static void InitAVCodec()
if (first_run)
{
av_register_all();
avformat_network_init();
first_run = false;
}
}
@ -98,20 +99,24 @@ bool AVIDump::CreateVideoFile()
{
const std::string& s_format = g_Config.sDumpFormat;
std::string s_dump_path = g_Config.sDumpPath;
if (s_dump_path.empty())
{
std::stringstream file_ss;
file_ss << File::GetUserPath(D_DUMPFRAMES_IDX)
<< "framedump" << s_file_index
<< "." << s_format;
std::string filename = file_ss.str();
File::CreateFullPath(filename);
s_dump_path = file_ss.str();
File::CreateFullPath(s_dump_path);
// Ask to delete file
if (File::Exists(filename))
if (File::Exists(s_dump_path))
{
if (SConfig::GetInstance().m_DumpFramesSilent ||
AskYesNoT("Delete the existing file '%s'?", filename.c_str()))
AskYesNoT("Delete the existing file '%s'?", s_dump_path.c_str()))
{
File::Delete(filename);
File::Delete(s_dump_path);
}
else
{
@ -119,14 +124,15 @@ bool AVIDump::CreateVideoFile()
return false;
}
}
}
AVOutputFormat* output_format = av_guess_format(s_format.c_str(), filename.c_str(), nullptr);
AVOutputFormat* output_format = av_guess_format(s_format.c_str(), s_dump_path.c_str(), nullptr);
if (!output_format)
{
WARN_LOG(VIDEO, "Invalid format %s", s_format.c_str());
return false;
}
avformat_alloc_output_context2(&s_format_context, output_format, nullptr, filename.c_str());
avformat_alloc_output_context2(&s_format_context, output_format, nullptr, s_dump_path.c_str());
const AVCodecDescriptor* codec_desc = avcodec_descriptor_get_by_name(g_Config.sDumpCodec.c_str());
AVCodecID codec_id = codec_desc ? codec_desc->id : output_format->video_codec;

View File

@ -77,6 +77,7 @@ void VideoConfig::Load(const std::string& ini_file)
settings->Get("UseFFV1", &bUseFFV1, false);
settings->Get("DumpFormat", &sDumpFormat, "avi");
settings->Get("DumpCodec", &sDumpCodec, "");
settings->Get("DumpPath", &sDumpPath, "");
settings->Get("BitrateKbps", &iBitrateKbps, 2500);
settings->Get("InternalResolutionFrameDumps", &bInternalResolutionFrameDumps, false);
settings->Get("EnablePixelLighting", &bEnablePixelLighting, false);

View File

@ -104,6 +104,7 @@ struct VideoConfig final
bool bUseFFV1;
std::string sDumpCodec;
std::string sDumpFormat;
std::string sDumpPath;
bool bInternalResolutionFrameDumps;
bool bFreeLook;
bool bBorderlessFullscreen;