--- start.sh.orig 2010-12-31 15:35:20.729995034 +0100 +++ start.sh 2011-01-06 14:55:52.768003662 +0100 @@ -1,11 +1,11 @@ -#!/bin/sh - +#!/bin/bash +# #/****************************************************************************** # # # MJPG-streamer allows to stream JPG frames from an input-plugin # # to several output plugins # # # -# Copyright (C) 2007 Tom Stöveken # +# Copyright (C) 2007 Tom Stoeveken # # # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,12 +24,10 @@ ## This example shows how to invoke mjpg-streamer from the command line -export LD_LIBRARY_PATH="$(pwd)" +#export LD_LIBRARY_PATH="$(pwd)" #./mjpg_streamer -i "input_uvc.so --help" -./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www" -#./mjpg_streamer -i "./input_uvc.so -d /dev/video0" -i "./input_uvc.so -d /dev/video1" -o "./output_http.so -w ./www" -#valgrind ./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www" +#./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www" #./mjpg_streamer -i "./input_uvc.so" -o "./output_udp.so -p 2001" @@ -84,3 +82,248 @@ ## a webpage while another program streams video/audio, like skype. #./mjpg_streamer -i "./input_control.so" -o "./output_http.so -w ./www" +######################## +# Notes: README openSUSE +######################## +# +# There have been some changes regarding the paths. +# The executable mjpg_streamer is found at /usr/bin and is within the +# normal user PATH. +# +# Plugins are stored in /usr/lib/mjpg-streamer/ for the i586 architecture +# and in /usr/lib64/mjpg-streamer/ for x86_64. Note that there is a hyphen +# and not an underscore in these pathnames. +# +# All sample HTML files found their place in /usr/share/mjpg-streamer/www/ +# where they should not conflict with apache. +# +# This section is written by vodoo (a t) vakw (d o t) ch +# +# ----------------------------------------------------------------------- +# Extensions to start.sh to make mstreamer accessible from the desktop +# +# Set to yes|no or say: "mstreamer start -b" to start as daemon +RUNASDAEMON="no" + +# Get configuration parameters +if test -r "/etc/sysconfig/mjpg-streamer" ; then + . /etc/sysconfig/mjpg-streamer +else + # Set parameters here + VIDEODEV="" + #VIDEODEV="/dev/video0" + IMGSIZE="640x480" + FRAMERATE="5" + TCP_PORT="8080" + UDP_PORT="2001" +fi + +if test -n "$VIDEODEV" ; then + VIDEOOPT="-d $VIDEODEV" +else + VIDEOOPT="" +fi + +################## +# running with GUI +################## + +if test "$1" == "gui" ; then + if ! test -x "/usr/bin/kdialog" ; then + # We do our best to give a message in the logs + if test -x "/bin/logger" ; then + logger "/usr/bin/mstreamer Error: /usr/bin/kdialog not found" + fi + exit 1 + fi + + if ! test -x "/usr/bin/mjpg_streamer" ; then + kdialog --title "mjpg-streamer" \ + --error "Executable /usr/bin/mjpg_streamer not found" + exit 1 + fi + + if test -f "/usr/lib/mjpg-streamer/input_uvc.so" ; then + LIBDIR="/usr/lib" + elif test -f "/usr/lib64/mjpg-streamer/input_uvc.so" ; then + LIBDIR="/usr/lib64" + else + kdialog --title "mjpg-streamer" \ + --error "plugin input_uvc.so not found;\n aborting" + exit 1 + fi + + if ! test -f "$LIBDIR/mjpg-streamer/output_http.so" ; then + kdialog --title "mjpg-streamer" \ + --error "plugin output_http.so not found;\n aborting" + exit 1 + fi + + if ! test -f "$LIBDIR/mjpg-streamer/output_udp.so" ; then + kdialog --title "mjpg-streamer" \ + --error "plugin output_http.so not found;\n aborting" + exit 1 + fi + + # get status + MPID=$(pgrep mjpg_streamer) + if test -z "$MPID" ; then + kdialog --title "mjpg-streamer" --yesno \ + "mjpg-streamer is currently not running\n do you want to start it now?" + RETVAL="$?" + if test "$RETVAL" == "0" ; then + kdialog --title "mjpg-streamer" \ + --passivepopup "Starting mjpg-streamer, please wait ..." 2 + export LD_LIBRARY_PATH="$LIBDIR/mjpg-streamer" + /usr/bin/mjpg_streamer -b \ + -i "input_uvc.so $VIDEOOPT -f $FRAMERATE -r $IMGSIZE" \ + -o "output_http.so -p $TCP_PORT -w /usr/share/mjpg-streamer/www" \ + -o "output_udp.so -p $UDP_PORT" \ + >/dev/null 2>&1 + sleep 2 + MPID=$(pgrep mjpg_streamer) + if test -n "$MPID" ; then + kdialog --title "mjpg-streamer" \ + --msgbox "mjpg-streamer started\n The stream is available at\n http://localhost:$TCP_PORT/" + else + kdialog --title "mjpg-streamer" \ + --error "Starting mjpg-streamer failed." + exit 1 + fi + fi + else + kdialog --title "mjpg-streamer" --warningyesno \ + "mjpg-streamer is currently running\n with PID = $MPID\n do you want to stop it?" + RETVAL="$?" + if test "$RETVAL" = "0" ; then + kdialog --title "mjpg-streamer" \ + --passivepopup "Shutting down mjpg-streamer, please wait ..." 3 + pkill -SIGTERM mjpg_streamer + sleep 3 + MPID=$(pgrep mjpg_streamer) + if test -z "$MPID" ; then + kdialog --title "mjpg-streamer" \ + --msgbox "mjpg-streamer stopped" + else + kdialog --title "mjpg-streamer" \ + --error "Stopping mjpg-streamer failed\n still runs with PID=$MPID" + exit 1 + fi + fi + fi + exit 0 +fi + +################# +# run in terminal +################# + +# Check arguments +if ! test "$1" == "start" -o "$1" == "stop" -o "$1" == "status"; then + echo "Usage: mstreamer " + echo " -b starts as daemon in the background" + exit 0 +fi + +if test "$1" == "start" -a "$2" == "-b" ; then + RUNASDAEMON="yes" +fi + +# Status +if test "$1" == "status" ; then + MPID=$(pgrep mjpg_streamer) + if test -n "$MPID" ; then + echo "mjpg_streamer is running" + else + echo "mjpg_streamer is stopped" + fi + exit 0 +fi + +# Stop running mjpg_streamer +if test "$1" == "stop" ; then + MPID=$(pgrep mjpg_streamer) + if test -n "$MPID" ; then + echo "Shutting down mjpg_streamer" + pkill -SIGINT mjpg_streamer + sleep 3 + else + echo "Can not stop; mjpg_streamer is not running" + exit 1 + fi + exit 0 +fi + +# Start mjpg_streamer +if test "$1" == "start" ; then + MPID=$(pgrep mjpg_streamer) + if test -n "$MPID" ; then + echo "Can not start; mjpg_streamer is already running" + exit 1 + else + if ! test -x "/usr/bin/mjpg_streamer" ; then + echo "Executable /usr/bin/mjpg_streamer not found" + exit 1 + fi + + if test -f "/usr/lib/mjpg-streamer/input_uvc.so" ; then + LIBDIR="/usr/lib" + elif test -f "/usr/lib64/mjpg-streamer/input_uvc.so" ; then + LIBDIR="/usr/lib64" + else + echo "Plugin input_uvc.so not found; aborting" + exit 1 + fi + + if ! test -f "$LIBDIR/mjpg-streamer/output_http.so" ; then + echo "Plugin output_http.so not found; aborting" + exit 1 + fi + + if ! test -f "$LIBDIR/mjpg-streamer/output_udp.so" ; then + echo "Plugin output_udp.so not found; aborting" + exit 1 + fi + + export LD_LIBRARY_PATH="$LIBDIR/mjpg-streamer" + echo "Info: to see the stream visit http://localhost:$TCP_PORT/" + if test "$RUNASDAEMON" == "yes" ; then + # can use bash to enter daemon mode: + # /usr/bin/mjpg_streamer \ + # -i "input_uvc.so $VIDEOOPT -f $FRAMERATE -r $IMGSIZE" \ + # -o "output_http.so -w /usr/share/mjpg-streamer/www" \ + # -o "output_udp.so -p 2001" C" + /usr/bin/mjpg_streamer \ + -i "input_uvc.so $VIDEOOPT -f $FRAMERATE -r $IMGSIZE" \ + -o "output_http.so -p $TCP_PORT -w /usr/share/mjpg-streamer/www" \ + -o "output_udp.so -p $UDP_PORT" + fi + fi +fi +exit 0 + +# Command to start or stop: mstreamer +# Then point your browser at http://localhost:8080/ +# and/or take snapshots with MJPG-streamer UDP client. +# This should get you started. +# +# To stop the running mjpg_streamer run 'mstreamer stop' +# All running plugins will be gracefully stopped before +# mjpg_streamer exits.