UI: Update configs for new FFmpeg output changes
If a user was using FFmpeg output before pathc 0.12.0, they had to type in the full file name to the FFmpeg output URL/Path box, which isn't exactly compatible with the new settings. This changes each profile's config file so that the FFmpeg output detects whether files are used, and then extracts the file's directory and extension and sets them accordingly to make it compatible with the new FFmpeg file output handling.
This commit is contained in:
parent
75dcd1ffa3
commit
0ce756acba
@ -1211,6 +1211,83 @@ static void move_to_xdg(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void update_ffmpeg_output(const char *path)
|
||||
{
|
||||
ConfigFile config;
|
||||
|
||||
if (config.Open(path, CONFIG_OPEN_EXISTING) != CONFIG_SUCCESS)
|
||||
return;
|
||||
|
||||
if (config_has_user_value(config, "AdvOut", "FFOutputToFile"))
|
||||
return;
|
||||
|
||||
const char *url = config_get_string(config, "AdvOut", "FFURL");
|
||||
if (!url)
|
||||
return;
|
||||
|
||||
bool isActualURL = strstr(url, "://") != nullptr;
|
||||
if (isActualURL)
|
||||
return;
|
||||
|
||||
string urlStr = url;
|
||||
string extension;
|
||||
|
||||
for (size_t i = urlStr.length(); i > 0; i--) {
|
||||
size_t idx = i - 1;
|
||||
|
||||
if (urlStr[idx] == '.') {
|
||||
extension = &urlStr[i];
|
||||
}
|
||||
|
||||
if (urlStr[idx] == '\\' || urlStr[idx] == '/') {
|
||||
urlStr[idx] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (urlStr.empty() || extension.empty())
|
||||
return;
|
||||
|
||||
config_remove_value(config, "AdvOut", "FFURL");
|
||||
config_set_string(config, "AdvOut", "FFFilePath", urlStr.c_str());
|
||||
config_set_string(config, "AdvOut", "FFExtension", extension.c_str());
|
||||
config_set_bool(config, "AdvOut", "FFOutputToFile", true);
|
||||
config_save(config);
|
||||
}
|
||||
|
||||
static void update_ffmpeg_outputs(void)
|
||||
{
|
||||
char path[512];
|
||||
int pathlen = GetConfigPath(path, 512, "obs-studio/basic/profiles");
|
||||
|
||||
if (pathlen <= 0)
|
||||
return;
|
||||
if (!os_file_exists(path))
|
||||
return;
|
||||
|
||||
os_dir_t *dir = os_opendir(path);
|
||||
if (!dir)
|
||||
return;
|
||||
|
||||
struct os_dirent *ent = os_readdir(dir);
|
||||
|
||||
while (ent) {
|
||||
if (ent->directory) {
|
||||
strcat(path, "/");
|
||||
strcat(path, ent->d_name);
|
||||
strcat(path, "/basic.ini");
|
||||
|
||||
update_ffmpeg_output(path);
|
||||
|
||||
path[pathlen] = 0;
|
||||
}
|
||||
|
||||
ent = os_readdir(dir);
|
||||
}
|
||||
|
||||
os_closedir(dir);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifndef _WIN32
|
||||
@ -1244,6 +1321,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
update_ffmpeg_outputs();
|
||||
|
||||
fstream logFile;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user