From 0ba3acd25a360ad53c13d97db8e59412faae07ed Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 11 Mar 2024 01:09:35 +0100 Subject: Do not create output directory when live streaming --- src/main.cpp | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6d2f16d..2da5e19 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1921,28 +1921,37 @@ int main(int argc, char **argv) { usage(); } + bool is_livestream = false; const char *filename = args["-o"].value(); if(filename) { - if(replay_buffer_size_secs == -1) { - char directory_buf[PATH_MAX]; - strcpy(directory_buf, filename); - char *directory = dirname(directory_buf); - if(strcmp(directory, ".") != 0 && strcmp(directory, "/") != 0) { - if(create_directory_recursive(directory) != 0) { - fprintf(stderr, "Error: failed to create directory for output file: %s\n", filename); - _exit(1); - } + is_livestream = is_livestream_path(filename); + if(is_livestream) { + if(replay_buffer_size_secs != -1) { + fprintf(stderr, "Error: replay mode is not applicable to live streaming\n"); + _exit(1); } } else { - if(!container_format) { - fprintf(stderr, "Error: option -c is required when using option -r\n"); - usage(); - } + if(replay_buffer_size_secs == -1) { + char directory_buf[PATH_MAX]; + strcpy(directory_buf, filename); + char *directory = dirname(directory_buf); + if(strcmp(directory, ".") != 0 && strcmp(directory, "/") != 0) { + if(create_directory_recursive(directory) != 0) { + fprintf(stderr, "Error: failed to create directory for output file: %s\n", filename); + _exit(1); + } + } + } else { + if(!container_format) { + fprintf(stderr, "Error: option -c is required when using option -r\n"); + usage(); + } - struct stat buf; - if(stat(filename, &buf) != -1 && !S_ISDIR(buf.st_mode)) { - fprintf(stderr, "Error: File \"%s\" exists but it's not a directory\n", filename); - usage(); + struct stat buf; + if(stat(filename, &buf) != -1 && !S_ISDIR(buf.st_mode)) { + fprintf(stderr, "Error: File \"%s\" exists but it's not a directory\n", filename); + usage(); + } } } } else { @@ -2134,7 +2143,6 @@ int main(int argc, char **argv) { gsr_capture *capture = create_capture_impl(window_str, screen_region, wayland, egl.gpu_info, egl, fps, overclock, video_codec, color_range); - const bool is_livestream = is_livestream_path(filename); // (Some?) livestreaming services require at least one audio track to work. // If not audio is provided then create one silent audio track. if(is_livestream && requested_audio_inputs.empty()) { -- cgit v1.2.3