Plugin for mjpstreamer

Max2Play Home Forums Max2Play Development (Ideas, Wishes) Plugin for mjpstreamer

Viewing 2 posts - 1 through 2 (of 2 total)
  • 6. April 2017 at 12:00 #28007

    Hi
    just started with m2p. Using rpi cam I found some restrictions to my existing solution with mjpg streamer.
    No support of external usb cams, no mjpg stream and some more … Feel free to have a look.

    I am using mjpgstreamer experimental (supporting raspicam: http://www.forum-raspberrypi.de/Thread-mjpg-streamer-input-raspicam-so) since a long time to get a simple mjpg stream for FHEM, Zoneminder a.s.o.

    e.g.

    define WebCam_Pinode3 weblink iframe http://pinode3.daheim:8088/?action=stream
    attr WebCam_Pinode3 group PiNode3
    attr WebCam_Pinode3 htmlattr width="340" height="260"
    attr WebCam_Pinode3 room Sicherheit

    To switch the functionality I just call a script (e.g. mjpg_pir) to start the service with corresponding parameters:

    
    define n_Service_PIR_Micha_off notify Service_PIR_Micha:off {system('sudo /aio/mjpg_pir pinode2.daheim');;;;}
    attr n_Service_PIR_Micha_off group PiNode2
    attr n_Service_PIR_Micha_off room Sicherheit,System

    script: mjpg_pir:

    #!/bin/sh
    ssh $1 'sudo service mjpg-streamer-mtk pir'
    

    Usecase:
    To use it as a PIR you can use emboss filter, which reduces data load on network and prevents everbody of beeing observed via cam. Using motion on my FHEM server I can easily detect motion in all rooms with configurable zones.
    Using a raspi cam with wide angle covers the complete room.

    Here is one of my init.d files to provide some services with a cam, you can enhance with more configs:

    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides: mjpgstreamer raspicam
    # Required-Start: $network
    # Required-Stop: $network
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Description: mjpg_streamer fuer raspi cam (erweitert mit PIR über emboss effekt)
    # Short-Description: Start mjpgstreamer (experimental) with raspi cam in background at boot time
    ### END INIT INFO
    
    # check for existing webcam device, nur bei usb cams, raspi weiss ich noch nicht wie.
    #if [ ! -e "/dev/video0" ]; then
    #  echo "webcam.sh: Error - NO /dev/video0 device" 2>&1 | logger
    #  exit 2
    #fi
    
    set -e
    # Source function library.
    . /lib/lsb/init-functions
    export LD_LIBRARY_PATH=/root/mjpg-streamer-experimental
    EXTRA_COMMANDS="cam shutdown pir restart_cam restart_pir"
    
    # pid=<code>ps -afx | grep mjpg_streamer | grep -v &quot;grep&quot; | cut -d &quot; &quot; -f 2</code>
    pid=<code>pidof mjpg_streamer</code>
    echo " MTK PID:-" $pid "-"
    case "$1" in
    
    'start')
    	# wird für boot start benötigt
    	/root/mjpg-streamer/mjpg_streamer --background -i "/root/mjpg-streamer/input_raspicam.so -d 0 -ex auto -vf " -o "/root/mjpg-streamer/output_http.so -p 8088 -w /root/mjpg-streamer/www"
    	;;
    
    'cam')
            # wird für start benötigt
            /root/mjpg-streamer/mjpg_streamer --background -i "/root/mjpg-streamer/input_raspicam.so -d 0 -ex auto -vf " -o "/root/mjpg-streamer/output_http.so  -p 8088 -w /root/mjpg-streamer/www"
            ;;
    
    'pir')
    	/root/mjpg-streamer/mjpg_streamer --background -i "/root/mjpg-streamer/input_raspicam.so -d 0 -ex auto -vf -x 320 -y 240 -ifx emboss" -o "/root/mjpg-streamer/output_http.so -p 8088 -w /root/mjpg-streamer/www"
    	;;
    
    'shutdown')
    	echo "Stopping mjpg-streamer-mtk ..."
    	# pkill -e mjpg_streamer 2>&1
    	# kill $pid
      	kill -9 $(pidof mjpg_streamer) >/dev/null 2>&1
    	;;
    
    'restart_cam')
    #	kill $pid
    	kill -9 $(pidof mjpg_streamer) >/dev/null 2>&1
    	/root/mjpg-streamer/mjpg_streamer --background -i "input_raspicam.so -d 0 -ex auto -vf " -o "output_http.so -p 8088 -w /root/mjpg-streamer/www" &
    ;;
    
    'restart_cam_1920')
    	kill -9 $(pidof mjpg_streamer) >/dev/null 2>&1
    	/root/mjpg-streamer/mjpg_streamer --background -i "/root/mjpg-streamer/input_raspicam.so -d 0 -ex auto -vf -x 1920 -y 1080" -o "/root/mjpg-streamer/output_http.so -p 8088 -w /root/mjpg-streamer/www" &
    ;;
    
    'restart_pir')
    	kill -9 $(pidof mjpg_streamer) >/dev/null 2>&1
    	/root/mjpg-streamer/mjpg_streamer --background -i "/root/mjpg-streamer/input_raspicam.so -d 0 -ex auto -vf -x 320 -y 240 -ifx emboss" -o "/root/mjpg-streamer/output_http.so -p 8088 -w /root/mjpg-streamer/www" &
    ;;
    
    'status_daemon')
    	echo "Status Daemon mjpg streamer MTK"
            # status_of_proc "/root/mjpg-streamer/mjpg_streamer"
    	if [ -n "$pid" ];
    		then
    		echo "mjpg_streamer is running with pid ${pid}"
    		echo "mjpg_streamer was started with the following command line"
    		cat /proc/${pid}/cmdline ; echo ""
    	else
    		echo "Could not find mjpg_streamer running"
    	fi
    ;;
    
    *)
    	echo "mtk Usage: $0 { start | cam | shutdown | pir | status_daemon | restart_cam | restart_cam_1920 | restart_pir}"
    ;;
    esac
    exit 0
    
    10. April 2017 at 14:52 #28059

    Hi mtk

    Thank you for sharing this plugin, I hope someone could benefit from it.

    Regards,
    Mohammad Mbydeen

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Register here