mediasnacks 0.18.0 → 0.18.2
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/.zsh/completions/_mediasnacks +0 -6
- package/README.md +18 -4
- package/install-zsh-completions.sh +23 -0
- package/package.json +11 -4
- package/src/avif.js +1 -1
- package/src/cli.js +1 -1
- package/src/dropdups.js +1 -1
- package/src/edgespic.js +2 -2
- package/src/prores.js +5 -5
- package/src/resize.js +2 -2
- package/src/sqcrop.js +1 -1
- package/src/vsplit.js +2 -2
- package/src/vtrim.js +1 -1
- package/.editorconfig +0 -11
- package/.github/workflows/test.yml +0 -25
- package/Dockerfile +0 -13
- package/TODO.md +0 -7
- package/docs/macos-quick-action.png +0 -0
- package/generate-fixtures.sh +0 -11
package/README.md
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
# mediasnacks
|
|
2
2
|
|
|
3
|
-
Utilities
|
|
3
|
+
Utilities video and images.
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
### Install
|
|
7
7
|
**FFmpeg and Node.js must be installed.**
|
|
8
8
|
|
|
9
|
-
```
|
|
10
|
-
|
|
9
|
+
```sh
|
|
10
|
+
npm install -g mediasnacks
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Optionally, if you have `ignore-scripts=true` in your `.npmprc`,
|
|
14
|
+
you can install zsh auto-completions with:
|
|
15
|
+
```sh
|
|
16
|
+
$(npm root -g)/mediasnacks/install-zsh-completions.sh
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Overview
|
|
22
|
+
```sh
|
|
23
|
+
mediasnacks <command> <args>
|
|
11
24
|
```
|
|
12
25
|
|
|
26
|
+
|
|
13
27
|
### Commands
|
|
14
28
|
- `avif` Converts images to AVIF
|
|
15
29
|
- `sqcrop` Square crops images
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
# Exit on systems without ZSH
|
|
5
|
+
zsh=$(command -v zsh) || exit 0
|
|
6
|
+
|
|
7
|
+
src="$(cd "$(dirname "$0")" && pwd)/.zsh/completions/_mediasnacks"
|
|
8
|
+
[ -f "$src" ] || exit 0
|
|
9
|
+
|
|
10
|
+
exec "$zsh" -s "$src" << 'ZSH_EOF'
|
|
11
|
+
src="$1"
|
|
12
|
+
for dir in "${fpath[@]}"; do
|
|
13
|
+
if [ -w "$dir" ]; then
|
|
14
|
+
dst="$dir/_mediasnacks"
|
|
15
|
+
ln -sf "$src" "$dst"
|
|
16
|
+
echo "linked zsh completions: $dst -> $src"
|
|
17
|
+
exit 0
|
|
18
|
+
fi
|
|
19
|
+
done
|
|
20
|
+
echo "zsh completions: no writable fpath directory found, skipping." >&2
|
|
21
|
+
exit 0
|
|
22
|
+
ZSH_EOF
|
|
23
|
+
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mediasnacks",
|
|
3
|
-
"version": "0.18.
|
|
4
|
-
"description": "Utilities for optimizing and preparing videos and images
|
|
3
|
+
"version": "0.18.2",
|
|
4
|
+
"description": "Utilities for optimizing and preparing videos and images",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Eric Fortis",
|
|
7
7
|
"type": "module",
|
|
@@ -9,6 +9,13 @@
|
|
|
9
9
|
"mediasnacks": "src/cli.js"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"test": "docker run --rm $(docker build -q .)"
|
|
13
|
-
|
|
12
|
+
"test": "docker run --rm $(docker build -q .)",
|
|
13
|
+
"postinstall": "sh install-zsh-completions.sh",
|
|
14
|
+
"dev-install": "npm i -g . --ignore-scripts=false"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src",
|
|
18
|
+
".zsh",
|
|
19
|
+
"install-zsh-completions.sh"
|
|
20
|
+
]
|
|
14
21
|
}
|
package/src/avif.js
CHANGED
package/src/cli.js
CHANGED
package/src/dropdups.js
CHANGED
|
@@ -45,7 +45,7 @@ async function main() {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
if (!files.length)
|
|
48
|
-
throw new Error('No video specified. See
|
|
48
|
+
throw new Error('No video specified. See mediasnacks dropdups --help')
|
|
49
49
|
|
|
50
50
|
let nBadFrame = values['bad-frame-number']
|
|
51
51
|
if (nBadFrame && !/^\d+$/.test(nBadFrame))
|
package/src/edgespic.js
CHANGED
|
@@ -14,8 +14,8 @@ Extracts the first and last frames from each video and saves them to the 'edgepi
|
|
|
14
14
|
--width defaults to 640px and The aspect ratio is preserved.
|
|
15
15
|
|
|
16
16
|
Example:
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
mediasnacks edgespic --width 800 *.mov
|
|
18
|
+
mediasnacks edgespic -w 600 'videos/**/*.mp4'
|
|
19
19
|
`.trim()
|
|
20
20
|
|
|
21
21
|
|
package/src/prores.js
CHANGED
|
@@ -23,12 +23,12 @@ Arguments:
|
|
|
23
23
|
<video> Video file to convert
|
|
24
24
|
|
|
25
25
|
Options:
|
|
26
|
-
--profile <n> ProRes profile (default: 3 (HQ))
|
|
27
|
-
-h, --help
|
|
26
|
+
-p, --profile <n> ProRes profile (default: 3 (422 HQ))
|
|
27
|
+
-h, --help Show this help message
|
|
28
28
|
|
|
29
29
|
Example:
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
mediasnacks prores video.mov
|
|
31
|
+
mediasnacks prores --profile 2 video.mov
|
|
32
32
|
|
|
33
33
|
Outputs: video.prores.mov
|
|
34
34
|
`.trim()
|
|
@@ -48,7 +48,7 @@ async function main() {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
if (files.length !== 1)
|
|
51
|
-
throw new Error('Expected 1 argument: video file. See
|
|
51
|
+
throw new Error('Expected 1 argument: video file. See mediasnacks prores --help')
|
|
52
52
|
|
|
53
53
|
const videoPath = resolve(files[0])
|
|
54
54
|
|
package/src/resize.js
CHANGED
|
@@ -15,10 +15,10 @@ Usage: mediasnacks resize [--width=<num>] [--height=<num>] [-y | --overwrite] [-
|
|
|
15
15
|
Resizes videos and images. The aspect ratio is preserved when only one dimension is specified.
|
|
16
16
|
|
|
17
17
|
Example: Overwrites the input file (-y)
|
|
18
|
-
|
|
18
|
+
mediasnacks resize -y --width 480 'dir-a/**/*.png' 'dir-b/**/*.mp4'
|
|
19
19
|
|
|
20
20
|
Example: Output directory (-o)
|
|
21
|
-
|
|
21
|
+
mediasnacks resize --height 240 --output-dir /tmp/out video.mov
|
|
22
22
|
|
|
23
23
|
Details:
|
|
24
24
|
--width and --height are -2 by default:
|
package/src/sqcrop.js
CHANGED
|
@@ -30,7 +30,7 @@ async function main() {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
if (!files.length)
|
|
33
|
-
throw new Error('No images specified. See
|
|
33
|
+
throw new Error('No images specified. See mediasnacks sqcrop --help')
|
|
34
34
|
|
|
35
35
|
console.log('Cropping…')
|
|
36
36
|
for (const file of files)
|
package/src/vsplit.js
CHANGED
|
@@ -19,7 +19,7 @@ Arguments:
|
|
|
19
19
|
<video> Video file to split
|
|
20
20
|
|
|
21
21
|
Example:
|
|
22
|
-
|
|
22
|
+
mediasnacks vsplit clips.csv video.mov
|
|
23
23
|
|
|
24
24
|
Given clips.csv:
|
|
25
25
|
start,end
|
|
@@ -44,7 +44,7 @@ async function main() {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
if (files.length !== 2)
|
|
47
|
-
throw new Error('Expected 2 arguments: CSV file and video file. See
|
|
47
|
+
throw new Error('Expected 2 arguments: CSV file and video file. See mediasnacks vsplit --help')
|
|
48
48
|
|
|
49
49
|
const [csvPath, videoPath] = files.map(f => resolve(f))
|
|
50
50
|
|
package/src/vtrim.js
CHANGED
|
@@ -32,7 +32,7 @@ async function main() {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
if (!files.length)
|
|
35
|
-
throw new Error('No video specified. See
|
|
35
|
+
throw new Error('No video specified. See mediasnacks vtrim --help')
|
|
36
36
|
|
|
37
37
|
for (const file of files)
|
|
38
38
|
await trim(resolve(file), values.start, values.end)
|
package/.editorconfig
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
name: Test
|
|
2
|
-
|
|
3
|
-
on: [ push, pull_request, workflow_dispatch ]
|
|
4
|
-
|
|
5
|
-
permissions:
|
|
6
|
-
contents: read
|
|
7
|
-
pull-requests: write
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
test:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v6
|
|
15
|
-
- uses: docker/setup-buildx-action@v4
|
|
16
|
-
- uses: docker/build-push-action@v7
|
|
17
|
-
with:
|
|
18
|
-
context: .
|
|
19
|
-
load: true
|
|
20
|
-
tags: app-test
|
|
21
|
-
cache-from: type=gha
|
|
22
|
-
cache-to: type=gha,mode=max
|
|
23
|
-
|
|
24
|
-
- name: Tests
|
|
25
|
-
run: docker run --rm app-test
|
package/Dockerfile
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
FROM mwader/static-ffmpeg:8.0.1 AS ffmpeg
|
|
2
|
-
FROM node:24-bookworm-slim
|
|
3
|
-
|
|
4
|
-
COPY --from=ffmpeg /ffmpeg /usr/local/bin/ffmpeg
|
|
5
|
-
COPY --from=ffmpeg /ffprobe /usr/local/bin/ffprobe
|
|
6
|
-
|
|
7
|
-
ENV FORCE_COLOR=1
|
|
8
|
-
WORKDIR /workspace
|
|
9
|
-
|
|
10
|
-
COPY src/ src/
|
|
11
|
-
COPY package.json .
|
|
12
|
-
|
|
13
|
-
CMD ["node", "--test"]
|
package/TODO.md
DELETED
|
Binary file
|
package/generate-fixtures.sh
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
|
|
3
|
-
docker run --rm \
|
|
4
|
-
-v "$(pwd)/src/fixtures:/workspace/src/fixtures" \
|
|
5
|
-
$(docker build -q .) \
|
|
6
|
-
/bin/bash -c "
|
|
7
|
-
node --test
|
|
8
|
-
cp /tmp/avif*/lenna.avif /workspace/src/fixtures/
|
|
9
|
-
cp /tmp/edgespic*/edgespic/*.png /workspace/src/fixtures/edgespic/
|
|
10
|
-
"
|
|
11
|
-
|