miércoles, 20 de octubre de 2010

Grabar sesión de escritorio con gstreamer + bash

#!/bin/bash
#
# Requiere:
#
# gstreamer0.10-tools
# gstreamer0.10-plugins-base
# gstreamer0.10-plugins-good

# Tenemos que usar videobox hasta que libgstreamer0.10-plugins-good >= 0.10.4
VIDEOSRCOPTS=           # "startx=0 starty=0 endx=639 endy=479"
VIDEOOUTCONV=",width=640,height=480,framerate=5/1"
VIDEOENCOPTS="quality=36"   # quality=[0,63] Default: 16

AUDIOOUTCONV=",rate=11050,channels=1"
AUDIOENCOPTS=           # quality=[-0.1,1] Default: 0.3

SINK="filesink location=desktop.ogg"

gst-launch-0.10 oggmux name=mux ! $SINK \
  ximagesrc name=videosource $VIDEOSRCOPTS ! videorate ! ffmpegcolorspace \
    ! videobox right=384 bottom=288 ! videoscale method=1 ! video/x-raw-yuv$VIDEOOUTCONV \
    ! theoraenc $VIDEOENCOPTS ! queue ! mux. \
  alsasrc name=audiosource ! audiorate ! audioconvert ! audio/x-raw-float$AUDIOOUTCONV \
    ! vorbisenc $AUDIOENCOPTS ! queue ! mux.


En Limpio:


#!/bin/bash
# Requiere:
# gstreamer0.10-tools
# gstreamer0.10-plugins-base
# gstreamer0.10-plugins-good

VIDEOOUTCONV=",width=640,height=480,framerate=5/1"
AUDIOOUTCONV=",rate=11050,channels=1"
SINK="filesink location=desktop.ogg"

gst-launch-0.10 oggmux name=mux ! $SINK \
  ximagesrc name=videosource $VIDEOSRCOPTS ! videorate ! ffmpegcolorspace \
    ! videobox right=384 bottom=288 ! videoscale method=1 ! video/x-raw-yuv$VIDEOOUTCONV \
    ! theoraenc $VIDEOENCOPTS ! queue ! mux. \
  alsasrc name=audiosource ! audiorate ! audioconvert ! audio/x-raw-float$AUDIOOUTCONV \
    ! vorbisenc $AUDIOENCOPTS ! queue ! mux.