icps

notes

Motion

install

apt-get install motion

config

#/etc/motion/motion.conf
#293    ffmpeg_output_movies on
#336    ffmpeg_video_codec mpeg4  
#450    target_dir /tmp/motion/
#473    movie_filename %m%d_%H%M

#Live Stream
#449    stream_port 8081
#504    stream_localhost off
#HTTP Based Control
#534    webcontrol_port 8080 
#537    webcontrol_localhost off
#sound
#640    on_event_start arecord -f cd -D sysdefault:CARD=1 /tmp/motion/%m%d_%H%M.wav
#645    on_event_end ps -ef | grep arecord  | awk '{print $2}' | xargs kill -9
#245    post_capture 25
#253    event_gap 1
#662    on_movie_end ruby /motion/motion.rb %f
#/etc/default/motion 
# set to 'yes' to enable the motion daemon
start_motion_daemon=yes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env ruby
require "net/scp"
require 'line/bot'

def upload(host,user,passwd,file)
  Net::SCP.upload!(host,user, file,file,  :ssh => { :password => passwd })
end

client = Line::Bot::Client.new do |config|
    config.channel_id     = channel_id
    config.channel_secret = channel_secret
    config.channel_mid    = channel_mid
end

file = ARGV[0].split("/motion/")[1]

begin
  client.send_text(to_mid:to_mid,text: "Alert!" )
rescue
  `echo #{file} >> /motion/alert`
  upload(host,user,passwd,"alert")
end
sleep 5
`ffmpeg -y -i #{ARGV[0]} /tmp/#{file}.gif`
`rm /tmp/#{file}.gif`

https://github.com/ccrisan/motioneye