Advertisement
mfillpot

screencast

Jul 8th, 2012
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.23 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # VidREs
  4. #sqcif=128x96, qcif=176x144, cif=352x288, 4cif=704x576, 16cif=1408x1152, qqvga=160x120, qvga=320x240, vga=640x480, svga=800x600, xga=1024x768, uxga=1600x1200, qxga=2048x1536, sxga=1280x1024, qsxga=2560x2048, hsxga=5120x4096, wvga=852x480, wxga=1366x768, wsxga=1600x1024, wuxga=1920x1200, oxga=2560x1600, wqsxga=3200x2048, wquxga=3840x2400, whsxga=6400x4096, whuxga=7680x4800, cga=320x200, ega=640x350, hd480=852x480, hd720=1280x720, hd1080=1920x1080
  5. # or custom resolution
  6.  
  7. #Input Device
  8. # alsa, bktr, dv1394, fbdev, jack, libdc1394, oss, sndio, video4linux, vfwcap, x11grab
  9.  
  10. DESKFILE=":0.0"
  11. CAMFILE=/dev/video0
  12.  
  13. #AUDFILE="hw:0"
  14. AUDFILE="/dev/audio"
  15. #MICFILE=/dev/dsp
  16. MICFILE="hw:0"
  17.  
  18. SNDINPUTDEV=alsa
  19. #SNDINPUTDEV=pulse
  20. #SNDINPUTDEV=oss
  21.  
  22. AUDTYPE=ogg
  23. VIDTYPE=webm
  24.  
  25. FRAMERATE=24
  26.  
  27. STARTRECORD() {
  28.  
  29.   # Build the video options
  30.   case "$VIDSRC" in
  31.   "desktop" )
  32.     VIDINPUTDEV=x11grab
  33.     #VIDRES=$(xrandr|grep "*"|tr -s " "|cut -d " " -f 2)
  34.     VIDRES=$(xwininfo -root | grep 'geometry' | awk '{print $2;}'|cut -d "+" -f 1)
  35.     VIDINPUTFILE=$DESKFILE
  36.  
  37.     VIDOPTS="-f $VIDINPUTDEV -s $VIDRES -r $FRAMERATE -i $VIDINPUTFILE"
  38.     ;;
  39.   "webcam" )
  40.     VIDINPUTDEV=video4linux2
  41.     #VIDINPUTDEV=v4l2-ctl
  42.     VIDRES=$(for i in `lsusb -v|grep wWidth|tr -s " "|cut -d " " -f 3`; do b=$(printf %04d ${i%});echo $b;done|sort|tail -n 1)x$(for i in `lsusb -v|grep wHeight|tr -s " "|cut -d " " -f 3`; do b=$(printf %04d ${i%});echo $b;done|sort|tail -n 1)
  43.     VIDINPUTFILE=$CAMFILE
  44.  
  45.     VIDOPTS="-f $VIDINPUTDEV -s $VIDRES -r $FRAMERATE -i $VIDINPUTFILE"
  46.     ;;
  47.   "none" )
  48.     VIDOPTS=""
  49.     ;;
  50.   * )
  51.     printf "\n invalid video input"
  52.     HELPOUTPUT
  53.     exit 1
  54.     ;;
  55.   esac
  56.  
  57.   if [ ! "$VIDOPTS" = "" ];then
  58.     VIDOPTS="$VIDOPTS -b 2M -bt 4M"
  59.     VIDCOD="-vcodec libvpx"
  60.   fi
  61.  
  62. #-threads 0
  63. #-vpre lossless_ultrafast
  64.  
  65.   # Build the audio options
  66.   case "$AUDSRC" in
  67.   "speaker" )
  68.     AUDOPTS="-f $SNDINPUTDEV -i $AUDFILE"
  69.     ;;
  70.   "mic" )
  71.     AUDOPTS="-f $SNDINPUTDEV -i $MICFILE"
  72.     ;;
  73.   "none" )
  74.     AUDOPTS=""
  75.     ;;
  76.   * )
  77.     printf "\n invalid audio input"
  78.     HELPOUTPUT
  79.     ;;
  80.   esac
  81.  
  82.   if [ ! "$AUDOPTS" = "" ]; then
  83.     AUDOPTS="$AUDOPTS -acodec pcm_s16le"
  84.     AUDCOD="-acodec libvorbis -ac 2 -ar 48000 -ab 128k"
  85.   fi
  86.  
  87.   if [ "$VIDSRC" = "none" -a "$AUDSRC" = "none" ]; then
  88.     printf "\n no audio or video input was selected"
  89.     HELPOUTPUT
  90.   elif  [ ! "$VIDSRC" = "none" ]; then
  91.     OUTFORMAT=$VIDTYPE
  92.   elif  [ ! "$AUDSRC" = "none" ]; then
  93.     OUTFORMAT=$AUDTYPE
  94.   fi
  95.  
  96. COMD="ffmpeg $VIDOPTS $AUDOPTS $VIDCOD $AUDCOD -y $OUTFILE.$OUTFORMAT"
  97. #COMD="ffmpeg $VIDOPTS $AUDOPTS -vcodec libx264 -pass 2 -vpre hq -acodec libfaac -ac 2 -ar 48000 -ab 192k -y $OUTFILE.$OUTFORMAT"
  98. $COMD
  99. echo "$COMD"
  100. exit 0
  101. #-vcodec libx264
  102. }
  103.  
  104. HELPOUTPUT() {
  105.   printf "\nInvalid arguments, the proper syntax is recordvideo {video source} {audiosource} {outputfile}"
  106.   printf "\n\t Valid video sources are desktop, webcam and none"
  107.   printf "\n\t Valid audio sources are speaker, mic and none"
  108.   printf "\n\t The output file should be entered without an extension\n\n"
  109.   exit 1
  110. }
  111.  
  112. if [ $# -eq 3 ]; then
  113.  
  114.   VIDSRC=$1
  115.   AUDSRC=$2
  116.   OUTFILE=$3
  117.  
  118.   STARTRECORD
  119.  
  120. else
  121.  
  122.   HELPOUTPUT
  123.  
  124. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement