electric_eye 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ecf642c699ff3a4a565dad774c7ceec948bae69
4
- data.tar.gz: 57c68395cb6e192f8c379cb3cd0e2a8bb27eae60
3
+ metadata.gz: c334d34da5e715dafc4bf25b413633745f7ddc81
4
+ data.tar.gz: 2e36a9cfcf7292a8bebfba866321f9a4f5ef3508
5
5
  SHA512:
6
- metadata.gz: 44593cfa1f41f8ab98880d83ea1608ea181adc07e3d5860701df37a4795a26d6860fa0ad0bd2c354ea12840404bdc65658a973dbb2cce2234064e931ccd28eeb
7
- data.tar.gz: df339343fee4e10616918e16eb6e433ec49f487d2cd7754233fcc6bfcfd736100412b91dec98ca3e9267d1d0315726ca1edba976a8c8526f1133e274e51474c4
6
+ metadata.gz: 1ae7373bcd7de070a94709af9d6475b36cabedced738efe18b5b42cf8b84ad28db982099e595dd9df370122dd595067cb65e3e6f73ea9f75f3e1f7c8fa20abbb
7
+ data.tar.gz: 7336de5be6c21b4d9e2ac5302571322c80fe9daad713ea2623f7dd3f828f2bd8f30e48e8b8e68a180b36a7011da411f95791452011e6f061434c0b44fa1f29b5
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.4
1
+ 2.2.5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- electric_eye (0.1.0)
4
+ electric_eye (0.1.1)
5
5
  construct
6
6
  filewatcher
7
7
  methadone (~> 1.9.0)
data/README.org CHANGED
@@ -12,8 +12,9 @@ I started with VLC doing the recording up to 0.1.0 where I changed over to using
12
12
 
13
13
  ** Requirements
14
14
 
15
- - ffmpeg - recording & motion detection
16
- - ruby
15
+ - ffmpeg 3.x - recording & motion detection
16
+ We are using 3.x for it's reconnect features.
17
+ - ruby 1.9.3 or above
17
18
  - Linux (Tested on Debian 7, Xubuntu 14.04)
18
19
 
19
20
  ** Installation
@@ -66,6 +67,10 @@ Files will be numbered up to your wrap figure. The wrap figure determines when t
66
67
 
67
68
  The default is going to be 10 minute blocks, this can be overridden with the duration variable above in minutes.
68
69
 
70
+ ** Rebooting cameras
71
+
72
+ Some people reboot their cameras everynight. This does not work well with electric eye at the moment. As a work around you have to stop and start electric eye in your crontab.
73
+
69
74
  ** Usage
70
75
 
71
76
  First make sure you add your cameras
@@ -181,6 +186,9 @@ Example for cleaning up reception after 60days at 7pm everynight.
181
186
  Then just call 'electric_eye --remove-recordings' within crontab
182
187
  This would iterate over all my cameras and remove old recordings to keep a rolling set of days.
183
188
 
189
+ - [ ] Adjust motion detection to date format
190
+ : <yyyymmdd>-<hhmm>-<camera name>.mpeg
191
+
184
192
  - [ ] Allow motion detection to be turned on/off (default: off)
185
193
 
186
194
  - [ ] Threshold should be per camera or have inside & outside thresholds
@@ -13,7 +13,7 @@ module ElectricEye
13
13
  end
14
14
 
15
15
  def start
16
- @motion = Motion.new # Create a new instance method to our motion library
16
+ # @motion = Motion.new # Create a new instance method to our motion library
17
17
 
18
18
  pids = []
19
19
  # Start the recording for each camera
@@ -29,7 +29,9 @@ module ElectricEye
29
29
  # segment_time = how much time to record in each segment in seconds, ie: 3600 = 1hr
30
30
  # sgement_wrap = how many copies
31
31
  loglevel = "-loglevel panic" if logger.level >= 1
32
- cmd="ffmpeg -f mjpeg -i #{camera[:url]} #{loglevel} -acodec copy -vcodec copy -y -f segment -segment_list #{listfile} -segment_time #{@configEye.config.duration} -segment_wrap #{@configEye.config.wrap} #{path}%03d.mpeg"
32
+
33
+ # ffmpeg 3.0.1 used
34
+ cmd="ffmpeg -i #{camera[:url]} #{loglevel} -c copy -f segment -segment_list #{listfile} -segment_time #{@configEye.config.duration} -segment_wrap #{@configEye.config.wrap} -y -reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 300 #{path}%03d.mjpeg"
33
35
 
34
36
  # Run command and add to our pids to make it easy for electric_eye to clean up.
35
37
  info "Starting to record #{camera[:name]}"
