Screen Capture - command line?

Mac OS X offers the ability to capture static screenshots from the command line using a utility called unimaginatively screencapture. You can find more information by running man screencapture.

eg. screencapture ~/Desktop/picture.png


As for recording motion and computer audio you can do this via AppleScript using QuickTime Player X if you're using Mac OS X 10.6 or newer. (However it's definitely not "silent" and will only run when someone is logged in)

(Recording the screen for 5 seconds, just a possible starting point)

tell application "QuickTime Player"
    --activate
    new screen recording
    start document 1
    delay 5
    stop document 1
    save document 1 in file "/tmp/test.mov"
    quit
end tell

I'm using SOX and VLC for capture, crontab for scheduling, XLD to create m4a and MP4Box for multiplexing. It is quite flexible, but requires knowledge of Bash scripting (perhaps also Apple script) I found my inspiration in Diego Massanti's mkmp4 script.

core processes to launch:

rec -q -c $C -r 48000 -b 16 $AFILE trim 0 $HH:$MM:00 &

VLC -I dummy screen:// --screen-fps=25 --quiet --sout "#transcode{vcodec=h264,vb=3072}:standard{access=file,mux=mp4,dst=$FILE}" --run-time $TIME vlc://quit

Scheduling recording:

crontab -l
0       8       *       *       1-5     ~/capture.sh 3 0 recording-name 1

you can get an idea what the script is doing: record 3h capture, mono sound, every working day at 8AM


I did not find nor compile SOX enabled for MPEG audio streams, hence using FLAC to save some space; I'm using XLD to convert it to AAC-HE 16kbps, which is enough for voice.

Next step: multiplex audio and video to create mp4. If you don't mind to use GUI, then MPEG StreamClip (or QuickTime) serves also well.

MP4Box -add $1.m4a -sbr -add $1.m4v -fps $2.0 -inter 500 $1.mp4

I'm using this daily to create archive of GoToWebinar, but when next release of FFmpeg supports G2M4 codec, I won't bother anymore. Yes, there's also OSAscript to launch the webinar which also required getting rid of com.apple.quarantine flag to disable warning (Are you sure you want to open it?).

links:

http://blog.massanti.com/2008/09/26/mkmp4-automated-h264-aacplus-encoder-script-mac-linux/


You can use ffmpeg. To install it on a Mac, follow the instructions here. Then use the command:

ffmpeg -f alsa -ac 2 -i hw:0,0 -f x11grab -r 30 -s $(xwininfo -root | grep 'geometry' | awk '{print $2;}') -i :0.0 -acodec pcm_s16le -vcodec libx264 -vpre lossless_ultrafast -threads 0 -y output.mkv