makedist-recordvm: create better and less preview images by decreasing rate; fix preview*.jpg images size
This commit is contained in:
parent
91c16825d5
commit
3069b88a8f
@ -7,14 +7,36 @@ EXECUTION_TIME=200
|
|||||||
VIDEO_EXT=.flv
|
VIDEO_EXT=.flv
|
||||||
VIDEO_EXT2=.ogv
|
VIDEO_EXT2=.ogv
|
||||||
|
|
||||||
[ $1 ] || {
|
function usage() {
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo "recordvm.sh iso_path"
|
echo "recordvm.sh iso_path [--recreate-images] [-h]"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
ISO_PATH=$1
|
opts=($@)
|
||||||
|
|
||||||
|
while test -n "$1" ; do
|
||||||
|
case $1 in
|
||||||
|
"--recreate-images") RECREATE_IMAGES=1;;
|
||||||
|
"-h") usage; exit 0 ;;
|
||||||
|
*) if [ -z "$ISO_PATH" ]; then
|
||||||
|
ISO_PATH=$1
|
||||||
|
else
|
||||||
|
echo "Error: extra argument $1 specified; aborting."
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
[ "$ISO_PATH" ] || {
|
||||||
|
echo "Error: ISO path was not specified; aborting."
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
ISO_DIR=`dirname $ISO_PATH`
|
ISO_DIR=`dirname $ISO_PATH`
|
||||||
ISO_NAME=`basename $ISO_PATH`
|
ISO_NAME=`basename $ISO_PATH`
|
||||||
|
|
||||||
@ -23,13 +45,14 @@ ISO_NAME=`basename $ISO_PATH`
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Preparing ISO image $ISO_PATH"
|
if [ ! "$RECREATE_IMAGES" ]; then
|
||||||
ln -sf $ISO_PATH $RECORDVM_DATA/recordvm.iso
|
echo "Preparing ISO image $ISO_PATH"
|
||||||
echo "Starting virtual machine for $ISO_PATH"
|
ln -sf $ISO_PATH $RECORDVM_DATA/recordvm.iso
|
||||||
export HOME=$RECORDVM_DATA
|
echo "Starting virtual machine for $ISO_PATH"
|
||||||
xinit -- $VBOX_DISPLAY &
|
export HOME=$RECORDVM_DATA
|
||||||
|
xinit -- $VBOX_DISPLAY &
|
||||||
|
|
||||||
if [ "$VBOX" ]; then
|
if [ "$VBOX" ]; then
|
||||||
# -nocursor &
|
# -nocursor &
|
||||||
# &>$RECORDVM_DATA/recordvm.log &
|
# &>$RECORDVM_DATA/recordvm.log &
|
||||||
#VBOX_USER_HOME=$RECORDVM_DATA/VirtualBox DISPLAY=:0 /opt/VirtualBox/VBoxSDL --startvm $VBOX_VMNAME --fixedmode 1024 768 32 >/dev/null &
|
#VBOX_USER_HOME=$RECORDVM_DATA/VirtualBox DISPLAY=:0 /opt/VirtualBox/VBoxSDL --startvm $VBOX_VMNAME --fixedmode 1024 768 32 >/dev/null &
|
||||||
@ -51,7 +74,7 @@ if [ "$VBOX" ]; then
|
|||||||
done
|
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|"`
|
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
|
VBoxManage controlvm $VBOX_VMNAME reset
|
||||||
else
|
else
|
||||||
sleepcnt=0
|
sleepcnt=0
|
||||||
while true; do
|
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=`xwininfo -display $VBOX_DISPLAY -name "QEMU (qemu-recordvm)" 2>/dev/null |grep "Window id:"| sed "s|.*Window id: \([0-9a-fx]*\).*|\1|"`
|
||||||
@ -63,13 +86,13 @@ else
|
|||||||
let sleepcnt=sleepcnt+1
|
let sleepcnt=sleepcnt+1
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Windowid is: $WINID"
|
echo "Windowid is: $WINID"
|
||||||
|
|
||||||
echo "Capturing window output"
|
echo "Capturing window output"
|
||||||
mkdir -p $ISO_DIR/preview/
|
mkdir -p $ISO_DIR/preview/
|
||||||
DBUS_SESSION_BUS_ADDRESS= HOME=$RECORDVM_DATA DISPLAY=$VBOX_DISPLAY xvidcap \
|
DBUS_SESSION_BUS_ADDRESS= HOME=$RECORDVM_DATA DISPLAY=$VBOX_DISPLAY xvidcap \
|
||||||
--cap_geometry 1024x768+0+0 \
|
--cap_geometry 1024x768+0+0 \
|
||||||
--verbose 2 --gui no --audio no \
|
--verbose 2 --gui no --audio no \
|
||||||
--time $EXECUTION_TIME --file $ISO_DIR/preview/${ISO_NAME}${VIDEO_EXT} \
|
--time $EXECUTION_TIME --file $ISO_DIR/preview/${ISO_NAME}${VIDEO_EXT} \
|
||||||
@ -85,46 +108,49 @@ DBUS_SESSION_BUS_ADDRESS= HOME=$RECORDVM_DATA DISPLAY=$VBOX_DISPLAY xvidcap \
|
|||||||
# sleep 1
|
# sleep 1
|
||||||
#done
|
#done
|
||||||
|
|
||||||
echo "Powering off VM"
|
echo "Powering off VM"
|
||||||
if [ "$VBOX" ]; then
|
if [ "$VBOX" ]; then
|
||||||
VBoxManage controlvm $VBOX_VMNAME poweroff &
|
VBoxManage controlvm $VBOX_VMNAME poweroff &
|
||||||
|
|
||||||
count=0
|
count=0
|
||||||
while [ "`pidof VBoxManage`" ]; do
|
while [ "`pidof VBoxManage`" ]; do
|
||||||
let count=count+1
|
let count=count+1
|
||||||
sleep 1
|
sleep 1
|
||||||
if [ $count -gt 60 ]; then
|
if [ $count -gt 60 ]; then
|
||||||
killall -9 VBoxManage
|
killall -9 VBoxManage
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
xkill -id $WINID -display $VBOX_DISPLAY
|
xkill -id $WINID -display $VBOX_DISPLAY
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Creating preview images"
|
echo "Creating preview images"
|
||||||
rm -f $ISO_DIR/preview/*.jpg
|
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
|
ffmpeg -y -i $ISO_DIR/preview/$ISO_NAME${VIDEO_EXT} -r 0.1 -f image2 $ISO_DIR/preview/image-%02d.jpg >/dev/null
|
||||||
for i in `seq 200 -1 1`; do
|
for i in `seq 22 -1 1`; do
|
||||||
f=`printf %03d $i`
|
f=`printf %02d $i`
|
||||||
[ -e $ISO_DIR/preview/image-$f.jpg ] && {
|
[ -e $ISO_DIR/preview/image-$f.jpg ] && {
|
||||||
convert -size 320x200 $ISO_DIR/preview/image-$f.jpg $ISO_DIR/preview/preview.jpg
|
convert -resize 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
|
convert -resize 400x300 $ISO_DIR/preview/image-$f.jpg $ISO_DIR/preview/preview-400x300.jpg
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Creating ${VIDEO_EXT2} video from ${VIDEO_EXT}"
|
if [ ! "$RECREATE_IMAGES" ]; then
|
||||||
|
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
|
#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
|
ffmpeg2theora -y -i $ISO_DIR/preview/$ISO_NAME${VIDEO_EXT} $ISO_DIR/preview/$ISO_NAME${VIDEO_EXT2} >/dev/null
|
||||||
|
|
||||||
#cleanup old files
|
#cleanup old files
|
||||||
for f in `ls $ISO_DIR/preview/*${VIDEO_EXT}`; do
|
for f in `ls $ISO_DIR/preview/*${VIDEO_EXT}`; do
|
||||||
[ "$f" = "$ISO_DIR/preview/$ISO_NAME${VIDEO_EXT}" ] || rm -f $f
|
[ "$f" = "$ISO_DIR/preview/$ISO_NAME${VIDEO_EXT}" ] || rm -f $f
|
||||||
done
|
done
|
||||||
for f in `ls $ISO_DIR/preview/*${VIDEO_EXT2}`; do
|
for f in `ls $ISO_DIR/preview/*${VIDEO_EXT2}`; do
|
||||||
[ "$f" = "$ISO_DIR/preview/$ISO_NAME${VIDEO_EXT2}" ] || rm -f $f
|
[ "$f" = "$ISO_DIR/preview/$ISO_NAME${VIDEO_EXT2}" ] || rm -f $f
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Done."
|
echo "Done."
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user