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) if (first_run)
{ {
av_register_all(); av_register_all();
avformat_network_init();
first_run = false; first_run = false;
} }
} }
@ -98,35 +99,40 @@ bool AVIDump::CreateVideoFile()
{ {
const std::string& s_format = g_Config.sDumpFormat; const std::string& s_format = g_Config.sDumpFormat;
std::stringstream file_ss; std::string s_dump_path = g_Config.sDumpPath;
file_ss << File::GetUserPath(D_DUMPFRAMES_IDX)
<< "framedump" << s_file_index
<< "." << s_format;
std::string filename = file_ss.str();
File::CreateFullPath(filename);
// Ask to delete file if (s_dump_path.empty())
if (File::Exists(filename))
{ {
if (SConfig::GetInstance().m_DumpFramesSilent || std::stringstream file_ss;
AskYesNoT("Delete the existing file '%s'?", filename.c_str())) file_ss << File::GetUserPath(D_DUMPFRAMES_IDX)
<< "framedump" << s_file_index
<< "." << s_format;
s_dump_path = file_ss.str();
File::CreateFullPath(s_dump_path);
// Ask to delete file
if (File::Exists(s_dump_path))
{ {
File::Delete(filename); if (SConfig::GetInstance().m_DumpFramesSilent ||
} AskYesNoT("Delete the existing file '%s'?", s_dump_path.c_str()))
else {
{ File::Delete(s_dump_path);
// Stop and cancel dumping the video }
return false; else
{
// Stop and cancel dumping the video
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) if (!output_format)
{ {
WARN_LOG(VIDEO, "Invalid format %s", s_format.c_str()); WARN_LOG(VIDEO, "Invalid format %s", s_format.c_str());
return false; 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()); 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; 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("UseFFV1", &bUseFFV1, false);
settings->Get("DumpFormat", &sDumpFormat, "avi"); settings->Get("DumpFormat", &sDumpFormat, "avi");
settings->Get("DumpCodec", &sDumpCodec, ""); settings->Get("DumpCodec", &sDumpCodec, "");
settings->Get("DumpPath", &sDumpPath, "");
settings->Get("BitrateKbps", &iBitrateKbps, 2500); settings->Get("BitrateKbps", &iBitrateKbps, 2500);
settings->Get("InternalResolutionFrameDumps", &bInternalResolutionFrameDumps, false); settings->Get("InternalResolutionFrameDumps", &bInternalResolutionFrameDumps, false);
settings->Get("EnablePixelLighting", &bEnablePixelLighting, false); settings->Get("EnablePixelLighting", &bEnablePixelLighting, false);

View File

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