diff --git a/Source/Core/VideoCommon/AVIDump.cpp b/Source/Core/VideoCommon/AVIDump.cpp index ccf355c712..2ee3747bb6 100644 --- a/Source/Core/VideoCommon/AVIDump.cpp +++ b/Source/Core/VideoCommon/AVIDump.cpp @@ -58,6 +58,7 @@ static void InitAVCodec() if (first_run) { av_register_all(); + avformat_network_init(); first_run = false; } } @@ -98,35 +99,40 @@ bool AVIDump::CreateVideoFile() { const std::string& s_format = g_Config.sDumpFormat; - 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); + std::string s_dump_path = g_Config.sDumpPath; - // Ask to delete file - if (File::Exists(filename)) + if (s_dump_path.empty()) { - if (SConfig::GetInstance().m_DumpFramesSilent || - AskYesNoT("Delete the existing file '%s'?", filename.c_str())) + std::stringstream file_ss; + 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); - } - else - { - // Stop and cancel dumping the video - return false; + if (SConfig::GetInstance().m_DumpFramesSilent || + AskYesNoT("Delete the existing file '%s'?", s_dump_path.c_str())) + { + File::Delete(s_dump_path); + } + 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) { 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; diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index fd8c6ea939..7e5f04f1db 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -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); diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index ed8b7827cc..dfab8bbcc3 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -104,6 +104,7 @@ struct VideoConfig final bool bUseFFV1; std::string sDumpCodec; std::string sDumpFormat; + std::string sDumpPath; bool bInternalResolutionFrameDumps; bool bFreeLook; bool bBorderlessFullscreen;