~warmwaffles/gopro-utils

71b2cf84fb85239792efebf7a33cb731303118aa — Matthew Johnston 5 months ago 02fee7a master
Remove archive and optimize from the organize command
2 files changed, 0 insertions(+), 65 deletions(-)

M README.md
M gopro
M README.md => README.md +0 -18
@@ 7,8 7,6 @@ importing.

* python 3+
* [ffmpeg](https://git.ffmpeg.org/ffmpeg.git)
* [jpegoptim](https://github.com/tjko/jpegoptim)
* [jpeginfo](https://github.com/tjko/jpeginfo)

## Installation



@@ 32,22 30,6 @@ The directory structure is as follows:
    * 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`


M gopro => gopro +0 -47
@@ 126,41 126,6 @@ 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():
                parent_path = path.parent
                outfile = Path(timelapse_dir, f"{path.name}.tar.zst")
                print(f"Archiving {path} => {outfile}")
                subprocess.run(
                    [
                        "tar",
                        "--directory",
                        parent_path,
                        "--zstd",
                        "-cf",
                        outfile,
                        path.name
                    ],
                    check=True,
                )


def timelapse(args):
    working_dir = Path(args.dir).resolve()


@@ 249,18 214,6 @@ organize_parser.add_argument(
    help="the model of go pro used",
    default="hero7",
)
organize_parser.add_argument(
    "--archive",
    type=str_to_bool,
    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",