Commit Graph

58 Commits

Author SHA1 Message Date
zii
c5393484c2 v3.4.t3
-added aud_codec to the conf file so audio codec is now a
 configurable option.

-renamed stream_codec to vid_codec on the conf file to contrast
 aud_codec.

-rtsp streams now use udp instead of tcp.

-updated README with conf file changes.
2024-04-03 17:28:53 -04:00
zii
7ca4fc3dbe v3.3.t9
-moved buff_path setup code away from rdconf() to loadSh(). this
 insures root will never take ownership of the camera buffer.
-added service group option.
-updated the documentation in preperation of release.
2023-12-23 17:38:11 -05:00
Zii
60a24c9d67 v3.3.t4
-completely reformed the eventloop code to be more efficent and
 removed the use backward/forward facing functions.
-added the live_secs config option that limits the amount of live
 footage the app will record to the buffer directory.
-moved away from ffmpeg hls formatting. live footage will instead
 just be recorded in clips inside of the 'live' directory, the
 stream.m3u8 file will not longer be created. doing this removes
 the codec/container limitations that hls imposed.
-changed up the default conf values that better suits a low spec
 machine like a resberrypi.
2023-11-05 18:44:50 -05:00
Zii
525c342c0f v3.3.t3
-moved all service related code to seperate files.
-split the camera service into 2 systemd services.
-the -i, -c and -d options now function differently to support the
 split systemd services.
-internal logging was completely removed. all verbose output will
 instead just go to stderr/stdout. will use journalctl for real
 time logging instead.
-fixed the magick compile/install script so it will actually run
 now.
-fixed a bug in the config file reading functions so it will now
 trim off white spaces and line breaks at the ends. doing this
 now prevents undefined behaviour if any parameter has a line
 break in it.
-service user was added as a config file option. this can be used
 to set user name the installed services will run under. the
 default user is "mow."
-the install.sh script will now add the default mow user to the
 video group making it possible to record footage from webcams
 without permission issues.
2023-10-27 15:43:17 -04:00
Zii
83080cfe41 v3.3.t2
-pixel sizes for video and thumbnails are now configurable
-the amount of recording and snapshot threads are now
 configurable
-changed the default buffer and recording directories to
 drop the application name and also drop a level
-service files are now stored in a dedicated dir
-fixed logging so it will capture errors better
-moved folder structure building to rdConfig() and added more
 error capturing
-recording fps is now configurable
2023-10-19 15:04:39 -04:00
Zii
41ccf1d1e7 v3.3.t1
-removed the web interface. this project will instead continue to
 focus on backend operations. external applications can interface
 with the buf/rec directories to provide frontend operations.

-removed the magick binary file from the project. magick will
 instead be built from source on the target machine for maximum
 support for the target architecture.

-stream codec and format are now user configurable.

-recording thumbnail and video formats are now user configurable.
2023-10-08 10:09:15 -04:00
Zii
3791b29cf7 v3.2.t2
-fixed the -i option that was using /etc instaead of /etc/mow
-the externalized image comparison executable is now configurable
 in the config file.
-moved the main index.html and theme.css files to the buffer dir,
 moving even more io to the buffer dir.
2023-08-06 10:17:10 -04:00
Zii
367ecc839b v3.2.t1
-the -d option will no longer directly run camera instances. it
 will instead utilize systemd to install camera services.

-added -i, -l and -r options to manage camera services.

-the app will now default work and output directories in the
 /var/opt directory instead of /var/www/html and /tmp, making
 it a better neighbour in the fact that it won't overwrite
 existing websites or tmp files.

-install.sh will now create an unprivileged mow user that will
 be used to run camera services. all in effort to make the app
 a good neighour and follow good security practice.
2023-07-31 11:16:07 -04:00
Zii
ad733f8317 v3.1.t2
added a buffer directory so the actual work of image frame capture
and live video recording can be moved off of main storage.

also removed installation of the apache2 http server from
install.sh to make this app more agnostic and leave it up to the
end user to install what ever web server they want.
2023-07-18 18:47:14 -04:00
Zii
510bdda64c v3.0.t16
-the debug code from the previous commit help narrow down what
 function is causing the crash but that's it, I need more. decided
 add the debug build type to cmake and will use gdb to help with
 debugging.

-decided to remove the debug code since I'll use gdb as the long
 term solution going forward.
2023-06-11 07:41:57 -04:00
Zii
9e7d8ee1ee v3.0.t16
-the app is still crashing, adding a bunch of console output to
 help with debug.
2023-06-10 22:44:38 -04:00
Zii
4b4c2649b8 v3.0.t13
-removed use of evtHist. will instead allow eventLoop to que up
 duplicate live video clips and then remove later using
 QStringList::removeDuplicates().

