aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-24 04:04:59 -0500
committerCraig Jennings <c@cjennings.net>2026-05-24 04:04:59 -0500
commit39795e850f2027a88021307a37de0381996df8a5 (patch)
tree7b0c6a011ca25de0e0a42303008db3c41aa8bb85 /modules
parent746e770ade412c8e7992b2a98441aebde000db3c (diff)
downloaddotemacs-39795e850f2027a88021307a37de0381996df8a5.tar.gz
dotemacs-39795e850f2027a88021307a37de0381996df8a5.zip
fix(recording): shell-quote device names and output paths in ffmpeg commands
The X11 video path and the audio path interpolated the mic device, system device, and output filename straight into the shell command, so a device name or recording directory with a space (or other shell metacharacter) would break the command or mishandle the path. The Wayland video branch already quoted these; the other two did not. I wrapped all three in shell-quote-argument on both paths. To make the audio command testable, I extracted it into cj/recording--build-audio-command mirroring the existing cj/recording--build-video-command, then quoted there. Tests cover device names and filenames with spaces on both the X11 and audio builders.
Diffstat (limited to 'modules')
-rw-r--r--modules/video-audio-recording.el44
1 files changed, 25 insertions, 19 deletions
diff --git a/modules/video-audio-recording.el b/modules/video-audio-recording.el
index 94f90099..6c00a2df 100644
--- a/modules/video-audio-recording.el
+++ b/modules/video-audio-recording.el
@@ -843,11 +843,32 @@ On X11: ffmpeg captures screen directly via x11grab with PulseAudio audio."
"-filter_complex \"[1:a]volume=%.1f[mic];[2:a]volume=%.1f[sys];[mic][sys]amerge=inputs=2[out]\" "
"-map 0:v -map \"[out]\" "
"%s")
- mic-device
- system-device
+ (shell-quote-argument mic-device)
+ (shell-quote-argument system-device)
cj/recording-mic-boost
cj/recording-system-volume
- filename)))
+ (shell-quote-argument filename))))
+
+(defun cj/recording--build-audio-command (mic-device system-device filename)
+ "Build the ffmpeg shell command string for audio-only recording.
+MIC-DEVICE and SYSTEM-DEVICE are PulseAudio device names. FILENAME is
+the output .m4a path. Mixes mic + system monitor into a single AAC file."
+ (format (concat "ffmpeg "
+ "-f pulse -i %s " ; Input 0: microphone
+ "-f pulse -i %s " ; Input 1: system audio monitor
+ "-filter_complex \""
+ "[0:a]volume=%.1f[mic];"
+ "[1:a]volume=%.1f[sys];"
+ "[mic][sys]amix=inputs=2:duration=longest[out]\" "
+ "-map \"[out]\" "
+ "-c:a aac "
+ "-b:a 64k "
+ "%s")
+ (shell-quote-argument mic-device)
+ (shell-quote-argument system-device)
+ cj/recording-mic-boost
+ cj/recording-system-volume
+ (shell-quote-argument filename)))
(defun cj/ffmpeg-record-video (directory)
"Start a video recording, saving output to DIRECTORY.
@@ -898,22 +919,7 @@ The filter graph mixes two PulseAudio inputs:
(name (format-time-string "%Y-%m-%d-%H-%M-%S"))
(filename (expand-file-name (concat name ".m4a") location))
(ffmpeg-command
- (format (concat "ffmpeg "
- "-f pulse -i %s " ; Input 0: microphone
- "-f pulse -i %s " ; Input 1: system audio monitor
- "-filter_complex \""
- "[0:a]volume=%.1f[mic];"
- "[1:a]volume=%.1f[sys];"
- "[mic][sys]amix=inputs=2:duration=longest[out]\" "
- "-map \"[out]\" "
- "-c:a aac "
- "-b:a 64k "
- "%s")
- mic-device
- system-device
- cj/recording-mic-boost
- cj/recording-system-volume
- filename)))
+ (cj/recording--build-audio-command mic-device system-device filename)))
(message "Recording from mic: %s + ALL system outputs" mic-device)
(cj/log-silently "Audio recording ffmpeg command: %s" ffmpeg-command)
(setq cj/audio-recording-ffmpeg-process