An open API service indexing awesome lists of open source software.

https://github.com/smkent/helmet-camera

Bicycle helmet camera file management tools
https://github.com/smkent/helmet-camera

file-management udev

Last synced: about 2 months ago
JSON representation

Bicycle helmet camera file management tools

Awesome Lists containing this project

README

        

# Helmet camera video tools

These are file management tools for videos recorded by my bicycle helmet
camera.

## Quick setup

### Determine your camera's USB vendor and product ID

Plug your camera into your computer and run `lsusb` to retrieve information
about connected USB devices. Locate your camera in the device list and note the
USB vendor and product ID for your device. For example, `lsusb` prints the
following for my camera (an original ContourROAM):

```
Bus 003 Device 045: ID 0d64:5566 DXG Technology Corp.
```

In this example, `0d64` and `5566` are the USB vendor and product ID,
respectively.

### setup-udev

To automatically copy video files from your camera to your hard drive when your
camera is plugged in via USB, run `setup-udev` to install a udev rule for your
device. Specify your camera's USB vendor and product ID, as well as a
destination directory to copy videos to:

```shell
./setup-udev -d path/to/videos/directory -v 0d64 -p 5566
```

The udev rule will be placed in `/etc/udev/rules.d/81-helmet-camera.rules`.
`setup-udev` will automatically reload the udev rules. Unplug and replug your
camera to test video import.

`setup-udev` accepts additional arguments that can be passed along to
`import-videos` via the installed udev rule. Run `setup-udev --help` for more
information.

### Email notification

Provide an email address to `setup-udev` using `-e/--email-address` to receive
an email notification when video import is complete. This feature requires your
system to have a working sendmail in /usr/sbin/sendmail.

## import-videos

`import-videos` is meant to run automatically via udev. It mounts the camera
device, copies video files to a directory specified by the user, and unmounts
the camera.

I wrote this script to handle my specific camera (an original ContourROAM), but
it may be useful for video import from any camera that presents videos to the
host via USB mass storage.

### Manual udev rule installation

An appropriate udev rule can be automatically installed using `setup-udev`. See
the "Quick setup" section above for more information. These instructions
describe how to configure udev manually.

To configure `import-videos` to run automatically, create a udev rule such as
the following (the entire rule must be placed on a single line):

``` KERNEL=="sd?1", ATTRS{idVendor}=="0d64", ATTRS{idProduct}=="5566", ACTION=="add", MODE="664", RUN+="/path/to/helmet-camera/import-videos -e '[email protected]' -d '/path/to/videos/directory'" ```

Note that the `import-videos` executable name and the target videos directory
argument must be absolute paths.

The email argument is optional, but recommended. If specified, a summary is
emailed from and to the specified address when video import is complete. This
feature requires a working sendmail in /usr/sbin/sendmail.

If you have a camera other than the original ContourROAM, you will likely want
to change the `idVendor` and `idProduct` values in the above example rule. You
can determine the correct values for your hardware by examining the output of
`lsusb`.

Place your udev rule in `/etc/udev/rules.d`, for example in a file named
`/etc/udev/rules.d/81-helmet-camera.rules`.

After creating your udev rule, you may need to reload your udev configuration
by running:

```shell
$ sudo udevadm control --reload
```

Please note this udev rule has been tested on Gentoo Linux. I am not sure if
these instructions are portable to other Linux distributions.

## organize-videos

This is a utility meant to be run manually for organizing already-imported
video files. `import-videos` places all video files directly into the
specified destination directory. `organize-videos` can be used to organize
video files into subdirectories based on the recording count.

`organize-videos` uses a hardcoded organization method based on how the
ContourROAM names its video files. Please see the top of
[video\_utils/\_\_init\_\_.py](/video_utils/__init__.py) for an explanation.

Video file organization can also happen automatically in `import-videos` with
the `-o`/`--organize` option.

## cleanup-videos

This utility removes video files to free disk space, in order by video number
from lowest to highest. `cleanup-videos` removes videos until the amount of
disk space specified by `-f`/`--free-space` (in GiB) is available.

Video file organization can also happen automatically in `import-videos` by
specifying the desired amount of free disk space (in GiB) with the
`-c`/`--clean-up-free-space` option.

----

## License

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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see .

See [`LICENSE`](/LICENSE) for the full license text.