[Discuss] Capturing X11 video/pulse audio using avconv

David Kramer david at thekramers.net
Wed Feb 20 21:52:04 EST 2013


(Sorry I wasn't at the meeting tonight.  I really wanted to go but I
work in Marlborough and got out too late)

I'm trying to put a script together to capture the video and audio from
a window.  For instance, let's say I'm watching a Flash video on a
website and I want to capture the Firefox window.  I'm not picky about
the video or audio format.  Lossy is probably OK.  This is on Kubuntu 12.04.

I found a clever post on Youtube on how to do it with ffmpeg, which is
deprecated.  The clever part is he used xwininfo to get the geometry and
offset to capture.  Converting it to avconv and adding some of my own
touches and things I picked up from other links, I ended up with:

---------------------------------------------------------------------------------------------------
echo "*** Click on the window to be recorded ***"
INFO=$(xwininfo -frame)
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:\s+\+[0-9]+\+[0-9]+' | grep
-oEe '[0-9]+\+[0-9]+' | sed -e 's/+/,/' )
FPS="25"
VIDEO_OPTIONS="-vcodec mpeg4"
AUDIO_OPTIONS="-f alsa -i pulse"
avconv -f x11grab -s ${WIN_GEO} -r ${FPS} -i :0.0+${WIN_XY} -threads 2
-y ${VIDEO_OPTIONS} ${AUDIO_OPTIONS} $1.mpg
---------------------------------------------------------------------------------------------------

This is does a great job of capturing the video, but I just get hissing
from the audio.  I'm guessing that these audio parameters are designed
to capture from an input device, and not "the sound I hear through my
speakers".  Ideally I would be able to capture the sound coming from
that app, but that's a bit crazy, so any sound that's going to the
output would be close enough.

Any ideas?




More information about the Discuss mailing list