-changed up the ffmpeg commands to utilize tcp and re-added a tcp
 timeout argument, removing the need for command stall checking.

-added logic to pick the snapshot with the highest diff score as
 the event thumbnail.
2023-06-09 16:24:32 -04:00
Maurice ONeal
b445906403 v3.0.t7
-added a dely to DetectLoop after a positive motion detection to
 prevent motion event overlap.

-moved the 2 image diff pair compair to proper "end of array" in
 DetectLoop.

-increased the size of the image stream so queded up events will
 be able generate thumbnails properly.

-cleaned off a bunch of unused parameters in the code.

-adjusted the default motion sensitivity after real world
 testing.

-added libfuse-dev to setup.sh since imagemagic needs that to
 operate.
2023-05-27 09:33:14 -04:00
Maurice ONeal
4134d4befb v3.0.t6
The Qt approach to grabbing frames from the live stream was also
a failure.

- decided to switch to a combination ffmpeg and imagemagic was
  external commands to do motion detection. this approach
  elimates the need for opencv altogeather so it was removed
  from the project. system resource usage appears to be decent
  and perhaps better than opencv.
2023-05-26 16:12:53 -04:00
Zii
40ef014e0f v3.0.t3
Got the app up to "not failing immediately" state.

However, for some reason DetectLoop is failing hard via opencv
being unable to open the stream clips.

I'll continue deep diving this. For now everything else works.
2023-05-17 21:10:39 +00:00
Zii
80e6980d9e Fixed a compile error. 2023-05-17 19:40:09 +00:00
Maurice ONeal
bbad30a5b0 v3.0.t2
Added the much need code in Camera object to actual start all of
the threads.

Added multi instance support via the -d option.

Made the Loop object loop structure slot-signal compatible so
all objects using it can interupt the main loop to run other
slots.
2023-05-17 15:06:58 -04:00
Maurice ONeal
b5ebbace12 v3.0.t1
Fixed some compile errors and currently debugging some issue with
setup.sh.
2023-05-15 19:39:29 -04:00
Maurice ONeal
fa834aba6c v3.0.t1
Completely re-written the project to use the QT API. By using Qt,
I've open up use of useful tools like QCryptographicHash, QString,
QByteArray, QFile, etc.. In the future I could even make use of
slots/signals. The code is also in general much more readable and
thread management is by far much easier.

General operation of the app should be the same, this commit just
serves as a base for the migration over to QT.
2023-05-15 15:29:47 -04:00
Maurice ONeal
3f3cbcc75b v2.1.t3
-adjusted config defaults

Attempting to slow down motion detection again. This time it should
properly match the camera's fps.
2023-04-21 16:01:14 -04:00
Maurice ONeal
b4ca30b0e1 v2.1.t2
the delay on the motion detection loop slowed it down too much to
the point that it falls too far behind live. I removed the delay
and re-introduced the frame gap so all frames in the video files
need to be decoded.

post command and event timers are now seperate but still tied to
a single thread so they can still be synced.

fixed an issued that cuased several thmubnails to not generate.

added more log lines the aid with debugging.
2023-04-20 14:52:59 -04:00
Maurice ONeal
bafd2bf727 v2.1.t1
- reduced the hls size to 2 seconds.
- motion clips are not being combined. fixed it by making event
  loop track the size of shared_t::recList instead of system time.
- maxScore is now global inside of shared_t instead of locally
  inside detectMoInStream().
2023-04-15 08:23:49 -04:00
Maurice ONeal
19872b3ff5 v2.0
updated documentation and cleaned up the code. preparing to release to
master.
2023-03-28 20:27:12 -04:00
Zii
83b206c06c v2.0.t13
Fixed the crashing issue by adding tcp timeout args to ffmpeg and
having the app handle empty frames from a disconnected camera
better.

Reformed the directory structure by having live, logs and events in
seperate directories.

schLoop() no longer exists, postCmd is now handled by
detectMoInStream() to ensure motion detection is not done while the
command is running.
2023-03-26 10:45:23 -04:00
Maurice ONeal
061c2571b4 v2.0.t9
Event VODs are still not playing back correctly. Trying mp4 format
instead of hls.
2023-03-12 15:27:53 -04:00
Maurice ONeal
3c5dbec24c v2.0.t7
Apparently native html5 or modern browsers do not support running .m3u8
playlist directly or I was missing something in the original code. Even
adding the correct mime types in apache2 didn't work so I decided to
embed hls.js into the video html files to support hls playlist.
2023-03-11 16:32:00 -05:00
Maurice ONeal
bddde644c1 v.2.0.t4
Fixed the compile error.
2023-03-10 19:47:36 -05:00
Maurice ONeal
ae46834777 v2.0.t3
Event recordings are not writing out correctly. added more log lines to
help debug.
2023-03-10 19:35:44 -05:00
Maurice ONeal
b0dbfa0852 v2.0.t2
Logs are not rotating correctly. Changed up the code to append the logs
in memory and then dump them to permanent storage on every loop of
upkeep(). Hopefully this fixes the issue.
2023-03-10 19:05:54 -05:00
Maurice ONeal
a065b7a1d3 v2.0.t1
Completely reformed the internal workings of the application code. I
brought back multi-threaded functions so there is now 5 separate threads
for different tasks.

