SF.net SVN: morphix: [2544] trunk/mmaker/utils/auto-testing/ video-qemu-booting-iso.sh

[email protected] Sat, 28 Jul 2007 17:01:14 -0700
Newsgroups gmane.linux.morphix.cvs
Message-ID <[email protected]>
Revision: 2544
          http://morphix.svn.sourceforge.net/morphix/?rev=2544&view=rev
Author:   bmsleight
Date:     2007-07-28 17:01:08 -0700 (Sat, 28 Jul 2007)

Log Message:
-----------
Working progress

Modified Paths:
--------------
    trunk/mmaker/utils/auto-testing/video-qemu-booting-iso.sh

Modified: trunk/mmaker/utils/auto-testing/video-qemu-booting-iso.sh
===================================================================
--- trunk/mmaker/utils/auto-testing/video-qemu-booting-iso.sh	2007-07-28 07:22:24 UTC (rev 2543)
+++ trunk/mmaker/utils/auto-testing/video-qemu-booting-iso.sh	2007-07-29 00:01:08 UTC (rev 2544)
@@ -6,18 +6,40 @@
 OLD_DISPLAY="$DISPLAY"
 TMP_DIR=/tmp/vqbi.$$.tmp
 IPADDRESS=$(sudo ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}')
-
-ISO="/home/morph/webconverger/debian-live-sid-i386-gnome-desktop.iso"
-SENDKEYS="spc,l,i,v,e,spc,kp_enter"
-QEMU_MONITOR_PORT=4444
-GEOMETRY="1280x960"
-CONVERT_DIM="800x600"
-MCODER_DIM="w=800:h=600"
-VIDEO="/tmp/qemu.avi"
-TIME_Q="6"
 VNCREC_MOVIE_FRAMERATE=1
 }
 
