Metadata-Version: 2.5
Name: remote-compression
Version: 0.2.0
Summary: rcomp performs batch video compression with ffmpeg, locally or on a remote server.
Project-URL: Repository, https://github.com/balouf/remote-compression
Project-URL: Documentation, https://balouf.github.io/remote-compression
Author-email: Fabien Mathieu <loufab@gmail.com>
Maintainer-email: Fabien Mathieu <loufab@gmail.com>
License-Expression: MIT
License-File: AUTHORS.md
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: click>=8.1.8
Requires-Dist: paramiko>=3.5.0
Requires-Dist: platformdirs>=4.5.1
Requires-Dist: tqdm>=4.67.0
Description-Content-Type: text/markdown

# Remote Compression


[![PyPI Status](https://img.shields.io/pypi/v/remote-compression.svg)](https://pypi.python.org/pypi/remote-compression)
[![Build Status](https://github.com/balouf/remote-compression/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/balouf/remote-compression/actions?query=workflow%3Abuild)
[![Documentation Status](https://github.com/balouf/remote-compression/actions/workflows/docs.yml/badge.svg?branch=main)](https://github.com/balouf/remote-compression/actions?query=workflow%3Adocs)
[![License](https://img.shields.io/github/license/balouf/remote-compression)](https://github.com/balouf/remote-compression/blob/main/LICENSE)
[![Code Coverage](https://codecov.io/gh/balouf/remote-compression/branch/main/graphs/badge.svg)](https://codecov.io/gh/balouf/remote-compression/tree/main)

`rcomp` compresses videos in batch with ffmpeg — on this machine, or on a remote
server over SSH.

- Free software: MIT license
- Documentation: https://balouf.github.io/remote-compression/.

## Features

- **Batch**: point it at a directory, it recursively finds the videos worth
  compressing (already-compliant files are left alone) and shows progress bars.
- **Everything comes out as mkv**: subtitles and odd containers (avi, wmv,
  flv...) stop breaking conversions; text subtitles are converted when needed.
- **Local or remote**: `-D my_server` compresses on a server (Linux **or**
  Windows) through a single SSH connection for the whole batch; `-D local`
  (or a hostname that resolves to this machine) runs locally.
- **Robust remote**: the workspace is created automatically, ffmpeg is checked
  at connection time, a lost connection is patiently re-established and the
  running encode is *re-attached* instead of relaunched.
- **Persistent preferences**: a TOML file managed with `rcomp config`, with
  named presets; command-line flags always win.
- **Failure log**: corrupt and non-profitable files are remembered (centrally,
  no droppings in your video folders) and skipped on the next runs; inspect it
  with `rcomp failures`.
- **Rotation-aware**: phone videos with rotation metadata are sized by their
  *display* definition — a 1080x1920 portrait is 1080p, not "1920 tall".
- **Old-source friendly**: interlaced material (DVD, AVCHD) is deinterlaced
  automatically, and odd-dimension oddities no longer break the encoder.

## Requirements

- `ffmpeg` and `ffprobe` in the local PATH.
- For remote compression:
  - an entry in `~/.ssh/config` for the server (private key; `ProxyJump`
    supported); `-D user@alias` is accepted too,
  - the SFTP service enabled on the server (Synology DSM ships with it
    disabled: Control Panel > File Services > FTP > SFTP),
  - `ffmpeg` in the PATH of the server (checked at connection, with a clear
    error message otherwise). The `.rcomp` workspace is created automatically.

## Usage

```console
$ rcomp movies/                     # compress a directory on the default host
$ rcomp -D nas -P hard movies/      # named preset on a specific server
$ rcomp -D local -n movies/         # local dry-run: show what would be done
$ rcomp config --init               # create the configuration template
$ rcomp remote status               # inspect the server workspace
$ rcomp remote purge --older-than 7d
$ rcomp failures                    # see why files are being skipped
$ rcomp cleanup movies/             # remove legacy .keep files (rcomp < 0.2)
$ rcomp --help
```

Configuration lives in a TOML file whose location is shown by `rcomp config`
(platform-dependent, e.g. `%LOCALAPPDATA%/rcomp` on Windows,
`~/.config/rcomp` on Linux). Notable keys: `hostname` (your default server),
`codec`, `crf`, `ffmpeg_preset`, `height`, `replace`, `extensions`,
`remote_ffmpeg` (explicit server-side binary path, when the non-interactive
PATH misses it or the stock build lacks encoders — both typical on Synology),
`remote_workdir`/`remote_workdir_sftp` (the workspace as seen by the shell
and by SFTP respectively — Synology chroots SFTP into the share tree, so pair
the default `.rcomp` with `remote_workdir_sftp = "/home/.rcomp"`), and
`[preset.X]` tables for your own presets. Each run also writes a full debug log under the
directory shown by `rcomp config`.

Note: `rcomp TARGET` is a shortcut for `rcomp run TARGET`; a target literally
named `config`, `cleanup`, `failures`, `remote` or `run` must therefore be
written `rcomp run <target>`.

## Credits

This package was created with [Cookiecutter][CC] and the [Package Helper 3][PH3] project template.

[CC]: https://github.com/audreyr/cookiecutter
[PH3]: https://balouf.github.io/package-helper-3/
