feat: video reconnect cli arg

This commit is contained in:
2026-05-11 08:36:32 +02:00
parent 7d99c617ef
commit dfefe879c9
4 changed files with 34 additions and 8 deletions
+6 -2
View File
@@ -175,14 +175,16 @@ These are configurable in the [`forge_project.cfg`](#forge_projectcfg).
### CLI arguments ### CLI arguments
```txt ```txt
usage: forge [-h] [-v] [-p=PROJECT_PATH] [-c=CFG_FILE] [-hr] [-s=SCREEN] [-m=SCREEN] [-mo] [-w] [-t=TEMPO] [-d] [-ar / -nar] [-arc=CYCLES] [-vi=FILE] [-vs=SIZE] [-is=SIZE] [-ls / -nls] [-ss / -nss] [-tm] [-tf] forge steel-dev
usage: forge [-h] [-v] [-p=PROJECT_PATH] [-c=CFG_FILE] [-hr] [-s=SCREEN] [-m=SCREEN] [-mo] [-w] [-t=TEMPO] [-d] [-ar / -nar] [-arc=CYCLES] [-vi=FILE] [-vs=SIZE] [-vr / -nvr] [-is=SIZE] [-ls / -nls] [-ss / -nss] [-tm] [-tf]
Fusion Of Real-time Generative Effects. Fusion Of Real-time Generative Effects.
options: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-v, --version print version -v, --version print version
-p, --project forge project directory (default: /usr/share/forge/default) -p, --project forge project directory (default: ./default)
-c, --config config file name (default: forge_project.cfg) -c, --config config file name (default: forge_project.cfg)
-hr, --hot-reload hot reload of shaders scripts -hr, --hot-reload hot reload of shaders scripts
-s, --screen output screen number (default: primary) -s, --screen output screen number (default: primary)
@@ -196,6 +198,8 @@ options:
-arc, --auto-random-cycle auto random cycle length (default: 4) -arc, --auto-random-cycle auto random cycle length (default: 4)
-vi, --video-in path to video capture device (multiple allowed) -vi, --video-in path to video capture device (multiple allowed)
-vs, --video-size video capture desired height (default: internal texture height) -vs, --video-size video capture desired height (default: internal texture height)
-vr, --video-reconnect auto-reconnect video (default)
-nvr, --no-video-reconnect do not auto-reconnect video
-is, --internal-size internal texture height (default: 720) -is, --internal-size internal texture height (default: 720)
-ls, --load-state load saved state (default) -ls, --load-state load saved state (default)
-nls, --no-load-state do not load saved state -nls, --no-load-state do not load saved state
+16
View File
@@ -32,6 +32,7 @@ static void print_help(int status_code) {
#ifdef VIDEO_IN #ifdef VIDEO_IN
"[-vi=FILE] " "[-vi=FILE] "
"[-vs=SIZE] " "[-vs=SIZE] "
"[-vr / -nvr] "
#endif /* VIDEO_IN */ #endif /* VIDEO_IN */
"[-is=SIZE] " "[-is=SIZE] "
"[-ls / -nls] " "[-ls / -nls] "
@@ -63,6 +64,8 @@ static void print_help(int status_code) {
"allowed)\n" "allowed)\n"
" -vs, --video-size video capture desired height (default: " " -vs, --video-size video capture desired height (default: "
"internal texture height)\n" "internal texture height)\n"
" -vr, --video-reconnect auto-reconnect video (default)\n"
" -nvr, --no-video-reconnect do not auto-reconnect video\n"
#endif /* VIDEO_IN */ #endif /* VIDEO_IN */
" -is, --internal-size internal texture height (default: 720)\n" " -is, --internal-size internal texture height (default: 720)\n"
" -ls, --load-state load saved state (default)\n" " -ls, --load-state load saved state (default)\n"
@@ -130,6 +133,7 @@ void args_parse(Parameters *params, int argc, char **argv) {
params->auto_random_cycle = 4; params->auto_random_cycle = 4;
params->video_in.length = 0; params->video_in.length = 0;
params->video_size = 0; params->video_size = 0;
params->video_reconnect = true;
params->internal_size = 720; params->internal_size = 720;
params->load_state = true; params->load_state = true;
params->save_state = true; params->save_state = true;
@@ -195,6 +199,18 @@ void args_parse(Parameters *params, int argc, char **argv) {
} }
#else #else
invalid_arg(arg); invalid_arg(arg);
#endif /* VIDEO_IN */
} else if (is_arg(arg, "-vr") || is_arg(arg, "--video-reconnect")) {
#ifdef VIDEO_IN
params->video_reconnect = true;
#else
invalid_arg(arg);
#endif /* VIDEO_IN */
} else if (is_arg(arg, "-nvr") || is_arg(arg, "--no-video-reconnect")) {
#ifdef VIDEO_IN
params->video_reconnect = false;
#else
invalid_arg(arg);
#endif /* VIDEO_IN */ #endif /* VIDEO_IN */
} else if (is_arg(arg, "-is") || is_arg(arg, "--internal-size")) { } else if (is_arg(arg, "-is") || is_arg(arg, "--internal-size")) {
params->internal_size = parse_uint(arg, value); params->internal_size = parse_uint(arg, value);
+5
View File
@@ -121,6 +121,9 @@ static bool start_video_captures(unsigned int video_count, bool trace_fps) {
return false; return false;
} }
} }
if (!init_params.video_reconnect) {
return true;
}
pid = fork(); pid = fork();
if (pid < 0) { if (pid < 0) {
log_error("Could not create subprocess"); log_error("Could not create subprocess");
@@ -268,12 +271,14 @@ static bool loop(bool hr, bool trace_fps) {
} }
#ifdef VIDEO_IN #ifdef VIDEO_IN
if (init_params.video_reconnect) {
for (unsigned int i = 0; i < context->inputs.length; i++) { for (unsigned int i = 0; i < context->inputs.length; i++) {
if (context->inputs.values[i].needs_reload) { if (context->inputs.values[i].needs_reload) {
shaders_relink_input(&program, &project, &context->inputs, i); shaders_relink_input(&program, &project, &context->inputs, i);
context->inputs.values[i].needs_reload = false; context->inputs.values[i].needs_reload = false;
} }
} }
}
#endif /* VIDEO_IN */ #endif /* VIDEO_IN */
compute_fps(trace_fps); compute_fps(trace_fps);
+1
View File
@@ -48,6 +48,7 @@ typedef struct Parameters {
StringArray video_in; StringArray video_in;
unsigned int video_size; unsigned int video_size;
unsigned int internal_size; unsigned int internal_size;
bool video_reconnect;
bool load_state; bool load_state;
bool save_state; bool save_state;
bool trace_midi; bool trace_midi;