131 lines
3.9 KiB
Plaintext
131 lines
3.9 KiB
Plaintext
|
#!/bin/bash
|
||
|
RECORDVM_DATA=/var/makedist/recordvm
|
||
|
#VBOX=1
|
||
|
VBOX_VMNAME="openmamba-recordvm"
|
||
|
VBOX_DISPLAY=:1
|
||
|
EXECUTION_TIME=200
|
||
|
VIDEO_EXT=.flv
|
||
|
VIDEO_EXT2=.ogv
|
||
|
|
||
|
[ $1 ] || {
|
||
|
echo "Usage:"
|
||
|
echo "recordvm.sh iso_path"
|
||
|
echo
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
|
ISO_PATH=$1
|
||
|
ISO_DIR=`dirname $ISO_PATH`
|
||
|
ISO_NAME=`basename $ISO_PATH`
|
||
|
|
||
|
[ -e $ISO_PATH ] || {
|
||
|
echo "Error: file $ISO_PATH does not exist; aborting."
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
|
echo "Preparing ISO image $ISO_PATH"
|
||
|
ln -sf $ISO_PATH $RECORDVM_DATA/recordvm.iso
|
||
|
echo "Starting virtual machine for $ISO_PATH"
|
||
|
export HOME=$RECORDVM_DATA
|
||
|
xinit -- $VBOX_DISPLAY &
|
||
|
|
||
|
if [ "$VBOX" ]; then
|
||
|
# -nocursor &
|
||
|
# &>$RECORDVM_DATA/recordvm.log &
|
||
|
#VBOX_USER_HOME=$RECORDVM_DATA/VirtualBox DISPLAY=:0 /opt/VirtualBox/VBoxSDL --startvm $VBOX_VMNAME --fixedmode 1024 768 32 >/dev/null &
|
||
|
trap "VBoxManage controlvm $VBOX_VMNAME poweroff" INT QUIT TSTP
|
||
|
|
||
|
sleepcnt=0
|
||
|
while true; do
|
||
|
if [ "`VBoxManage list runningvms | grep $VBOX_VMNAME`" ]; then
|
||
|
break
|
||
|
fi
|
||
|
# xwininfo -display $VBOX_DISPLAY -name "$VBOX_VMNAME - Oracle VM VirtualBox" 2>/dev/null |grep "Window id:"| sed "s|.*Window id: \([0-9a-fx]*\).*|\1|"
|
||
|
# [ "$WINID" ] && break
|
||
|
sleep 1
|
||
|
if [ $sleepcnt -gt 20 ]; then
|
||
|
echo "VirtualBox did not start; aborting."
|
||
|
exit 1
|
||
|
fi
|
||
|
let sleepcnt=sleepcnt+1
|
||
|
done
|
||
|
WINID=`xwininfo -display $VBOX_DISPLAY -name "$VBOX_VMNAME - Oracle VM VirtualBox" 2>/dev/null |grep "Window id:"| sed "s|.*Window id: \([0-9a-fx]*\).*|\1|"`
|
||
|
VBoxManage controlvm $VBOX_VMNAME reset
|
||
|
else
|
||
|
sleepcnt=0
|
||
|
while true; do
|
||
|
WINID=`xwininfo -display $VBOX_DISPLAY -name "QEMU (qemu-recordvm)" 2>/dev/null |grep "Window id:"| sed "s|.*Window id: \([0-9a-fx]*\).*|\1|"`
|
||
|
[ "$WINID" ] && break
|
||
|
if [ $sleepcnt -gt 20 ]; then
|
||
|
echo "qemu did not start; aborting."
|
||
|
exit 1
|
||
|
fi
|
||
|
let sleepcnt=sleepcnt+1
|
||
|
sleep 1
|
||
|
done
|
||
|
fi
|
||
|
|
||
|
echo "Windowid is: $WINID"
|
||
|
|
||
|
echo "Capturing window output"
|
||
|
mkdir -p $ISO_DIR/preview/
|
||
|
DBUS_SESSION_BUS_ADDRESS= HOME=$RECORDVM_DATA DISPLAY=$VBOX_DISPLAY xvidcap \
|
||
|
--cap_geometry 1024x768+0+0 \
|
||
|
--verbose 2 --gui no --audio no \
|
||
|
--time $EXECUTION_TIME --file $ISO_DIR/preview/${ISO_NAME}${VIDEO_EXT} \
|
||
|
--quality 100 >>$RECORDVM_DATA/recordvm.log
|
||
|
#recordmydesktop --no-frame --display $VBOX_DISPLAY --windowid $WINID -o $ISO_DIR/preview/$ISO_NAME.ogv --overwrite --no-sound --no-wm-check --fps 10 --no-cursor &
|
||
|
#echo "Sleeping $EXECUTION_TIME seconds..."
|
||
|
#sleep $EXECUTION_TIME
|
||
|
|
||
|
#killall -TERM recordmydesktop
|
||
|
|
||
|
#echo "Waiting for recordmydesktop to exit"
|
||
|
#while [ "`pidof recordmydesktop`" ]; do
|
||
|
# sleep 1
|
||
|
#done
|
||
|
|
||
|
echo "Powering off VM"
|
||
|
if [ "$VBOX" ]; then
|
||
|
VBoxManage controlvm $VBOX_VMNAME poweroff &
|
||
|
|
||
|
count=0
|
||
|
while [ "`pidof VBoxManage`" ]; do
|
||
|
let count=count+1
|
||
|
sleep 1
|
||
|
if [ $count -gt 60 ]; then
|
||
|
killall -9 VBoxManage
|
||
|
break
|
||
|
fi
|
||
|
done
|
||
|
else
|
||
|
xkill -id $WINID -display $VBOX_DISPLAY
|
||
|
fi
|
||
|
|
||
|
echo "Creating preview images"
|
||
|
rm -f $ISO_DIR/preview/*.jpg
|
||
|
ffmpeg -y -i $ISO_DIR/preview/$ISO_NAME${VIDEO_EXT} -r 1 -f image2 $ISO_DIR/preview/image-%03d.jpg >/dev/null
|
||
|
for i in `seq 200 -1 1`; do
|
||
|
f=`printf %03d $i`
|
||
|
[ -e $ISO_DIR/preview/image-$f.jpg ] && {
|
||
|
convert -size 320x200 $ISO_DIR/preview/image-$f.jpg $ISO_DIR/preview/preview.jpg
|
||
|
convert -size 400x300 $ISO_DIR/preview/image-$f.jpg $ISO_DIR/preview/preview-400x300.jpg
|
||
|
break
|
||
|
}
|
||
|
done
|
||
|
|
||
|
echo "Creating ${VIDEO_EXT2} video from ${VIDEO_EXT}"
|
||
|
#ffmpeg -y -i $ISO_DIR/preview/$ISO_NAME${VIDEO_EXT} $ISO_DIR/preview/$ISO_NAME${VIDEO_EXT2} >/dev/null
|
||
|
ffmpeg2theora -y -i $ISO_DIR/preview/$ISO_NAME${VIDEO_EXT} $ISO_DIR/preview/$ISO_NAME${VIDEO_EXT2} >/dev/null
|
||
|
|
||
|
#cleanup old files
|
||
|
for f in `ls $ISO_DIR/preview/*${VIDEO_EXT}`; do
|
||
|
[ "$f" = "$ISO_DIR/preview/$ISO_NAME${VIDEO_EXT}" ] || rm -f $f
|
||
|
done
|
||
|
for f in `ls $ISO_DIR/preview/*${VIDEO_EXT2}`; do
|
||
|
[ "$f" = "$ISO_DIR/preview/$ISO_NAME${VIDEO_EXT2}" ] || rm -f $f
|
||
|
done
|
||
|
|
||
|
echo "Done."
|
||
|
exit 0
|