@@ -52,7 +54,7 @@ module ElectricEye
52
54
  path = path(camera)
53
55
 
54
56
  # Watch the directory & read from the list file
55
- filewatcher = FileWatcher.new("#{path}*.mpeg")
57
+ filewatcher = FileWatcher.new("#{path}*.mjpeg")
56
58
  filewatcher.watch do |f|
57
59
  file = read_listfile("#{path}.list")
58
60
  if file
@@ -60,7 +62,7 @@ module ElectricEye
60
62
 
61
63
  # Run motion detection on the file, make sure that we output to a different file.
62
64
  loglevel = "-loglevel panic" if logger.level >= 1
63
- cmd="ffmpeg -i #{dir}/#{file} #{loglevel} -y -vf \"select=gt(scene\\,0.003),setpts=N/(25*TB)\" #{dir}/motion-#{file}"
65
+ cmd="ffmpeg -i #{dir}/#{file} #{loglevel} -y -vf \"select=gt(scene\\,0.003),setpts=N/(25*TB)\" #{dir}/#{date_filename(camera)}.mpeg"
64
66
 
65
67
  # Run command and add to our pids to make it easy for electric_eye to clean up.
66
68
  Process.spawn(cmd)
@@ -74,13 +76,6 @@ module ElectricEye
74
76
  lines.last.chomp! unless lines.length == 0
75
77
  end
76
78
 
77
- # Remove a recording
78
- def remove(path)
79
- debug "REMOVE #{path}.mpeg (no motion)"
80
- File.delete("#{path}.log")
81
- File.delete("#{path}.mpeg")
82
- end
83
-
84
79
  def stop
85
80
  stop_recordings(get_pids) if File.exist?(PID_FILE)
86
81
  end
@@ -101,6 +96,10 @@ module ElectricEye
101
96
  dir
102
97
  end
103
98
 
99
+ def date_filename(camera)
100
+ "#{Time.now.strftime('%Y%m%d-%H%M%S')}-#{camera[:name]}"
101
+ end
102
+
104
103
  def path(camera)
105
104
  "#{dir(camera)}/#{camera[:name]}"
106
105
  end
@@ -1,3 +1,3 @@
1
1
  module ElectricEye
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
data/spec/record_spec.rb CHANGED
@@ -27,7 +27,7 @@ describe "record" do
27
27
  end
28
28
  end
29
29
 
30
- describe "#dir" do
30
+ describe "#date_filename" do
31
31
  before do
32
32
  Timecop.freeze(Time.local(2015,06,30,10,05,0))
33
33
  end
@@ -36,6 +36,13 @@ describe "record" do
36
36
  Timecop.return
37
37
  end
38
38
 
39
+ it "returns a filename with date" do
40
+ filename = @record.date_filename(@configEye.config.cameras.first)
41
+ expect(filename).to eq("20150630-100500-Reception")
42
+ end
43
+ end
44
+
45
+ describe "#dir" do
39
46
  it "returns a full dir" do
40
47
  dir = @record.dir(@configEye.config.cameras.first)
41
48
  expect(dir).to eq("~/recordings/Reception")
@@ -43,14 +50,6 @@ describe "record" do
43
50
  end
44
51
 
45
52
  describe "record_path" do
46
- before do
47
- Timecop.freeze(Time.local(2015,06,30,10,05,0))
48
- end
49
-
50
- after do
51
- Timecop.return
52
- end
53
-
54
53
  it "returns a full path" do
55
54
  path = @record.path(@configEye.config.cameras.first)
56
55
  expect(path).to eq("~/recordings/Reception/Reception")
@@ -123,24 +122,4 @@ describe "record" do
123
122
  end
124
123
  end
125
124
  end
126
-
127
- describe "#remove" do
128
- before do
129
- @path = "/tmp/electric_eye"
130
- File.new("#{@path}.log", "w")
131
- File.new("#{@path}.mjpeg", "w")
132
- end
133
-
134
- it "removes recording" do
135
- expect(File.exist?("#{@path}.mjpeg")).to equal(true)
136
- @record.remove(@path)
137
- expect(File.exist?("#{@path}.mjpeg")).to equal(false)
138
- end
139
-
140
- it "removes log" do
141
- expect(File.exist?("#{@path}.log")).to equal(true)
142
- @record.remove(@path)
143
- expect(File.exist?("#{@path}.log")).to equal(false)
144
- end
145
- end
146
125
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: electric_eye
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Pope
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2016-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: construct
@@ -283,3 +283,4 @@ test_files:
283
283
  - spec/motion_spec.rb
284
284
  - spec/record_spec.rb
285
285
  - spec/spec_helper.rb
286
+ has_rdoc: