Merge pull request #1904 from exeldro/filename_format
libobs: Add video info to filename formatting
This commit is contained in:
commit
e9a50aa392
@ -763,10 +763,10 @@ Basic.Settings.Output.Adv.FFmpeg.GOPSize="Keyframe interval (frames)"
|
||||
Basic.Settings.Output.Adv.FFmpeg.IgnoreCodecCompat="Show all codecs (even if potentially incompatible)"
|
||||
|
||||
# basic mode 'output' settings - advanced section - recording subsection - completer
|
||||
FilenameFormatting.completer="%CCYY-%MM-%DD %hh-%mm-%ss\n%YY-%MM-%DD %hh-%mm-%ss\n%Y-%m-%d %H-%M-%S\n%y-%m-%d %H-%M-%S\n%a %Y-%m-%d %H-%M-%S\n%A %Y-%m-%d %H-%M-%S\n%Y-%b-%d %H-%M-%S\n%Y-%B-%d %H-%M-%S\n%Y-%m-%d %I-%M-%S-%p\n%Y-%m-%d %H-%M-%S-%z\n%Y-%m-%d %H-%M-%S-%Z"
|
||||
FilenameFormatting.completer="%CCYY-%MM-%DD %hh-%mm-%ss\n%YY-%MM-%DD %hh-%mm-%ss\n%Y-%m-%d %H-%M-%S\n%y-%m-%d %H-%M-%S\n%a %Y-%m-%d %H-%M-%S\n%A %Y-%m-%d %H-%M-%S\n%Y-%b-%d %H-%M-%S\n%Y-%B-%d %H-%M-%S\n%Y-%m-%d %I-%M-%S-%p\n%Y-%m-%d %H-%M-%S-%z\n%Y-%m-%d %H-%M-%S-%Z\n%FPS\n%CRES\n%ORES\n%VF"
|
||||
|
||||
# basic mode 'output' settings - advanced section - recording subsection - TT
|
||||
FilenameFormatting.TT="%CCYY Year, four digits\n%YY Year, last two digits (00-99)\n%MM Month as a decimal number (01-12)\n%DD Day of the month, zero-padded (01-31)\n%hh Hour in 24h format (00-23)\n%mm Minute (00-59)\n%ss Second (00-61)\n%% A % sign\n%a Abbreviated weekday name\n%A Full weekday name\n%b Abbreviated month name\n%B Full month name\n%d Day of the month, zero-padded (01-31)\n%H Hour in 24h format (00-23)\n%I Hour in 12h format (01-12)\n%m Month as a decimal number (01-12)\n%M Minute (00-59)\n%p AM or PM designation\n%S Second (00-61)\n%y Year, last two digits (00-99)\n%Y Year\n%z ISO 8601 offset from UTC in timezone\n%Z Timezone name or abbreviation\n"
|
||||
FilenameFormatting.TT="%CCYY Year, four digits\n%YY Year, last two digits (00-99)\n%MM Month as a decimal number (01-12)\n%DD Day of the month, zero-padded (01-31)\n%hh Hour in 24h format (00-23)\n%mm Minute (00-59)\n%ss Second (00-61)\n%% A % sign\n%a Abbreviated weekday name\n%A Full weekday name\n%b Abbreviated month name\n%B Full month name\n%d Day of the month, zero-padded (01-31)\n%H Hour in 24h format (00-23)\n%I Hour in 12h format (01-12)\n%m Month as a decimal number (01-12)\n%M Minute (00-59)\n%p AM or PM designation\n%S Second (00-61)\n%y Year, last two digits (00-99)\n%Y Year\n%z ISO 8601 offset from UTC in timezone\n%Z Timezone name or abbreviation\n%FPS Frames per second\n%CRES Base (canvas) resolution\n%ORES Output (scaled) resolution\n%VF Video format"
|
||||
|
||||
# basic mode 'video' settings
|
||||
Basic.Settings.Video="Video"
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "bmem.h"
|
||||
#include "utf8.h"
|
||||
#include "dstr.h"
|
||||
#include "obs.h"
|
||||
|
||||
FILE *os_wfopen(const wchar_t *path, const char *mode)
|
||||
{
|
||||
@ -708,6 +709,8 @@ char *os_generate_formatted_filename(const char *extension, bool space,
|
||||
time_t now = time(0);
|
||||
struct tm *cur_time;
|
||||
cur_time = localtime(&now);
|
||||
struct obs_video_info ovi;
|
||||
obs_get_video_info(&ovi);
|
||||
|
||||
const size_t spec_count = 23;
|
||||
static const char *spec[][2] = {
|
||||
@ -728,11 +731,10 @@ char *os_generate_formatted_filename(const char *extension, bool space,
|
||||
dstr_init_copy(&sf, format);
|
||||
|
||||
while (pos < sf.len) {
|
||||
const char *cmp = sf.array + pos;
|
||||
for (size_t i = 0; i < spec_count && !convert[0]; i++) {
|
||||
size_t len = strlen(spec[i][0]);
|
||||
|
||||
const char *cmp = sf.array + pos;
|
||||
|
||||
if (astrcmp_n(cmp, spec[i][0], len) == 0) {
|
||||
if (strlen(spec[i][1]))
|
||||
strftime(convert, sizeof(convert),
|
||||
@ -747,6 +749,35 @@ char *os_generate_formatted_filename(const char *extension, bool space,
|
||||
}
|
||||
}
|
||||
|
||||
if (!convert[0]) {
|
||||
if (astrcmp_n(cmp, "%FPS", 4) == 0) {
|
||||
if (ovi.fps_den <= 1) {
|
||||
sprintf(convert, "%u", ovi.fps_num);
|
||||
} else {
|
||||
const double obsFPS =
|
||||
(double)ovi.fps_num /
|
||||
(double)ovi.fps_den;
|
||||
sprintf(convert, "%.2f", obsFPS);
|
||||
}
|
||||
replace_text(&sf, pos, 4, convert);
|
||||
|
||||
} else if (astrcmp_n(cmp, "%CRES", 5) == 0) {
|
||||
sprintf(convert, "%ux%u", ovi.base_width,
|
||||
ovi.base_height);
|
||||
replace_text(&sf, pos, 5, convert);
|
||||
|
||||
} else if (astrcmp_n(cmp, "%ORES", 5) == 0) {
|
||||
sprintf(convert, "%ux%u", ovi.output_width,
|
||||
ovi.output_height);
|
||||
replace_text(&sf, pos, 5, convert);
|
||||
|
||||
} else if (astrcmp_n(cmp, "%VF", 3) == 0) {
|
||||
strcpy(convert, get_video_format_name(
|
||||
ovi.output_format));
|
||||
replace_text(&sf, pos, 3, convert);
|
||||
}
|
||||
}
|
||||
|
||||
if (convert[0]) {
|
||||
pos += strlen(convert);
|
||||
convert[0] = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user