Just messing around with ffmpeg today. :-)


 — Get it here.

↑ Sometimes, all you need is … : A few examples, and a bit of ffmpeg. 😉

Example script to “ snap ” one’s desktop — without the top, and bottom panel in my case.

#!/bin/bash -
# Modified: Today by E.L.F.
#
## Licensed as:
## http://www.opensource.org/licenses/mit-license.php
#
## Script-name - snap
#
if
  [[ "$UID" = "0" ]]
then
  ##  \u21 prints out an EXCLAMATION mark. ; )
  printf '%b\n' "\tError: There is no need to run this script as: \u201c "${USER^}"\u21 \u201d"
  exit 1
else
##  Use ffmpeg to snap your desktop.
##  'tardate' is an exported variable, on my box.
##  It will yield: year-mm-dd
#   tardate="$(date +"%F")"
rndm="$(head -c 6 /dev/urandom |base64)"
#   ${rndm//\//fs} = replace any occuring '/', in its output, with 'fs'
ffmpeg -f x11grab -s 1280x720 \
-i :0.0 -vf "crop=1280:668:0:26" \
-r 1 -t 1 -c:v png -b:v 3000k \
-f mjpeg -s hd720 \
Snap."$tardate"."${rndm//\//fs}".png
fi
exit 0
## http://ubuntuforums.org/tags.php?tag=recordmydesktop
## http://ubuntuforums.org/showthread.php?t=1392026 - How to screencast properly.
##  Totem, with hidden controls (ctrl+h) aligned to top-left of screen.
#   -vf "crop=752:483:1:56" ← Give or take a few pixels. lol
##  Electricsheep (mplayer).
#   -vf "crop=800:592:1:56" \
##  ‘ Full-screen ’ (1366x768=full)
#   -vf "crop=1366:741:0:27"

Example script to record one’s desktop — without the top, and bottom panel in my case.

#!/bin/bash -
# Modified: Today by E.L.F.
#
## Licensed as:
## http://www.opensource.org/licenses/mit-license.php
#
## Script-name - xgrabber.sh
#
## http://ubuntuforums.org/tags.php?tag=recordmydesktop
## http://ubuntuforums.org/showthread.php?t=1392026 - How to screencast properly.
## https://wiki.ubuntu.com/PulseAudio
if
  [[ "$UID" = "0" ]]
then
  ##  \u21 prints out an EXCLAMATION mark. ; )
  printf '%b\n' "\tError: There is no need to run this script as: \u201c "${USER^}"\u21 \u201d"
  exit 1
else
  Usage(){
  ##  Use "${FUNCNAME[N]}", for function-names.
  ##  The "${0##*/}" construct is the same,
  ##  as its "$(basename "$0")" construct. ; )
  printf '%b\n' "\tUsage: "${0##*/}" \u22Your title with or without spaces in between \u201cquotes\u201d\u22"
  exit 1
  }
  clear
  if [[ -z "$1" ]]
  then
    printf '%b' "\tEnter name for output file: "
    read Arg
    if
      [[ -z "$Arg" ]]
    then
      Usage;exit 1
    else
      Out="$Arg"
    fi
  else
    Out="$1"
  fi
  ##  This will capitalize your title and put a dot at the end of it.
  ##    E.g. 'this is my recording' becomes 'This is my recording.'
  Title="${Out^}."
  ##    The following line makes certain you can type a 'normal' sentence as filename.
  ##    All this without 'violating' UNIX' restriction on spaces.
  ##    E.g. 'This is my recording' becomes 'This.is.my.recording'
  Out="${Out//\ /.}.mkv"
  ##  Let's capitalize the outgoing filename, just in case you forgot. : )
  ##    E.g. 'this.is.my.recording' becomes 'This.is.my.recording'
  Out="${Out^}"
  ##  No need for sleep, as I run this script from another monitor. ; )
  #   sleep 2
  ##  mplayer -geometry 800x592+1+56 > -s pal
  ffmpeg -y -f x11grab -s 1280x720 -i :0.0 -r 30 \
  -t 00:30:00 \
  -c:v mpeg4 -vtag xvid -qscale:v 2 \
  -vf "crop=1280:668:0:26" \
  -an \
  -s hd720 \
  "${Out}"
  unset Arg Title Out
fi
exit 0
##  For scaling purposes:
##  http://www.renevolution.com/understanding-ffmpeg-part-ii-scaling-video/
#  http://wp.me/pNJrg-8O - Grab that screen!
#  http://wp.me/pNJrg-4J - How to quote from your media.
q  ##  In terminal do:
  #   xwininfo -root -int
  ##  My total screen-real-estate consists out of a resolution of:
  #
  #   xwininfo: Window id: 335 (the root window) (has no name)
  #
  ##  Absolute upper-left X:  0
  ##  Absolute upper-left Y:  0
  ##  Relative upper-left X:  0
  ##  Relative upper-left Y:  0
  ##  Width: 2720
  ##  Height: 900
  ##  Depth: 24
  ##  Visual: 0x21
  ##  Visual Class: TrueColor
  ##  Border width: 0
  ##  Class: InputOutput
  ##  Colormap: 0x20 (installed)
  ##  Bit Gravity State: NorthWestGravity
  ##  Window Gravity State: NorthWestGravity
  ##  Backing Store State: NotUseful
  ##  Save Under State: no
  ##  Map State: IsViewable
  ##  Override Redirect State: no
  ##  Corners:  +0+0  -0+0  -0-0  +0-0
  ##  -geometry 2720x900+0+0