#! /bin/bash # Licensed under GPLv2.0 # BVidCap (Bash Video Capture) v0.3 # June 2006 # # Tested : Ubuntu 6.06 (Dapper) # # Depends: zenity package (comes as default) # patched ffmpeg for screencasting # http://ubuntu.wordpress.com/2006/06/08/how-to-create-a-screencast-in-ubuntu/ # http://erunar.co.uk/debs/ubuntu_dapper/ffmpeg-0.4.9-p20051216_i386.deb # ffmpeg2theora package (enable universe) # # Changes # # - Adjust framesize to be divisible by 2 # - Places the default avi format to the Desktop # - Prompts for Ogg/Ogm conversion # - Calls another xterm session to track progress of Ogg/Ogm conversion # # Todos: # # - Linux utility to select region in desktop that returns compatible xwininfo message # - Check if ffmpeg with capture.avi is really running on process id # - allow user to specify Ogg filename # - provide GUI to make it work with Desktop # (Create a shortcut keys on the desktop instead: # Ctrl+Alt+Prn for starting the capture # Ctrl+Alt+Break for stoping the capture # Works greak on Xubuntu Desktop.) # - avi to swf # # Author: # # nbjayme # function stopCapture(){ if [ -e "/tmp/capture.pid" ]; then # be sure we capture everything using sleep (for 10 seconds) sleep 10 kill `cat /tmp/capture.pid` rm /tmp/capture.pid -f fi if [ -e "/tmp/capture.avi" ]; then saveCapture fi if [ -e "/tmp/capture.win" ]; then rm /tmp/capture.win -f fi return 0 } function saveCapture(){ #$cOggFile=`zenity --file-selection --save --filename 'OggCapture' --title "Save capture to.."` #if [ "$?" == "1" ]; then # return 1 #fi # i want open format no avi please # mv /tmp/capture.avi "$cOggFile" # ffmpeg2theora "$cOggFile" /tmp/capture.avi > /dev/null 2>&1 #ffmpeg2theora "$cOggFile" /tmp/capture.avi mv /tmp/capture.avi ~/Desktop/capture.avi zenity --question --text "Export to the non-proprietary format Ogg/Ogm?" if [ "$?" == "0" ]; then xterm -T "Exporting to Ogg/Ogm..." -e ffmpeg2theora ~/Desktop/capture.avi fi } function modeCapture(){ cMode=`zenity --list --radiolist --column "" --column "Select capture mode" TRUE "Whole screen" FALSE "Select a window"` if [ "$?" == "1" ]; then return 1 fi if [ "$cMode" == "Whole screen" ]; then xwininfo -root > /tmp/capture.win else xwininfo -frame > /tmp/capture.win fi cMessage=`cat /tmp/capture.win` zenity --question --text="$cMessage" --title="Begin capture?" return "$?" } function startCapture(){ modeCapture if [ "$?" == "1" ]; then return 1 fi # parse /tmp/capture.win nLeft=`cat /tmp/capture.win | grep 'Absolute upper-left X:' | awk '{print $NF}'` nTop=`cat /tmp/capture.win | grep 'Absolute upper-left Y:' | awk '{print $NF}'` nWidth=`cat /tmp/capture.win | grep Width: | awk '{print $NF}'` nHeight=`cat /tmp/capture.win | grep Height: | awk '{print $NF}'` if [ $((nWidth%2)) -gt 0 ]; then nWidth=$((nWidth+1)) fi if [ $((nHeight%2)) -gt 0 ]; then nHeight=$((nHeight+1)) fi cFileAvi=/tmp/capture.avi # ffmpeg -vcodec mpeg4 -b 1000 -r 10 -g 300 -vd x11:0,0 -s 1024x768 ./test.avi ffmpeg -vcodec mpeg4 -b 1000 -r 10 -g 300 -vd x11:"$nLeft","$nTop" -s "$nWidth"x"$nHeight" "$cFileAvi" & echo "$!" > /tmp/capture.pid return 0 } function checkIfRunning(){ if [ ! -e "/tmp/capture.pid" ]; then return 0 fi zenity --question --text="Detected active capture process. Stop previous capture?" if [ "$?" == "1" ]; then return 1 fi stopCapture return 0 } # main routine if [ "$1" == "-stop" ]; then stopCapture exit 0 fi if [ "$1" == "-start" ]; then checkIfRunning if [ "$?" == "0" ]; then startCapture fi exit "$?" fi echo "This is a Free Software" echo "Licensed under GPLv2.0" echo "BVidCap (Bash Video Capture) v0.3" echo "June 2006" echo "" echo "----Help Information----" echo " -start = start capturing " echo " -stop = stop capturing"