https://github.com/wyvernixtl/crop4mkv
Bun ts script that analyses crop margins of a video and sets the flags for an mkv.
https://github.com/wyvernixtl/crop4mkv
bun bunjs crop cropping matroska matroska-files
Last synced: 4 months ago
JSON representation
Bun ts script that analyses crop margins of a video and sets the flags for an mkv.
- Host: GitHub
- URL: https://github.com/wyvernixtl/crop4mkv
- Owner: WyvernIXTL
- License: mpl-2.0
- Created: 2025-02-09T15:39:33.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2025-03-01T13:24:22.000Z (4 months ago)
- Last Synced: 2025-03-01T14:24:01.933Z (4 months ago)
- Topics: bun, bunjs, crop, cropping, matroska, matroska-files
- Language: TypeScript
- Homepage:
- Size: 131 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `crop4mkv`
**Bun TS script that analyzes crop margins of a video and sets the flags for an MKV.**
[](https://www.npmjs.com/package/crop4mkv)
[](https://github.com/WyvernIXTL/crop4mkv/blob/master/LICENSE)* This script searches with [`ffmpeg` `cropdetect`](https://ffmpeg.org/ffmpeg-filters.html#cropdetect) at multiple different points in the video to check the crop.
* It then takes the crop per axis that clips the fewest pixels (the safe crop).
* The crop is then saved into the MKV flags with [MKVToolNix](https://mkvtoolnix.download/) without touching the video stream.Video players like [MPV](https://mpv.io/) read this MKV flag and crop the video at play time.
## Usage
Generate and set crop tags for a single file:
```
crop4mkv ./myvideo.mkv
```Generate and set crop tags recursively for a directory:
```
crop4mkv ./myDir/
```Do not write tag to file:
```
crop4mkv --dryrun PATH
```Skip check for the existence of crop tags:
```
crop4mkv --overwrite PATH
```Sometimes a movie or show might have a few scenes that are in a different format.
If almost the entire video is 21/9, but one scene is 16/9, it might make sense to ignore that one scene by filtering outliers:
```
crop4mkv --filter PATH
```For some options, there exist shorthand flags, which you can write together:
```
crop4mkv PATH -dof # Dryrun, Overwrite, Filter
```
```
crop4mkv PATH -o # Overwrite
```## Prerequisites
* [MKVToolNix](https://mkvtoolnix.download/) installed and in [PATH](https://www.howtogeek.com/787217/how-to-edit-environment-variables-on-windows-10-or-11/).
* [ffmpeg](https://ffmpeg.org/) installed and in PATH.
* [bun](https://bun.sh/) installed and in PATH.I recommend for Windows users to install these dependencies apart from bun with [Scoop](https://scoop.sh/):
```
scoop bucket add main
scoop install main/ffmpeg
scoop bucket add extras
scoop install extras/mkvtoolnix
```## Installation
```
bun install -g crop4mkv
```## Images


