Skip to content

Commit 72ffdb9

Browse files
committed
[rust] Set default video device for avfoundation
1 parent a51d412 commit 72ffdb9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

rust/src/ffmpeg.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use crate::config::OS::{MACOS, WINDOWS};
18+
use crate::config::OS::{LINUX, MACOS, WINDOWS};
1919
use crate::downloads::download_to_tmp_folder;
2020
use crate::files::{
2121
compose_driver_path_in_cache, create_parent_path_if_not_exists, get_filename_with_extension,
@@ -44,7 +44,7 @@ const FFMPEG_MACOS_RELEASE_URL: &str = "https://evermeet.cx/ffmpeg/ffmpeg-{}.zip
4444
const FFMPEG_RECORD_FRAME_RATE: &str = "30";
4545
const FFMPEG_RECORD_DESKTOP_WINDOWS_COMMAND: &str = "{} -f gdigrab -i desktop -r {} -q:v 1 -y {}";
4646
const FFMPEG_RECORD_DESKTOP_LINUX_COMMAND: &str = "{} -f x11grab -i {} -r {} -vcodec huffyuv -y {}";
47-
const FFMPEG_RECORD_DESKTOP_MACOS_COMMAND: &str = r#"{} -f avfoundation -i "{}:0" -r {} -y {}"#;
47+
const FFMPEG_RECORD_DESKTOP_MACOS_COMMAND: &str = r#"{} -f avfoundation -i "1:0" -r {} -y {}"#;
4848
const FFMPEG_RECORDING_EXTENSION: &str = "avi";
4949
const FFMPEG_RECORDING_FOLDER: &str = "recordings";
5050
const FFMPEG_DEFAULT_DISPLAY: &str = ":0";
@@ -210,19 +210,19 @@ pub fn record_desktop_with_ffmpeg(
210210
"Recording desktop with {} to {}",
211211
FFMPEG_NAME, &recording_name
212212
));
213-
let command = if WINDOWS.is(os) {
214-
Command::new_single(format_three_args(
213+
let command = if LINUX.is(os) {
214+
let env_display = env::var(ENV_DISPLAY).unwrap_or(FFMPEG_DEFAULT_DISPLAY.to_string());
215+
Command::new_single(format_four_args(
215216
get_recording_command(os),
216217
&path_to_string(&ffmpeg_path),
218+
&env_display,
217219
FFMPEG_RECORD_FRAME_RATE,
218220
&recording_name,
219221
))
220222
} else {
221-
let env_display = env::var(ENV_DISPLAY).unwrap_or(FFMPEG_DEFAULT_DISPLAY.to_string());
222-
Command::new_single(format_four_args(
223+
Command::new_single(format_three_args(
223224
get_recording_command(os),
224225
&path_to_string(&ffmpeg_path),
225-
&env_display,
226226
FFMPEG_RECORD_FRAME_RATE,
227227
&recording_name,
228228
))

0 commit comments

Comments
 (0)