Skip to content

Instantly share code, notes, and snippets.



Created Sep 8, 2014
What would you like to do?
Records a window
#!/bin/bash -e
FILENAME=recording`date +%d-%m-%Y_%H.%M`.mp4
CMD=`xwininfo | awk '/Width/{printf"ffmpeg -f x11grab -s "$2"x"}/Height/{printf$2" -i '$DISPLAY'"}/Corners/{gsub(/\+/,",",$2);sub(/,/,"+",$2);print$2" -f alsa -i pulse -c:v libx264 -preset ultrafast -crf 0 -c:a copy"}'`
CMD="${CMD} -vf scale='iw+mod(iw,2):ih+mod(ih,2)' _tmp_record.nut"
# -vf scale='iw+mod(iw,2):ih+mod(ih,2)' makes sure the width and height are diviseable by 2 (needed for libx264)
echo "Press ^C to stop recording"
$CMD || true
ffmpeg -i _tmp_record.nut -c:v libx264 -pix_fmt yuv420p -crf $CRF -tune film -c:a libfdk_aac -b:a $ABITRATE -movflags +faststart "$FILENAME"
rm -f _tmp_record.nut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment