@@ 18,6 18,37 @@ Or simply execute it with `python path/to/gopro`.
## Commands
+### `organize`
+
+Takes the crazy format that GoPro stores the files as and moves them into their
+respective directories.
+
+The directory structure is as follows:
+
+* timelapse
+ * chapter
+* videos
+ * thumbnails
+ * low-res
+ * hi-res
+
+Timelapse files will be optimized with `jpegoptim` which is a lossless
+optimization. There is roughly a 6% reduction in each file size.
+
+Timelapse files will also be archived using `tar`. This is so that after
+converting the timelapse to an `mp4` the directory of all the images can be
+deleted and the archive can be moved to a NAS or backed up elsewhere.
+Transferring thousands of small 2MB files over a network has a lot of overhead
+that a single tar file will suffice.
+
+#### Options
+
+* `--archive` - Set to `--archive no` to disable archiving the timelapse files.
+ Default is enabled.
+* `--optimize` - Set to `--optimize no` to disable jpegoptim. Default is
+ enabled.
+
+
### `timelapse`
Converts the timelapse images into a single `mp4` file.
@@ 126,6 126,22 @@ def organize(args):
print(f"DELETE {directory}")
directory.rmdir()
+ # Run jpegoptim on all of the gopro timelapse jpegs. I usually see a 6%
+ # optimization in size reduction. In my eyes it is worth the extra
+ # processing.
+ if args.optimize:
+ for path in list(timelapse_dir.glob("*")):
+ if path.is_dir():
+ subprocess.run(
+ [
+ "jpegoptim",
+ f"{path}/*.JPG"
+ ],
+ check=True,
+ )
+
+ # Archive all of the timelapse images into a single tar file. Makes moving
+ # an entire set of files easier.
if args.archive:
for path in list(timelapse_dir.glob("*")):
if path.is_dir():
@@ 146,7 162,6 @@ def organize(args):
)
-
def timelapse(args):
working_dir = Path(args.dir).resolve()
file_glob = Path(working_dir, "*.JPG")
@@ 240,6 255,12 @@ organize_parser.add_argument(
help="Enable or disable archiving the timelapse files",
default=True,
)
+organize_parser.add_argument(
+ "--optimize",
+ type=str_to_bool,
+ help="Enable or disable jpeg optimization",
+ default=True,
+)
timelapse_parser = subparsers.add_parser(
"timelapse",