@ponderdev/justfits 0.0.0-stage → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +240 -2
- package/THIRD-PARTY-NOTICES.md +120 -0
- package/agents/skills/justfits/SKILL.md +102 -0
- package/licenses/ffmpeg-license.txt +127 -0
- package/licenses/gpl-2.0.txt +338 -0
- package/licenses/gpl-3.0.txt +674 -0
- package/package.json +51 -4
- package/scripts/link-skill.cjs +99 -0
- package/src/binaries.cjs +106 -0
- package/src/cli.cjs +603 -0
- package/src/engine.cjs +358 -0
- package/src/heif.cjs +156 -0
- package/src/kit/scan.cjs +105 -0
- package/src/kit/window.cjs +93 -0
- package/src/main.cjs +265 -0
- package/src/plan.js +257 -0
- package/src/preload.cjs +35 -0
- package/src/renderer/app.js +635 -0
- package/src/renderer/index.html +57 -0
- package/src/renderer/kit/kit.css +767 -0
- package/src/renderer/kit/kit.js +740 -0
- package/src/renderer/licenses.html +1204 -0
- package/src/renderer/styles.css +9 -0
- package/src/scan.cjs +43 -0
package/README.md
CHANGED
|
@@ -1,3 +1,241 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Just Fits
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Makes a video small enough to send. Point it at a file, pick a limit, and it
|
|
4
|
+
compresses to land just under that limit. Everything happens on your machine.
|
|
5
|
+
|
|
6
|
+
Built because "compress for Discord" is a thing everyone needs and every
|
|
7
|
+
existing answer is either a website you upload your footage to, or a wall of
|
|
8
|
+
ffmpeg flags you have to get right yourself.
|
|
9
|
+
|
|
10
|
+
## How it decides
|
|
11
|
+
|
|
12
|
+
Hitting an exact size is arithmetic, not guesswork:
|
|
13
|
+
|
|
14
|
+
1. Read the duration, resolution, frame rate and whether there is sound.
|
|
15
|
+
2. Turn the target size into a total bitrate, minus 5 percent, because mp4
|
|
16
|
+
spends a little on overhead the bitrate maths cannot see.
|
|
17
|
+
3. Give sound the smallest share that still sounds like sound. Speech stays
|
|
18
|
+
intelligible far below the point where picture falls apart, so audio gives
|
|
19
|
+
way first, and drops to mono before it drops below 48kbps.
|
|
20
|
+
4. Give the rest to picture, then pick the largest frame size that still gets
|
|
21
|
+
enough bits per pixel to look like the source. Over 32 frames a second, it
|
|
22
|
+
tries every size at the full frame rate first, then every size at 30, and
|
|
23
|
+
only then settles for a rougher picture.
|
|
24
|
+
5. Encode in two passes, which is precisely what two-pass is for.
|
|
25
|
+
6. Measure what actually came out. x264 overshoots on hard footage, so if it
|
|
26
|
+
missed, correct by the measured amount and go again. Three attempts.
|
|
27
|
+
|
|
28
|
+
All of that lives in `src/plan.js` as pure functions, with no ffmpeg and no
|
|
29
|
+
filesystem anywhere near it, because whether your file comes in under the line
|
|
30
|
+
is the one thing this has to get right. `test/plan.test.cjs` covers it.
|
|
31
|
+
|
|
32
|
+
## The presets
|
|
33
|
+
|
|
34
|
+
Checked August 2026, and they move, so they live in one list in `src/plan.js`
|
|
35
|
+
and the custom box is always there.
|
|
36
|
+
|
|
37
|
+
Discord is 10MB free, 50MB on Nitro Basic, 500MB on Nitro, and a level 3
|
|
38
|
+
boosted server gives everyone in it 100MB whether they pay or not.
|
|
39
|
+
|
|
40
|
+
The email presets aim lower than the number the provider advertises, because
|
|
41
|
+
attachments are base64 encoded in transit and that adds about 37 percent.
|
|
42
|
+
Gmail says 25MB and will bounce a 25MB file, so the Gmail preset targets 18.2MB.
|
|
43
|
+
|
|
44
|
+
## The rules it follows
|
|
45
|
+
|
|
46
|
+
- **Your original is only ever read.** Output goes to `name-fits.mp4` beside
|
|
47
|
+
it (a folder's go into a new folder beside it), and never to a path that
|
|
48
|
+
already exists.
|
|
49
|
+
- **Nothing is uploaded.** There is no network code in the app at all.
|
|
50
|
+
- **No account, no telemetry, no update checker.** The build you have is the
|
|
51
|
+
build you keep.
|
|
52
|
+
- GPL v3, like the ffmpeg build it carries.
|
|
53
|
+
|
|
54
|
+
## Running it
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
nvm use # Node 22, per .nvmrc, and 22.12 or newer. See below.
|
|
58
|
+
npm ci
|
|
59
|
+
npx install-electron # Electron 43 has no postinstall, see below.
|
|
60
|
+
npm run fetch-ffmpeg # puts ffmpeg and ffprobe in vendor/
|
|
61
|
+
npm start
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Two steps there look redundant and are not:
|
|
65
|
+
|
|
66
|
+
**Node 22.12 or newer matters.** Electron's installer does
|
|
67
|
+
`require('@electron/get')`, which is now an ES module, so it needs
|
|
68
|
+
`require(esm)`. That arrived in Node 22.12. On Node 18 the install fails with
|
|
69
|
+
`ERR_REQUIRE_ESM` and you get a checkout that tests fine and cannot open a
|
|
70
|
+
window.
|
|
71
|
+
|
|
72
|
+
**`npx install-electron` gets the binary now.** Electron 43 dropped its
|
|
73
|
+
postinstall script, so `npm ci` completes in seconds and downloads none of the
|
|
74
|
+
295MB binary. Electron fetches it the first time it starts instead, which needs
|
|
75
|
+
a network connection and Node 22.12 at that moment. Running the installer up
|
|
76
|
+
front gets that over with while you are watching.
|
|
77
|
+
|
|
78
|
+
## The command line
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
npm install -g @ponderdev/justfits
|
|
82
|
+
justfits clip.mp4 --to discord
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
No dependencies and no bundled encoder, so the install is under 2MB. It uses
|
|
86
|
+
whatever ffmpeg is on your PATH, which on Linux is one package away
|
|
87
|
+
(`pacman -S ffmpeg`, `apt install ffmpeg`). The desktop app carries its own
|
|
88
|
+
copy instead, because someone downloading a finished app should not then be
|
|
89
|
+
told to install a video encoder.
|
|
90
|
+
|
|
91
|
+
Needs Node 22 or newer, and an ffmpeg with libx264 on the PATH (no minimum version has been tested).
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
justfits clip.mp4 # beside it, as clip-fits.mp4 (a picture becomes clip-fits.jpg)
|
|
95
|
+
justfits clip.mp4 --to gmail # any preset, or a size like 25MB
|
|
96
|
+
justfits clip.mp4 -o small.mp4 # somewhere specific
|
|
97
|
+
justfits clip.mp4 --json # for scripting
|
|
98
|
+
justfits a.mp4 b.mov photo.heic # several, each fitted on its own
|
|
99
|
+
justfits "Beach day" # a folder, its subfolders too, into "Beach day (fitted)"
|
|
100
|
+
justfits "Beach day" --beside # a folder, each saved beside its original as name-fits
|
|
101
|
+
cat clip.mp4 | justfits --to 8MB > small.mp4
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Several files, or a folder, are each fitted on their own to the same target,
|
|
105
|
+
one after another. Files named on their own are saved beside their originals.
|
|
106
|
+
A folder's results go into a new folder beside it, `Beach day (fitted)`, with
|
|
107
|
+
its subfolders mirrored and each result named `name-fits` as beside the original (a file that already fits is copied in under that name,
|
|
108
|
+
so the new folder holds the whole folder), and the folder itself
|
|
109
|
+
is left as it was; done again, they go into `Beach day (fitted) 2`. `--beside`
|
|
110
|
+
(in the app, Save next to the originals instead) saves each beside its original
|
|
111
|
+
as `name-fits` instead. In a folder it takes the videos and pictures, and
|
|
112
|
+
passes over hidden files, the `._name` files a Mac leaves on other disks, and
|
|
113
|
+
its own earlier results (`name-fits.mp4` and the `(fitted)` folders), so a
|
|
114
|
+
folder done twice is not fitted on top of itself. `-o` and stdin take one file
|
|
115
|
+
only. In the app, drop several files or a folder on the window, or pick them
|
|
116
|
+
(on a Mac the picker takes folders too; on Windows and Linux, Choose a folder
|
|
117
|
+
brings one in). Cancel stops at once: the file being fitted is left as it was,
|
|
118
|
+
the ones already fitted are kept, and no more are started.
|
|
119
|
+
|
|
120
|
+
`-o` names the one result. A video has to be given an `.mp4` name and a picture
|
|
121
|
+
a `.jpg` name, and anything else is refused before the encode (a file that
|
|
122
|
+
already fits is copied to `-o` as it is, so it may keep its own extension).
|
|
123
|
+
|
|
124
|
+
If the name is taken it writes `clip-fits 2.mp4`, then 3, and never over an
|
|
125
|
+
existing file. A file that is neither video nor picture is refused with a
|
|
126
|
+
sentence saying so (exit 1). With input from stdin and no `-o`, the result goes
|
|
127
|
+
to stdout.
|
|
128
|
+
|
|
129
|
+
Progress goes to stderr, so stdout stays clean to pipe. Piped input is buffered
|
|
130
|
+
to a temp file first and it says so: two-pass encoding reads the input twice
|
|
131
|
+
and a pipe cannot be rewound.
|
|
132
|
+
|
|
133
|
+
The piped example is for macOS and Linux shells. In PowerShell, `cat` reads
|
|
134
|
+
the file as text, and Windows PowerShell 5.1 also turns anything piped between
|
|
135
|
+
programs into text, so the video comes out broken. On Windows, name the files
|
|
136
|
+
instead: `justfits clip.mp4 -o small.mp4`.
|
|
137
|
+
|
|
138
|
+
### For scripts and assistants
|
|
139
|
+
|
|
140
|
+
- `--json` prints one JSON line per thing it did, then a `done` line: a
|
|
141
|
+
`result` (written), a `skip` (it already fit) or an `error`. Errors are JSON
|
|
142
|
+
too. When the video itself goes to stdout, the JSON goes to stderr instead.
|
|
143
|
+
With several files there is one line per file, each with its `input`, and
|
|
144
|
+
one that fails does not stop the rest. One file gives the same lines as
|
|
145
|
+
before.
|
|
146
|
+
- `--describe` prints every option, its type and default, the targets and the
|
|
147
|
+
exit codes, as JSON, so nothing has to be guessed from `--help`.
|
|
148
|
+
- `--dry-run` says what would happen and writes nothing.
|
|
149
|
+
- `--help`, `--version` and `--describe` answer at once and do nothing else.
|
|
150
|
+
|
|
151
|
+
Exit status: **0** done or already fits, **1** failed, **2** a bad option,
|
|
152
|
+
target or missing file (nothing was started), **3** several files where some
|
|
153
|
+
were done and some failed, **4** still over the target after every try. With
|
|
154
|
+
several files, 1 means every one failed, and 4 that none failed but some
|
|
155
|
+
stayed over. 129, 130 and 143 mean it was stopped, with part files removed.
|
|
156
|
+
|
|
157
|
+
**Changed in 1.2.0**, for anyone with a script from before: still over the
|
|
158
|
+
target is now 4 (it was 2, which is now a usage error), and `--json` ends with a
|
|
159
|
+
`done` line, so read the first line rather than parsing everything printed.
|
|
160
|
+
The fields in a result are the same as before.
|
|
161
|
+
|
|
162
|
+
The maths and the ffmpeg work are shared with the desktop app rather than
|
|
163
|
+
reimplemented, so both produce the same output for the same input.
|
|
164
|
+
|
|
165
|
+
### For Claude and other assistants
|
|
166
|
+
|
|
167
|
+
The package carries an agent skill, `agents/skills/justfits/SKILL.md`, that
|
|
168
|
+
tells an AI assistant when to reach for Just Fits and how to drive it. Installing
|
|
169
|
+
the command line with `npm install -g` links it in for the assistants set up on
|
|
170
|
+
the machine: into Claude Code's skills folder (`~/.claude/skills/justfits`, or
|
|
171
|
+
under `$CLAUDE_CONFIG_DIR`), and into `~/.agents/skills/justfits`, the shared
|
|
172
|
+
folder that Codex, Gemini CLI, Copilot, Cursor, OpenCode, Amp and Goose read.
|
|
173
|
+
Updating the package updates the skill with it. It never replaces a folder, or
|
|
174
|
+
a link to anywhere else; it only mends a link that an earlier install of Just
|
|
175
|
+
Fits left behind (an uninstall leaves one pointing at nothing). `npm install -g
|
|
176
|
+
--ignore-scripts` skips it. After `npm uninstall -g @ponderdev/justfits`, remove
|
|
177
|
+
the leftover links: on macOS and Linux
|
|
178
|
+
`rm -f ~/.claude/skills/justfits ~/.agents/skills/justfits`, on Windows
|
|
179
|
+
`rmdir "%USERPROFILE%\.claude\skills\justfits" "%USERPROFILE%\.agents\skills\justfits"`
|
|
180
|
+
(each only if it exists; with `CLAUDE_CONFIG_DIR` set, the first is under that).
|
|
181
|
+
|
|
182
|
+
## On Linux
|
|
183
|
+
|
|
184
|
+
Unpack the .tar.gz and run `./justfits` in the folder; the AppImage needs only to be made executable. Both start the app with Chromium's sandbox where your system allows it, and without it where it does not, because Ubuntu 24.04 forbids the user namespaces the sandbox needs and the program file inside the .tar.gz (`justfits-app`) then stops at once with a "SUID sandbox helper" error unless given `--no-sandbox`. To put Just Fits in your applications menu with its icon, run `./install-desktop-entry.sh` in the unpacked folder (again if you move it).
|
|
185
|
+
|
|
186
|
+
## Keeping an older version
|
|
187
|
+
|
|
188
|
+
Installing a new version the usual way replaces the old one. To keep both:
|
|
189
|
+
|
|
190
|
+
- **Mac:** rename the old app in Applications first (to "Just Fits 1.2.0", say), then install the new one. Both open, side by side.
|
|
191
|
+
- **Windows:** the installer replaces the old version, so use the portable download instead (the .exe, or the .zip), each version in its own folder.
|
|
192
|
+
- **Linux:** each AppImage is its own file, so keep the old one beside the new. The .tar.gz works the same way, in its own folder.
|
|
193
|
+
|
|
194
|
+
The two versions share your settings. A newer version's settings are kept when the older one saves, and the older one ignores what it does not know.
|
|
195
|
+
|
|
196
|
+
## Licences
|
|
197
|
+
|
|
198
|
+
Built with kit 1.0.0, the parts every Just tool shares (the start screen, the
|
|
199
|
+
run, the footer, the folder intake), from PonderDev's tools workshop. The app's
|
|
200
|
+
licences page and `justfits --describe` (`"kit"`) say the same.
|
|
201
|
+
|
|
202
|
+
GPL-3.0-or-later, like the ffmpeg build it carries. `THIRD-PARTY-NOTICES.md`
|
|
203
|
+
names every bundled component and how the terms are met; `licenses/` holds the
|
|
204
|
+
full texts; and both are readable from inside the app under **Licences and
|
|
205
|
+
credits** in the footer.
|
|
206
|
+
|
|
207
|
+
`npm run licences` regenerates that screen from those files, and the build
|
|
208
|
+
scripts run it first so a stale one cannot ship.
|
|
209
|
+
|
|
210
|
+
## Tests
|
|
211
|
+
|
|
212
|
+
```sh
|
|
213
|
+
npm test # the size arithmetic, instant
|
|
214
|
+
node test/cli.test.cjs # the command line, as a subprocess
|
|
215
|
+
npm run test:linux # the command line on real linux, in docker
|
|
216
|
+
node test/encode.test.cjs # real encodes, a minute or two
|
|
217
|
+
electron test/window.test.cjs # the window boots and renders
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
`encode.test.cjs` builds its own footage, compresses it, and checks the result
|
|
221
|
+
is both under the limit and still playable. It also checks the original came
|
|
222
|
+
through untouched.
|
|
223
|
+
|
|
224
|
+
`test:linux` installs the published package into a Debian container, with that
|
|
225
|
+
distro's own ffmpeg, and runs the same checks. The CLI is headless so a
|
|
226
|
+
container is a real test of it. The GUI is not testable this way.
|
|
227
|
+
|
|
228
|
+
## ffmpeg
|
|
229
|
+
|
|
230
|
+
`vendor/` is not in git: the binaries are large, they are not ours to
|
|
231
|
+
redistribute through our history, and they move on someone else's schedule.
|
|
232
|
+
`npm run fetch-ffmpeg` pulls them, `--all` gets every arch a release needs.
|
|
233
|
+
|
|
234
|
+
Any GPL build with libx264 works. If a host moves, drop the binaries in by
|
|
235
|
+
hand as `ffmpeg-x64`, `ffmpeg-arm64`, `ffprobe-x64`, `ffprobe-arm64`, or with
|
|
236
|
+
`.exe` on Windows. Nothing in the app cares where they came from.
|
|
237
|
+
|
|
238
|
+
**Apple Silicon** builds come from osxexperts.net, since evermeet publishes
|
|
239
|
+
x86_64 only. Those are checked against a published SHA256 before installing,
|
|
240
|
+
and the script refuses rather than installs on a mismatch. Note the published
|
|
241
|
+
hash is of the binary inside the zip, not of the zip.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Third party notices
|
|
2
|
+
|
|
3
|
+
Just Fits is built on other people's work. This file records what it uses,
|
|
4
|
+
under what terms, and where to get the original source. Full licence texts are
|
|
5
|
+
in the `licenses/` folder and are also shown inside the app under
|
|
6
|
+
**Licences and credits** in the footer.
|
|
7
|
+
|
|
8
|
+
Just Fits itself is GPL-3.0-or-later. See `LICENSE`.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## FFmpeg
|
|
13
|
+
|
|
14
|
+
Does all of the actual work: reading the file, deciding nothing, and encoding
|
|
15
|
+
what it is told to. `ffprobe` from the same project reads the duration,
|
|
16
|
+
resolution, frame rate and stream layout that `src/plan.js` does its
|
|
17
|
+
arithmetic on.
|
|
18
|
+
|
|
19
|
+
- Project: <https://ffmpeg.org>, source at <https://github.com/FFmpeg/FFmpeg>
|
|
20
|
+
- FFmpeg's core is **LGPL v2.1 or later**. Every build shipped here is
|
|
21
|
+
configured with `--enable-gpl`, which pulls in the GPL-licensed parts and
|
|
22
|
+
moves the whole binary to the GPL. Builds that also carry
|
|
23
|
+
`--enable-version3` are **GPL v3 or later**; builds without it are **GPL v2
|
|
24
|
+
or later**. The table below says which is which.
|
|
25
|
+
- Full text: `licenses/ffmpeg-license.txt`, and the GPL itself in
|
|
26
|
+
`licenses/gpl-3.0.txt` and `licenses/gpl-2.0.txt`.
|
|
27
|
+
|
|
28
|
+
**On the command line, FFmpeg is not bundled at all.** The `justfits` command
|
|
29
|
+
uses whatever `ffmpeg` and `ffprobe` are on your PATH, so the terms that apply
|
|
30
|
+
are those of the build your system installed, not of anything shipped here.
|
|
31
|
+
Only the desktop app carries its own copy.
|
|
32
|
+
|
|
33
|
+
**The bundled binaries are not built here and are not modified.** They are
|
|
34
|
+
published builds, taken exactly as the publisher shipped them. The publishers
|
|
35
|
+
differ per platform, and so do their configure lines, so the effective licence
|
|
36
|
+
is stated per build rather than once for all of them:
|
|
37
|
+
|
|
38
|
+
| Platform and arch | Publisher | Licence, from the configure line |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| macOS x86_64 | [evermeet.cx/ffmpeg](https://evermeet.cx/ffmpeg/) | `--enable-gpl --enable-version3`, so **GPL v3 or later** |
|
|
41
|
+
| macOS arm64 | [osxexperts.net](https://www.osxexperts.net) | `--enable-gpl`, no `--enable-version3`, so **GPL v2 or later** |
|
|
42
|
+
| Windows x86_64 | [BtbN/FFmpeg-Builds](https://github.com/BtbN/FFmpeg-Builds) (the `win64-gpl` build) | `--enable-gpl --enable-version3`, so **GPL v3 or later** |
|
|
43
|
+
| Linux x86_64 | [BtbN/FFmpeg-Builds](https://github.com/BtbN/FFmpeg-Builds) (the `linux64-gpl` build) | `--enable-gpl --enable-version3`, so **GPL v3 or later** |
|
|
44
|
+
|
|
45
|
+
All four were read out of the builds those sources served, last on 15 November
|
|
46
|
+
2026. Publishers change their configure lines, so the copy on your machine is
|
|
47
|
+
the authoritative answer for your copy.
|
|
48
|
+
|
|
49
|
+
`scripts/fetch-ffmpeg.mjs` is what downloads them, and it is the complete
|
|
50
|
+
record of where they came from. To see exactly how the copy on your machine
|
|
51
|
+
was configured, including every library compiled into it:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
"/Applications/Just Fits.app/Contents/Resources/ffmpeg/ffmpeg-x64" -version
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## x264
|
|
58
|
+
|
|
59
|
+
The H.264 encoder. Every video Just Fits produces comes out of it, and the
|
|
60
|
+
two-pass rate control that makes a file land on a target size is x264's.
|
|
61
|
+
|
|
62
|
+
- Project: <https://www.videolan.org/developers/x264.html>
|
|
63
|
+
- **Licence: GNU GPL v2 or later.** Full text: `licenses/gpl-2.0.txt`
|
|
64
|
+
- Compiled into the FFmpeg builds above, unmodified.
|
|
65
|
+
|
|
66
|
+
## x265
|
|
67
|
+
|
|
68
|
+
The H.265 encoder. Compiled into the same builds. Just Fits does not currently
|
|
69
|
+
encode H.265, but the binary carries it, so it is listed.
|
|
70
|
+
|
|
71
|
+
- Project: <https://www.videolan.org/developers/x265.html>
|
|
72
|
+
- **Licence: GNU GPL v2 or later.** Full text: `licenses/gpl-2.0.txt`
|
|
73
|
+
|
|
74
|
+
## Everything else inside FFmpeg
|
|
75
|
+
|
|
76
|
+
These builds also carry libopus, libvpx, libaom, libvorbis, libmp3lame,
|
|
77
|
+
libwebp, libass, dav1d, libtheora, libspeex and around twenty more, each under
|
|
78
|
+
its own terms, mostly BSD, LGPL or MIT. They are not listed individually here
|
|
79
|
+
because the list belongs to the build rather than to this app, and it changes
|
|
80
|
+
when the build does. `ffmpeg -version` prints the exact configuration of the
|
|
81
|
+
copy you have, which is the authoritative answer for your binary.
|
|
82
|
+
|
|
83
|
+
## Electron
|
|
84
|
+
|
|
85
|
+
The application shell: Chromium for the window, Node for the file handling.
|
|
86
|
+
|
|
87
|
+
- Project: <https://www.electronjs.org>
|
|
88
|
+
- **Licence: MIT.** Electron bundles Chromium and Node.js, whose combined
|
|
89
|
+
licence text ships inside the app as `LICENSES.chromium.html`.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Meeting the GPL terms
|
|
94
|
+
|
|
95
|
+
FFmpeg as shipped here is GPL v3 or later, or GPL v2 or later on Apple Silicon
|
|
96
|
+
(the table above). Distributing it inside an application carries
|
|
97
|
+
obligations, and Just Fits meets them like this:
|
|
98
|
+
|
|
99
|
+
0. **Compatibility.** Just Fits is GPL-3.0-or-later, the same licence, so there
|
|
100
|
+
is no combination problem to solve.
|
|
101
|
+
1. **Notice.** This file, plus the in-app credits screen, names each component
|
|
102
|
+
and its licence.
|
|
103
|
+
2. **Licence texts.** Shipped in full, both in `licenses/` and inside the app.
|
|
104
|
+
3. **Source.** Linked above. Nothing was modified for Just Fits; published
|
|
105
|
+
builds are used as-is, so the upstream source is the complete source.
|
|
106
|
+
4. **Replacing them.** The binaries live in `vendor/ffmpeg` and are found by
|
|
107
|
+
name at runtime. Drop your own GPL build in with the same filenames and the
|
|
108
|
+
app uses it. Nothing is statically linked and nothing is patched.
|
|
109
|
+
|
|
110
|
+
If you would rather have the source on a disk than a link, ask and it will be
|
|
111
|
+
sent.
|
|
112
|
+
|
|
113
|
+
## A note on H.264 patents
|
|
114
|
+
|
|
115
|
+
H.264 is covered by patents in some countries. Just Fits encodes H.264 with
|
|
116
|
+
x264, an independent open source encoder, and the licence above covers the
|
|
117
|
+
copyright in that software and nothing else. Patent licensing is a separate
|
|
118
|
+
matter from the software licence. If you are redistributing Just Fits
|
|
119
|
+
commercially or at scale, take your own advice on what that means where you
|
|
120
|
+
operate.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: justfits
|
|
3
|
+
description: Shrink a video or picture to fit a size limit with Just Fits (`justfits`), PonderDev's free command line and app, so it can be sent on Discord, email, WhatsApp, Signal, Slack and the rest. Use when the user wants to send, share, upload or attach a file that is too big: "make this fit Discord", "compress this video", "it's too big to send", "get this under 50MB", "shrink this clip for Gmail", "make every video in this folder fit". Runs entirely on the user's machine. Covers checking it's installed, picking the target, running it, and checking the result.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Making a file fit with Just Fits
|
|
7
|
+
|
|
8
|
+
**Just Fits** (`justfits`) compresses a video, or a picture, to land just under
|
|
9
|
+
a size limit, and measures the result. It is PonderDev's free tool: page
|
|
10
|
+
https://ponderdev.com/justfits, source `ponder-dev/just-fits`. Use it instead of
|
|
11
|
+
hand-written ffmpeg: it works out the bitrate and size, makes as many tries as
|
|
12
|
+
it needs, and never writes over a file.
|
|
13
|
+
|
|
14
|
+
## Is it installed?
|
|
15
|
+
|
|
16
|
+
command -v justfits && justfits --version
|
|
17
|
+
|
|
18
|
+
If not, the command line installs with `npm install -g @ponderdev/justfits`
|
|
19
|
+
(Node 22 or newer). That install uses `ffmpeg` from the PATH, so check
|
|
20
|
+
`command -v ffmpeg` too; if it's missing, say so and suggest the system's
|
|
21
|
+
package manager (`brew install ffmpeg`, `apt install ffmpeg`,
|
|
22
|
+
`winget install Gyan.FFmpeg`). The desktop app, from the page's download
|
|
23
|
+
button, carries its own ffmpeg. Ask before installing anything.
|
|
24
|
+
|
|
25
|
+
`justfits --help` and `justfits --describe` only print, so they're safe to run.
|
|
26
|
+
`--help` lists the current targets.
|
|
27
|
+
|
|
28
|
+
## Pick the target: ask where it's going
|
|
29
|
+
|
|
30
|
+
The limit decides the quality, so ask where the file is going if the user
|
|
31
|
+
hasn't said. A long video into a small target comes out small and soft; say so
|
|
32
|
+
before running.
|
|
33
|
+
|
|
34
|
+
| `--to` | Size | For |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| `discord` (default) | 10MB | Discord, free account |
|
|
37
|
+
| `discord-basic` | 50MB | Discord Nitro Basic |
|
|
38
|
+
| `discord-boost3` | 100MB | a Discord server boosted to level 3 |
|
|
39
|
+
| `discord-nitro` | 500MB | Discord Nitro |
|
|
40
|
+
| `gmail` | 18.2MB | Gmail (its 25MB limit, less the email encoding) |
|
|
41
|
+
| `outlook` | 14.6MB | Outlook and Microsoft 365 |
|
|
42
|
+
| `whatsapp` | 16MB | WhatsApp video |
|
|
43
|
+
| `signal`, `imessage` | 100MB | Signal, iMessage |
|
|
44
|
+
| `slack` / `telegram` | 1GB / 2GB | Slack, Telegram |
|
|
45
|
+
| `25MB` etc. | any | a plain size |
|
|
46
|
+
|
|
47
|
+
Services change their limits; `justfits --help` on the installed copy is the
|
|
48
|
+
list that counts. If the file already fits, Just Fits says so and writes
|
|
49
|
+
nothing: send the original.
|
|
50
|
+
|
|
51
|
+
## Run it
|
|
52
|
+
|
|
53
|
+
justfits "/path/to/video.mp4" --to discord-basic --json
|
|
54
|
+
|
|
55
|
+
- Several files, or a folder (subfolders too), go in one run:
|
|
56
|
+
`justfits a.mp4 b.mov --to gmail --json` or `justfits "/path/to/folder" --json`.
|
|
57
|
+
Each is fitted on its own to the same target; nothing is combined. Files
|
|
58
|
+
named on their own are saved beside their originals; a folder's results go
|
|
59
|
+
into a new folder beside it, `folder (fitted)` (subfolders mirrored, results
|
|
60
|
+
named `name-fits`, files that already fit copied in so the folder is
|
|
61
|
+
complete, the folder untouched). `--beside` saves each beside its original as
|
|
62
|
+
`name-fits` instead. In a folder, hidden files, earlier `-fits` results and
|
|
63
|
+
`(fitted)` folders are passed over. `-o` and stdin take one file only.
|
|
64
|
+
- A video comes out as `name-fits.mp4` beside it, a picture as `name-fits.jpg`.
|
|
65
|
+
Then `name-fits 2.mp4` and so on: it never writes over a file, and the
|
|
66
|
+
original is only read. `-o path` writes somewhere else.
|
|
67
|
+
- `-o path` names the one result: a video must end in `.mp4` and a picture in
|
|
68
|
+
`.jpg` (a `.mov` or `.png` for the wrong kind is refused with exit 2, before
|
|
69
|
+
anything is encoded). If the file already fits, `-o` still gets a copy of it,
|
|
70
|
+
as a `result` line; without `-o` it is a `skip` line and nothing is written.
|
|
71
|
+
- It reads video (mp4, mov, m4v, mkv, webm, avi) and pictures (jpg, png, heic,
|
|
72
|
+
webp, gif). An animated WebP is refused (exit 1, code `animated-webp`) because
|
|
73
|
+
it would lose its animation. A file that is damaged or is not a video or
|
|
74
|
+
picture is refused with exit 1, never reported as "already fits".
|
|
75
|
+
- `--to` takes a preset or a size such as `25MB`, `800KB` or `1.5GB`. `8b` is
|
|
76
|
+
refused as bytes, since it is one letter from 8MB or 8KB.
|
|
77
|
+
- `--dry-run` says what it would do and writes nothing.
|
|
78
|
+
- With `--json`, stdout is JSON lines: a `result` line (`output`, `before` and
|
|
79
|
+
`after` in bytes, `target`, `attempts`, `width`, `height`, and `notes` when the video is long
|
|
80
|
+
for the target), or a `skip` line
|
|
81
|
+
when it already fits, or an `error` line; then always a `done` line. With
|
|
82
|
+
several files that is one line per file, each with its `input`.
|
|
83
|
+
- Exit codes: 0 done or already fit; 2 a usage mistake (bad option, unknown
|
|
84
|
+
target, missing file), nothing started; 4 still over the target after every
|
|
85
|
+
try, with the closest result written; 1 failed (with several files, every
|
|
86
|
+
one failed); 3 several files where some were done and some failed; 129, 130 or 143 stopped by a
|
|
87
|
+
signal, part files removed.
|
|
88
|
+
- A video takes every CPU core for a minute or more. On a machine someone is
|
|
89
|
+
using, run it as `nice -n 19 justfits ...` and mention that a game or call
|
|
90
|
+
running at the same time may stutter.
|
|
91
|
+
|
|
92
|
+
## Report back
|
|
93
|
+
|
|
94
|
+
Give the output path in full, the size before and after, and the resolution it
|
|
95
|
+
chose (`width` x `height`). If the resolution came out low, say so and offer
|
|
96
|
+
the next target up, or trimming the video first. A `notes` entry or a line on
|
|
97
|
+
stderr saying the video is long for the target means the picture will be soft
|
|
98
|
+
or blurry: pass that on. On exit 4, say it's still
|
|
99
|
+
over and by how much. For several files, sum it up (how many fitted, the total
|
|
100
|
+
before and after) and name each one that failed or stayed over, with its
|
|
101
|
+
reason. Nothing is uploaded by Just Fits; don't send or upload
|
|
102
|
+
the file yourself unless the user asks.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# License
|
|
2
|
+
|
|
3
|
+
Most files in FFmpeg are under the GNU Lesser General Public License version 2.1
|
|
4
|
+
or later (LGPL v2.1+). Read the file `COPYING.LGPLv2.1` for details. Some other
|
|
5
|
+
files have MIT/X11/BSD-style licenses. In combination the LGPL v2.1+ applies to
|
|
6
|
+
FFmpeg.
|
|
7
|
+
|
|
8
|
+
Some optional parts of FFmpeg are licensed under the GNU General Public License
|
|
9
|
+
version 2 or later (GPL v2+). See the file `COPYING.GPLv2` for details. None of
|
|
10
|
+
these parts are used by default, you have to explicitly pass `--enable-gpl` to
|
|
11
|
+
configure to activate them. In this case, FFmpeg's license changes to GPL v2+.
|
|
12
|
+
|
|
13
|
+
Specifically, the GPL parts of FFmpeg are:
|
|
14
|
+
|
|
15
|
+
- optional x86 optimization in the files
|
|
16
|
+
- `libavcodec/x86/flac_dsp_gpl.asm`
|
|
17
|
+
- `libavcodec/x86/idct_mmx.c`
|
|
18
|
+
- `libavfilter/x86/vf_removegrain.asm`
|
|
19
|
+
- the following building and testing tools
|
|
20
|
+
- `compat/solaris/make_sunver.pl`
|
|
21
|
+
- `doc/t2h.pm`
|
|
22
|
+
- `doc/texi2pod.pl`
|
|
23
|
+
- `libswresample/tests/swresample.c`
|
|
24
|
+
- `tests/checkasm/*`
|
|
25
|
+
- `tests/tiny_ssim.c`
|
|
26
|
+
- the following filters in libavfilter:
|
|
27
|
+
- `signature_lookup.c`
|
|
28
|
+
- `vf_blackframe.c`
|
|
29
|
+
- `vf_boxblur.c`
|
|
30
|
+
- `vf_colormatrix.c`
|
|
31
|
+
- `vf_cover_rect.c`
|
|
32
|
+
- `vf_cropdetect.c`
|
|
33
|
+
- `vf_delogo.c`
|
|
34
|
+
- `vf_eq.c`
|
|
35
|
+
- `vf_find_rect.c`
|
|
36
|
+
- `vf_fspp.c`
|
|
37
|
+
- `vf_histeq.c`
|
|
38
|
+
- `vf_hqdn3d.c`
|
|
39
|
+
- `vf_kerndeint.c`
|
|
40
|
+
- `vf_lensfun.c` (GPL version 3 or later)
|
|
41
|
+
- `vf_mcdeint.c`
|
|
42
|
+
- `vf_mpdecimate.c`
|
|
43
|
+
- `vf_nnedi.c`
|
|
44
|
+
- `vf_owdenoise.c`
|
|
45
|
+
- `vf_perspective.c`
|
|
46
|
+
- `vf_phase.c`
|
|
47
|
+
- `vf_pp7.c`
|
|
48
|
+
- `vf_pullup.c`
|
|
49
|
+
- `vf_repeatfields.c`
|
|
50
|
+
- `vf_sab.c`
|
|
51
|
+
- `vf_signature.c`
|
|
52
|
+
- `vf_smartblur.c`
|
|
53
|
+
- `vf_spp.c`
|
|
54
|
+
- `vf_stereo3d.c`
|
|
55
|
+
- `vf_super2xsai.c`
|
|
56
|
+
- `vf_tinterlace.c`
|
|
57
|
+
- `vf_uspp.c`
|
|
58
|
+
- `vf_vaguedenoiser.c`
|
|
59
|
+
- `vsrc_mptestsrc.c`
|
|
60
|
+
|
|
61
|
+
Should you, for whatever reason, prefer to use version 3 of the (L)GPL, then
|
|
62
|
+
the configure parameter `--enable-version3` will activate this licensing option
|
|
63
|
+
for you. Read the file `COPYING.LGPLv3` or, if you have enabled GPL parts,
|
|
64
|
+
`COPYING.GPLv3` to learn the exact legal terms that apply in this case.
|
|
65
|
+
|
|
66
|
+
There are a handful of files under other licensing terms, namely:
|
|
67
|
+
|
|
68
|
+
* The files `libavcodec/jfdctfst.c`, `libavcodec/jfdctint_template.c` and
|
|
69
|
+
`libavcodec/jrevdct.c` are taken from libjpeg, see the top of the files for
|
|
70
|
+
licensing details. Specifically note that you must credit the IJG in the
|
|
71
|
+
documentation accompanying your program if you only distribute executables.
|
|
72
|
+
You must also indicate any changes including additions and deletions to
|
|
73
|
+
those three files in the documentation.
|
|
74
|
+
* `tests/reference.pnm` is under the expat license.
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
## External libraries
|
|
78
|
+
|
|
79
|
+
FFmpeg can be combined with a number of external libraries, which sometimes
|
|
80
|
+
affect the licensing of binaries resulting from the combination.
|
|
81
|
+
|
|
82
|
+
### Compatible libraries
|
|
83
|
+
|
|
84
|
+
The following libraries are under GPL version 2:
|
|
85
|
+
- avisynth
|
|
86
|
+
- frei0r
|
|
87
|
+
- libcdio
|
|
88
|
+
- libdavs2
|
|
89
|
+
- librubberband
|
|
90
|
+
- libvidstab
|
|
91
|
+
- libx264
|
|
92
|
+
- libx265
|
|
93
|
+
- libxavs
|
|
94
|
+
- libxavs2
|
|
95
|
+
- libxvid
|
|
96
|
+
|
|
97
|
+
When combining them with FFmpeg, FFmpeg needs to be licensed as GPL as well by
|
|
98
|
+
passing `--enable-gpl` to configure.
|
|
99
|
+
|
|
100
|
+
The following libraries are under LGPL version 3:
|
|
101
|
+
- gmp
|
|
102
|
+
- libaribb24
|
|
103
|
+
- liblensfun
|
|
104
|
+
|
|
105
|
+
When combining them with FFmpeg, use the configure option `--enable-version3` to
|
|
106
|
+
upgrade FFmpeg to the LGPL v3.
|
|
107
|
+
|
|
108
|
+
The VMAF, mbedTLS, RK MPI, OpenCORE and VisualOn libraries are under the Apache License
|
|
109
|
+
2.0. That license is incompatible with the LGPL v2.1 and the GPL v2, but not with
|
|
110
|
+
version 3 of those licenses. So to combine these libraries with FFmpeg, the
|
|
111
|
+
license version needs to be upgraded by passing `--enable-version3` to configure.
|
|
112
|
+
|
|
113
|
+
The smbclient library is under the GPL v3, to combine it with FFmpeg,
|
|
114
|
+
the options `--enable-gpl` and `--enable-version3` have to be passed to
|
|
115
|
+
configure to upgrade FFmpeg to the GPL v3.
|
|
116
|
+
|
|
117
|
+
### Incompatible libraries
|
|
118
|
+
|
|
119
|
+
There are certain libraries you can combine with FFmpeg whose licenses are not
|
|
120
|
+
compatible with the GPL and/or the LGPL. If you wish to enable these
|
|
121
|
+
libraries, even in circumstances that their license may be incompatible, pass
|
|
122
|
+
`--enable-nonfree` to configure. This will cause the resulting binary to be
|
|
123
|
+
unredistributable.
|
|
124
|
+
|
|
125
|
+
The Fraunhofer FDK AAC and OpenSSL libraries are under licenses which are
|
|
126
|
+
incompatible with the GPLv2 and v3. To the best of our knowledge, they are
|
|
127
|
+
compatible with the LGPL.
|