IP Cam monitor project - need help!

Started by tERBO, October 14, 2012, 10:07:42 AM

Previous topic - Next topic

tERBO

I am working on a project that will allow me to watch several webcams on a TV (or any other display) without a PC. I am not a great programmer, so I went easiest way - write a simple shell script that checks if button is pressed and starts mplayer when needed. Here is the code:

#!/bin/sh
#
clear;
fbi -T 1 -noverbose /mnt/video/plswait.gif
mplayer -fps 15 -loop 0 -really-quiet -framedrop -vo fbdev2 -fs -nocache -nosound -nolirc -demuxer lavf -lavfdopts probesize=32 "http://84.242.4.43/mjpg/1/video.mjpg?fps=15&ololo.mjpg"&

# Function
#
check_gpio_mplayer () {
while :; do

  if [ "1" = "$(</sys/class/gpio/gpio${1}/value)" ]; then
    killall -v mplayer
    fbi -T 1 -noverbose /mnt/video/plswait.gif
  if [ "9" = "${2}" ]; then
    mplayer -fps 15 -loop 0 -really-quiet -framedrop -vo fbdev2 -fs -nocache -nosound -nolirc -demuxer lavf -lavfdopts probesize=32 "http://84.242.4.43/mjpg/1/video.mjpg?fps=15&ololo.mjpg"&
  else
    mplayer -fps 5 -loop 0 -really-quiet -framedrop -vo fbdev2 -vf scale=360:288 -geometry 720x576-500-500 -nocache -nosound -nolirc -demuxer lavf -lavfdopts probesize=32 "http://cam1.infolink.ru/mjpg/1/video.mjpg?resolution=CIF&fps=5&ololo.mjpg"&
    mplayer -fps 5 -loop 0 -really-quiet -framedrop -vo fbdev2 -vf scale=360:288 -geometry 720x576+500-500 -nocache -nosound -nolirc -demuxer lavf -lavfdopts probesize=32 "http://84.242.4.43/mjpg/1/video.mjpg?resolution=CIF&fps=5&ololo.mjpg"&
    mplayer -fps 5 -loop 0 -really-quiet -framedrop -vo fbdev2 -vf scale=360:288 -geometry 720x576-500+500 -nocache -nosound -nolirc -demuxer lavf -lavfdopts probesize=32 "http://178.158.205.86/mjpg/1/video.mjpg?resolution=CIF&fps=5&ololo.mjpg"&
    mplayer -fps 5 -loop 0 -really-quiet -framedrop -vo fbdev2 -vf scale=360:288 -geometry 720x576+500+500 -nocache -nosound -nolirc -demuxer lavf -lavfdopts probesize=32 "http://217.197.122.134/mjpg/1/video.mjpg?resolution=CIF&fps=5&ololo.mjpg"&
  fi
  fi
sleep .2s
done &
}

# Open the GPIO port
#
for gpio in 16 7 6 5 4 3 2 1 0; do
echo "$gpio" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio${gpio}/direction
done

# Read forever
#
for cmd in "16 1" "7 2" "6 3" "5 4" "4 5" "3 6" "2 7" "1 8" "0 9"; do
check_gpio_mplayer $cmd
done

exit 0


As you can see I have 9 buttons here. Last one opens one full-screen image and the others should open 8 different quad displays, but for the test purposes they are all the same right now.

This code works fine on the Raspberry Pi, but on the Olinuxino it is very slow. The button-polling routine does not give mplayer any chance to display even a first frame of the video.

So I want to ask the community if anyone can improve my code (maybe rewrite it in python or C++) or can give me any other suggestion how to make my system work faster.

Thanks!