recLoop() - this function calls ffmpeg to begin recording footage from
the defined camera and stores the footage in hls format. It is designed
to keep running for as long as the application is running and if it does
stop for whatever reason, it will attempt to auto re-start.

upkeep() - this function does regular cleanup and enforcement of maxDays
maxLogSize and maxEvents without the need to stop recording or detecting
motion.

detectMo() - this function reads directly from recLoop's hls output and
list all footage that has motion in it. motion detection no longer has
to wait for the clip to finish recording thanks to the use of .ts
containers for the video clips. this makes the motion detection for less
cpu intensive now that it will now operate at the camera's fps (slower).

eventLoop() - this function reads the motion list from detectMo and
copies the footage pointed out by the list to an events folder, also in
hls format.

schLoop() - this function runs an optional user defined external command
every amount of seconds defined in sch_sec. this command temporary stops
motion detection without actually terminating the thread. It will also
not run the command at the scheduled time if motion was detected.

Benefits to this reform:

- far less cpu intensive operation
- multi-threaded architecture for better asynchronous operation
- it has support for live streaming now that hls is being used
- a buff_dir is no longer necessary
2023-03-05 16:07:07 -05:00
Maurice ONeal
81da33ba81 v1.6.t9
The fork() architecture from the previous commit is also deemed a
failure. Reverted back to v1.5.t19 code. I'll start from scratch, using
this commit as the new base.
2023-02-18 21:21:34 -05:00
Maurice ONeal
13eaf75c8a v1.6.t8
going back to basics. removed all threading code and opted for a multi
process architecture using fork(). previous code had a bad memory leak
and doesn't handle unexpected camera disconnects and for some reason it
also didn't recover gracefully in systemctl when it crashes. Hopefully
this new re-write fixes all of those numerous issues.

moDetect() will now try multiple times to grab buffer footage before
giving up and moving on.
2023-02-18 17:43:10 -05:00
Maurice ONeal
4758b62275 v1.6.t6
The crashing problems may have started after switching my test machine
to to multiple config file setup. I'll test this theory by completely
removing the multiple config file feasure and see if it crashes again.

I'll figure out a better solution for multi config files in the next
round of deveoplment.
2023-02-12 15:04:32 -05:00
Maurice ONeal
23e0ae935e v1.6.t3
Added string trimming to the vid_container parameter to filter out bad
user input.

Added detection_stream url to the config file and made it so the
application can now use a smaller/lower bit rate stream for motion
detection separate from the recording stream. This can significantly
lower CPU usage.

Moved away from using system() and the explicit timeout command. Instead
opted to using popen() and cancelable pthreads. Doing this pulls back
more control over ffmpeg than before and the app will now properly
respond term signals and even the CTRL-C keyboard interrupt.
2023-02-05 14:05:56 -05:00
Maurice ONeal
80f8ec07e3 v1.6.t2
The app was still cutting out last command line arg of my test setup.
Later found out it was the run script limiting the command line arg
count to 3. I extended it out to 8 but I'll need to find a better option
to make it limitless.
2023-01-18 21:55:17 -05:00
Maurice ONeal
62a6139f3a v1.6.t1
The is not currently parsing multiple config files properly. Changed up
the parser function without complicated check ahead logic. Will test if
this works.
2023-01-18 20:51:16 -05:00
Maurice ONeal
62b2bfd76b v1.5.t19
Added the ability to read multiple config files so it's now possible to
load a singular global config and then load a camera specific config in
another.

Many elements in the web interface are coming out too small. Added meta
viewport device width in hopes that the web interface will self adjust
to device it is being displayed on.

Changed duration to num_of_clips and added clip_len so the amount of
seconds in each clip and the amount of clips to be processed for motion
are now adjustable.

Adjusted a several default values.
2022-12-24 13:48:51 -05:00
Maurice ONeal
4e44111ea8 v1.5.t18
Discovered that the "ffmpeg stall" is still an issue so I put the
timeout call back into the ffmpeg command.

