Merge pull request #1241 from Blajda/ffmpeg-opts

FFmpeg options for swaygrab
This commit is contained in:
Drew DeVault 2017-06-17 23:56:59 -04:00 committed by GitHub
commit 25b6adb7ac
2 changed files with 20 additions and 4 deletions

View file

@ -84,13 +84,18 @@ void grab_and_apply_movie_magic(const char *file, const char *payload,
sway_abort("Unknown output %s.", name); sway_abort("Unknown output %s.", name);
} }
const char *fmt = "ffmpeg -f rawvideo -framerate %d " char *ffmpeg_opts = getenv("SWAYGRAB_FFMPEG_OPTS");
if(!ffmpeg_opts) {
ffmpeg_opts = "";
}
const char *fmt = "ffmpeg %s -f rawvideo -framerate %d "
"-video_size %dx%d -pixel_format argb " "-video_size %dx%d -pixel_format argb "
"-i pipe:0 -r %d -vf vflip %s"; "-i pipe:0 -r %d -vf vflip %s";
char *cmd = malloc(strlen(fmt) - 8 /*args*/ char *cmd = malloc(strlen(fmt) - 8 /*args*/
+ numlen(width) + numlen(height) + numlen(framerate) * 2 + strlen(ffmpeg_opts) + numlen(width) + numlen(height)
+ strlen(file) + 1); + numlen(framerate) * 2 + strlen(file) + 1);
sprintf(cmd, fmt, framerate, width, height, framerate, file); sprintf(cmd, fmt, ffmpeg_opts, framerate, width, height, framerate, file);
long ns = (long)(1000000000 * (1.0 / framerate)); long ns = (long)(1000000000 * (1.0 / framerate));
struct timespec start, finish, ts; struct timespec start, finish, ts;

View file

@ -48,6 +48,13 @@ Options
*-f, --focused*:: *-f, --focused*::
Capture only the currently focused container. Capture only the currently focused container.
Environment Variables
---------------------
swaygrab reads the following environment variables.
*SWAYGRAB_FFMPEG_OPTS*::
Pass additional arguments to FFmpeg when starting a capture.
Examples Examples
-------- --------
@ -57,6 +64,10 @@ swaygrab output.png::
swaygrab -c -o HDMI-A-1 output.webm:: swaygrab -c -o HDMI-A-1 output.webm::
Capture a webm of HDMI-A-1. Capture a webm of HDMI-A-1.
SWAYGRAB_FFMPEG_OPTS="-f alsa -i pulse" swaygrab -c::
Capture the focused output and encode audio from the default recording
device.
Authors Authors
------- -------