From f49fd005e9886ff558df5d2aaed5542e319df4ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Einar=20J=C3=B8rgen=20Haraldseid?= Date: Tue, 3 Jun 2014 09:51:34 +0200 Subject: [PATCH 1/1] Added a script for ffmpeg screen capture --- ffmpeg-grab-window-with-sound.bash | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/ffmpeg-grab-window-with-sound.bash b/ffmpeg-grab-window-with-sound.bash index 2dfa61d..37fee2f 100755 --- a/ffmpeg-grab-window-with-sound.bash +++ b/ffmpeg-grab-window-with-sound.bash @@ -1,29 +1,11 @@ #!/bin/bash -# A simple script to grab a screencast of a window using ffmpeg -# Once started, select the window you want to record, and start -# talking/using the indicated program +# Fugly script to use ffmpeg to capture a given window -# Select window to grab info from INFO=$(xwininfo -frame) -# Get the window size -WIN_SIZE=$(echo $INFO | grep -oEe 'geometry [0-9]+x[0-9]+' | grep -oEe '[0-9]+x[0-9]+') -# Get the window position +WIN_GEO=$(echo $INFO | grep -oEe 'geometry [0-9]+x[0-9]+' | grep -oEe '[0-9]+x[0-9]+') WIN_XY=$(echo $INFO | grep -oEe 'Corners: \+[0-9]+\+[0-9]+' | grep -oEe '[0-9]+\+[0-9]+' | sed -e 's/\+/,/') -# Determine window width and window height, and adjust to be divisible by two -WIN_WIDTH=$(echo $WIN_SIZE | cut -d "x" -f 1 | awk '{print $1+$1%2}') -WIN_HEIGHT=$(echo $WIN_SIZE | cut -d "x" -f 2 | awk '{print $1+$1%2}') +WIN_X=$(echo $WIN_GEO | cut -d "x" -f 1 | awk '{print $1+$1%2}') +WIN_Y=$(echo $WIN_GEO | cut -d "x" -f 2 | awk '{print $1+$1%2}') -# Run ffmpeg -# Audio from alsa, using one channel, using the default pulse input device -# Video from X11, framerate 30 -# Use the libx264 video encoder with the lossless_ultrafast preset -# Use the libmp3lame audio encoder -# Output to a file in the user's homedir, using current date and time - -ffmpeg \ --f alsa -ac 1 -i pulse \ --f x11grab -r 30 -s ${WIN_WIDTH}x${WIN_HEIGHT} -i :0.0+${WIN_XY} \ --vcodec libx264 -vpre lossless_ultrafast \ --acodec libmp3lame \ -${HOME}/screencast-$(date +%F-%H-%M-%S).mkv +ffmpeg -f alsa -ac 1 -i pulse -f x11grab -r 30 -s ${WIN_X}x${WIN_Y} -i :0.0+${WIN_XY} -vcodec libx264 -vpre lossless_ultrafast -acodec libmp3lame ${HOME}/screencast-$(date +%F-%H-%M-%S).mkv -- 2.30.2