Changed the default pix_thresh to 10000.
2022-12-22 20:15:14 -05:00
Maurice ONeal
b470915276 v1.5.t16
The app is still failing with intermittent moov atom failures on trying
to open the video clips with opencv VideoCapture. I suspect it is trying
to open the files while ffmpeg is not done finalizing them. Reformed the
detection loop to spawn dedicated motion detection threads for each
video clip and only when ffmpeg confirmed finished.
2022-12-21 20:30:37 -05:00
Maurice ONeal
ad4a6357b4 v1.5.t15
Thanks the debug messages, in found a potential issue with the video
clips being pulled from the in house test cameras. Sometimes the video
clips are being pulled with incomplete meta information causing opencv
to fail to open the clips. Added "-movflags faststart" to the ffmpeg
command that should hopefully fix this and should help the app to handle
unreliable camera streams more gracefully.

max_clips now defaults to 90 instead of 30.
2022-12-20 20:25:54 -05:00
Maurice ONeal
2e10d31ab6 v1.5.t13
Added the ability change the video codec via the config file.

Changed the install script to now install the application in the /opt
directory and then symm link to /usr/bin. Doing this allowed me to
create a run script to start the application and enable the
OPENCV_VIDEOIO_DEBUG parameter for opencv. This should make it easier to
diagnose video-io issues with opencv.

Updated the README documentation with all of the changes done to the
application since v1.5.
2022-12-18 10:25:46 -05:00
Maurice ONeal
c153fdcd21 v1.5.t10
Somewhere in the code is causing an infinite loop, root cause still
undermined. added more logging statements to help me find misbehavior.
imgDiff() will now handle empty frames on the parameters more
gracefully.

enforceMaxClips() will no longer assume all video clips are accompanied
by html and jpg files but will now instead "delete if exists."
2022-12-16 18:30:27 -05:00
Maurice ONeal
a5ee164b4e v1.5.t9
The app is hard crashing now but I was able to determine the cause this
time. Must functions in filesystem tend to abort if the filesystem
object doesn't exists. Added protection where needed to prevent crashing
2022-12-13 21:13:10 -05:00
Maurice ONeal
954fdfba0b v1.5.t8
Logs are still being cutoff, I'm assuming the app is crashing but can't
locate the problem without any logs. Reformed logging to never overwrite
the logs and will instead append only. Size control will be in the form
of the byte size of the log files.
2022-12-13 20:27:32 -05:00
Maurice ONeal
2bd600bd51 v1.5.t5
Fixed a bug that caused the buffDir to get deleted before the app did
any work. Apparently the filesystem lib crashes the app if the directory
doesn't exists. Might need to add protection against that in the future.

Directory pages with now explicitly link to index.html since implicit
does not work for apache2.
2022-12-11 15:06:09 -05:00
Maurice ONeal
5ab50433cf v1.5.t4
The error checking with ffmpeg is not working. Learned that it doesn't
always return 0 on success. Decided to remove the error checking
altogether. Instead ffmpeg failures should be checked manually using
stderr.

Dirent includes .. and . so I decided to switch to the filesystem entry
listing that should hopefully exclude those special directories.

The camera webroot was not generating .index files. those files would
only get generated if motion was detected. Copied the code that does
that onto recLoop() to execute regardless of motion.
2022-12-11 12:33:56 -05:00
Maurice ONeal
baeaabbd55 v1.5.t3
Fixed the default webroot directory to apache's correct webroot. Also
renamed separated outDir from webRoot and made webRoot changeable on the
config file.

Added logging the recorder and detection loops to help with debugging
and troubleshooting. Just like the video clips, max log lines were added
to control the size of the data being saved to storage.
2022-12-11 10:25:22 -05:00
Maurice ONeal
ce4a326b24 v1.5.t2
The camera folder will now be auto created and eventually will cause the
app to auto create the webroot regardless if motion was detected or not.
2022-12-04 20:07:20 -05:00
Maurice ONeal
9816ba339f v1.5.t1
Decided to switch using opencv's builtin pixel diff motion detection via
absdiff and thresh. Doing this should increase efficiency instead of
using the home brewed pixel loops and threads.

Added a web interface of sorts by having html files output along with
the video clips. These files are designed to link together with the
assumption that the output directory is a web root like /var/www/html
that apache2 uses. The interface is crude at best but at least allow
playback of recorded footage.

Added max_clips config variable that can limit the amount of motion
events that can recorded to storage on a single day.
2022-12-04 15:13:39 -05:00
Maurice ONeal
a0ee8e35f7 v1.4.t11
completely removed object detection code because I don't foresee going
back to that model anytime soon. diffs will not reset to 0 instead
decrement and the consecutive pixel diffs are now adjustable via
consec_threshold.

updated README.md for the changes to pixel diff detection.
2022-10-14 14:31:12 -04:00