+get_options_and_defaults ()
+{
+if [ "$SENDKEYS" = "" ]; then
+ SENDKEYS="spc,l,i,v,e,spc,kp_enter"
+fi
+if [ "$QEMU_MONITOR_PORT" = "" ]; then
+ QEMU_MONITOR_PORT=4444
+fi
+if [ "$GEOMETRY" = "" ]; then
+ GEOMETRY="1280x960"
+fi
+if [ "$CONVERT_DIM" = "" ]; then
+ CONVERT_DIM="800x600"
+fi
+if [ "$MCODER_DIM" = "" ]; then
+ MCODER_DIM="w=800:h=600"
+fi
+MCODER_DIM_SCALE=$(echo "$MCODER_DIM" | sed s/x/,/g)
+if [ "$TIME_Q" = "" ]; then
+ TIME_Q="60"
+fi
+if [ "$LOGO" = "" ]; then
+ LOGO="/home/morph/webconverger/openlogo-75.png"
+fi
+if [ "$QEMU_BIN" = "" ]; then
+ QEMU_BIN="qemu"
+ #qemu_0.8.4-etch1
+fi
+}
+
+
 set_up_workspace ()
 {
 mkdir $TMP_DIR 2>/dev/null
@@ -43,11 +65,11 @@
 
 start_vnc_sessions ()
 {
-vncserver -nocursor -geometry $GEOMETRY >$TMP_DIR/vncserver.txt 2>&1
+vncserver -nocursor -geometry $GEOMETRY  >$TMP_DIR/vncserver.txt 2>&1
 VNSERVER_QEMU=$(cat $TMP_DIR/vncserver.txt | grep 'New' | awk '{ print $5}' )
 VNCSERVER_QMEU_NUMBER=$(cat $TMP_DIR/vncserver.txt | grep 'New' | cut -d: -f2)
 echo "Launched vncserver $VNSERVER_QEMU"
-vncserver -nocursor -geometry 1600x1200 >$TMP_DIR/vncserver.txt 2>&1
+vncserver -nocursor -geometry 1600x1200  >$TMP_DIR/vncserver.txt 2>&1
 VNSERVER_VNCREC=$(cat $TMP_DIR/vncserver.txt | grep 'New' | awk '{ print $5}' )
 VNCSERVER_VNCREC_NUMBER=$(cat $TMP_DIR/vncserver.txt | grep 'New' | cut -d: -f2)
 echo "Launched vncserver $VNSERVER_VNCREC"
@@ -55,7 +77,8 @@
 
 start_vnc_record ()
 {
-#export DISPLAY="$VNSERVER_VNCREC"	
+export DISPLAY="$VNSERVER_VNCREC"	
+#export DISPLAY="$OLD_DISPLAY"
 rm /tmp/qemu.1.vnc
 export VNCREC_MOVIE_FRAMERATE
 echo "Starting vncrec, recording :$VNCSERVER_QMEU_NUMBER. Local display :$VNCSERVER_VNCREC_NUMBER"
@@ -66,8 +89,8 @@
 {
 export DISPLAY=$VNSERVER_QEMU
 echo "Starting qemu, within Dispaly $VNSERVER_QEMU"
-qemu_0.8.4-etch1 -no-kqemu -full-screen  -cdrom $ISO -monitor telnet:$IPADDRESS:$QEMU_MONITOR_PORT,server,nowait &
-sleep 10
+$QEMU_BIN -no-kqemu -full-screen  -cdrom $ISO -monitor telnet:$IPADDRESS:$QEMU_MONITOR_PORT,server,nowait &
+sleep 3
 i=1
 REACHED_LAST_KB=""
 while [ -z $REACHED_LAST_KB ]
@@ -81,7 +104,7 @@
  fi
  let i=i+1
 done
-sleep 3
+sleep 1
 }
 
 let_qemu_run ()
@@ -94,7 +117,7 @@
 {
 echo "Stopping vncrec and qemu"  
 killall vncrec
-killall qemu_0.8.4-etch1
+killall $QEMU_BIN
 }
 
 stop_vncservers ()
@@ -107,14 +130,16 @@
 
 export_frames ()
 {
+convert $LOGO -resize 200x200 -negate  -gravity South -background Black -font Helvetica-Bold -fill white -splice 0x36 -pointsize 25 -draw "text 0,0 'AutoTesting'" -transparent black $TMP_DIR/minilogo.png
+convert $TMP_DIR/minilogo.png  -fill grey50 -colorize 40 $TMP_DIR/minilogo.png
 VNCREC_MOVIE_CMD='convert xpm:-  '$TMP_DIR'/image-%05d.jpg'
 export VNCREC_MOVIE_CMD
-#vncrec  -movie $TMP_DIR/qemu.1.vnc 1>/dev/null 2>&1
 vncrec  -movie $TMP_DIR/qemu.1.vnc
 for i in $TMP_DIR/image-*.jpg
 do
  convert $i -resize $CONVERT_DIM $i 
  echo "Resized $i"
+ composite -dissolve 15 -gravity northeast $TMP_DIR/minilogo.png $i $i
 done
 echo "Finished making Frames"
 }
@@ -122,7 +147,14 @@
 
 make_video ()
 {
-mencoder mf://$TMP_DIR/*.jpg -mf $MCODER_DIM:fps=4:type=jpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o $VIDEO
+##Following is ideal - does not work
+#mkfifo -m 660 $TMP_DIR/stream.yuv
+#mplayer -vo yuv4mpeg:file=$TMP_DIR/stream.yuv -ao null -nosound -quiet "mf://$TMP_DIR/*.jpg"  -mf fps=4:type=jpg &
+#ffmpeg2theora -v 8 $TMP_DIR/stream.yuv -o $VIDEO 
+#sleep 5
+
+mencoder mf://"$TMP_DIR/*.jpg" -mf w=800:h=600:fps=4:type=jpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o $TMP_DIR/tmp.avi
+ffmpeg2theora -o $VIDEO $TMP_DIR/tmp.avi
 }
 
 clean_up ()
@@ -132,6 +164,46 @@
 #rm $TMP_DIR -r
 }
 
+
+while getopts s:p:g:d:t:l:q: opt
+do
+    case "$opt" in
+      s)  SENDKEYS="$OPTARG";;
+      p)  QEMU_MONITOR_PORT="$OPTARG";;
+      g)  GEOMETRY="$OPTARG";;
+      d)  CONVERT_DIM="$OPTARG";;
+      t)  TIME_Q="$OPTARG";;
+      l)  LOGO="$OPTARG";;
+      q)  QEMU_BIN="$OPTARG";;
+
+      
+      \?)		# unknown flag
+      	  echo >&2 \
+		"usage: $0 [-s \"keys,to,send,to,qemu\"] [-p port_number for qemu-monitor] [-g geometry of vncsession] [-d dimensions of video] [-t time to run qemu] [-l logo] [-q alternative qemu binary name] IsoToTest.iso Video.ogg " 
+	  exit 1;;
+    esac
+done
+shift `expr $OPTIND - 1`
+
+if [ -z "$1" -a -z "$2" ]; then
+    echo "usage: $0 [-s \"keys,to,send,to,qemu\"] [-p port_number for qemu-monitor] [-g geometry of vncsession] [-d dimensions of video] [-t time to run qemu] [-l logo] IsoToTest.iso Video.ogg " 
+    echo
+    echo " This script boots a livecd using qemu and records a video of the process. "
+    echo 
+    echo " It is worth noting that this script takes a long time to run and heavy usage of CPU."
+    echo " There is heavy usage of the qemu, imagemagik tools. "
+    echo " For every second of running qemu the script it can take up to 12s to compile the video."
+    echo " For example using -t 300 will about one hour."
+    echo
+    echo " Launches a couple of vncserver session, kills other vncrec and qemu session running."
+    echo " Requires sudo ifconfig"
+    exit
+fi
+
+ISO=$1
+VIDEO=$2
+
+get_options_and_defaults
 get_global_variables
 set_up_workspace
 start_vnc_sessions


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/