Menu

31 March 2010

Capture screen and mic input using FFmpeg and ALSA

---------- Forwarded message ----------
From: Mohan R <mohan43u@gmail.com>
Date: Wed, Mar 31, 2010 at 4:28 PM
Subject: [Ilugc] Capture screen and mic input using FFmpeg and ALSA
To: ilugc@ae.iitm.ac.in


Hi,

Recently, lot of traffic about x11grab appeared in commandlinefu(http://www.commandlinefu.com). People posted their commandline variants to create screencast video.

For my purpose, I also created my own variant of x11grab, here is the commandline.

-----
ffmpeg -f alsa -itsoffset 00:00:02.000 -ac 2 -i hw:0,0 -f x11grab -s $(xwininfo -root | grep 'geometry' | awk '{print $2;}') -r 10 -i :0.0 -sameq -f mp4 -s wvga -y outputfile.mp4
-----

And to make it simple, I also wrote a small script

-----
#!/bin/sh
# simple command to capture your screen and mic input

OUTPUT="${1:?[usage] screencast.sh OUTPUTFILE}"

getgeometry()
{
       xwininfo -root |
       grep 'geometry' |
       awk '{print $2;}'
}

captureX11()
{
       ffmpeg -f alsa -itsoffset 00:00:02.000 -ac 2 -i hw:0,0 \
               -f x11grab -s $(getgeometry) -r 10 -i :0.0 \
               -sameq -f mp4 \
               -s wvga \
               -y "${OUTPUT}"
}

captureX11
-----

This script captured my desktop as well as voice from my laptop's in-built front mic. I'm using Debian(Testing). I'm posting this script to see how it works in other distros. If you understand and know how to tweek this commandline, please post your modifications.

For newcomers, to run this script, you need to install ffmpeg and ALSA. Ubuntu/Fedora are using pulse as their audio subsystem. I don't know how to use pulse to capture mic input. Don't try if you don't know what you are doing. You will endup breaking your sound.

This is the first screencast I created using this script,

Lets play with ffmpeg :)

Cheers,
Mohan R.

Posted via email from LUG@IITD Community Blog

No comments: