-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathInfoWriterObsUtils.cpp
More file actions
43 lines (33 loc) · 1.26 KB
/
InfoWriterObsUtils.cpp
File metadata and controls
43 lines (33 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "InfoWriterObsUtils.h"
#include <obs-frontend-api.h>
std::optional<std::string> get_filename_from_recording_path(const InfoWriterSettings &Settings)
{
obs_output_t *output = obs_frontend_get_recording_output();
if (!output)
return std::nullopt;
obs_data_t *outputSettings = obs_output_get_settings(output);
obs_data_item_t *item = obs_data_item_byname(outputSettings, "url");
if (!item)
item = obs_data_item_byname(outputSettings, "path");
if (!item)
return std::nullopt;
std::string CurrentFilename = obs_data_item_get_string(item);
size_t videoextensionstart = CurrentFilename.find_last_of('.') + 1;
auto extension = Settings.GetAutomaticOutputExtension();
CurrentFilename.replace(videoextensionstart, CurrentFilename.length(), extension);
return CurrentFilename;
}
std::optional<std::string> get_filename_from_last_recording(const InfoWriterSettings &Settings)
{
char *path = obs_frontend_get_last_recording();
if (!path)
return std::nullopt;
std::string filename = path;
bfree(path);
if (filename.empty())
return std::nullopt;
size_t videoextensionstart = filename.find_last_of('.') + 1;
auto extension = Settings.GetAutomaticOutputExtension();
filename.replace(videoextensionstart, filename.length(), extension);
return filename;
}