mediasnacks 0.16.2 → 0.16.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasnacks",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "description": "Utilities for optimizing and preparing videos and images for the web",
5
5
  "license": "MIT",
6
6
  "author": "Eric Fortis",
package/src/avif.js CHANGED
@@ -8,7 +8,7 @@ import { ffmpeg, assertUserHasFFmpeg } from './utils/ffmpeg.js'
8
8
 
9
9
 
10
10
  const USAGE = `
11
- Usage: npx mediasnacks avif [-y | --overwrite] [--output-dir=<dir>] <images>
11
+ Usage: mediasnacks avif [-y | --overwrite] [--output-dir=<dir>] <images>
12
12
 
13
13
  Converts images to AVIF.
14
14
  `.trim()
package/src/dropdups.js CHANGED
@@ -18,7 +18,7 @@ const PROFILE = PRORES_PROFILES.hq
18
18
 
19
19
 
20
20
  const USAGE = `
21
- Usage: npx mediasnacks dropdups [-n <bad-frame-number>] <video>
21
+ Usage: mediasnacks dropdups [-n <bad-frame-number>] <video>
22
22
 
23
23
  Removes duplicate frames and outputs ProRes 422 HQ.
24
24
 
package/src/edgespic.js CHANGED
@@ -8,7 +8,7 @@ import { ffmpeg, videoAttrs, assertUserHasFFmpeg } from './utils/ffmpeg.js'
8
8
 
9
9
 
10
10
  const USAGE = `
11
- Usage: npx mediasnacks edgespic [--width=<num>] <files>
11
+ Usage: mediasnacks edgespic [--width=<num>] <files>
12
12
 
13
13
  Extracts the first and last frames from each video and saves them to the 'edgepics/' subfolder.
14
14
  --width defaults to 640px and The aspect ratio is preserved.
@@ -0,0 +1,36 @@
1
+ import { test } from 'node:test'
2
+ import { deepEqual } from 'node:assert/strict'
3
+ import { readdirSync } from 'node:fs'
4
+
5
+ import { mkTempDir, cli, dir, touch } from './utils/test-utils.js'
6
+
7
+ test('flattendir moves files to top level and deletes empty dirs', () => {
8
+ const tmp = mkTempDir('flattendir')
9
+ dir(tmp, 'dir1', 'dir1-1')
10
+ dir(tmp, 'dir2')
11
+ touch(tmp, 'file1.txt')
12
+ touch(tmp, 'dir1', 'file2.txt')
13
+ touch(tmp, 'dir1', 'dir1-1', 'file3.txt')
14
+ touch(tmp, 'dir1', '.DS_Store')
15
+
16
+ cli('flattendir', tmp)
17
+ deepEqual(readdirSync(tmp).sort(), [
18
+ 'file1.txt',
19
+ 'file2.txt',
20
+ 'file3.txt'
21
+ ])
22
+ })
23
+
24
+ test('flattendir does not move files if filename collision occurs', () => {
25
+ const tmp = mkTempDir('flattendir-collision')
26
+ dir(tmp, 'dir1')
27
+ touch(tmp, 'file1.txt')
28
+ touch(tmp, 'dir1', 'file1.txt')
29
+
30
+ cli('flattendir', tmp)
31
+ deepEqual(readdirSync(tmp, { recursive: true }).sort(), [
32
+ 'dir1',
33
+ 'dir1/file1.txt',
34
+ 'file1.txt'
35
+ ])
36
+ })
package/src/hev1tohvc1.js CHANGED
@@ -6,7 +6,7 @@ import { videoAttrs, ffmpeg, assertUserHasFFmpeg } from './utils/ffmpeg.js'
6
6
 
7
7
 
8
8
  const USAGE = `
9
- Usage: npx mediasnacks hev1tohvc1 <videos>
9
+ Usage: mediasnacks hev1tohvc1 <videos>
10
10
 
11
11
  This program fixes video thumbnails not rendering in macOS
12
12
  Finder, and fixes video not importable in Final Cut Pro. That’s done
package/src/moov2front.js CHANGED
@@ -6,7 +6,7 @@ import { parseOptions } from './utils/parseOptions.js'
6
6
 
7
7
 
8
8
  const USAGE = `
9
- Usage: npx mediasnacks moov2front <videos>
9
+ Usage: mediasnacks moov2front <videos>
10
10
 
11
11
  Rearranges .mov and .mp4 metadata to the start of the file for fast-start streaming.
12
12
 
package/src/qdir.js CHANGED
@@ -3,14 +3,13 @@
3
3
  import { join } from 'node:path'
4
4
  import { spawn } from 'node:child_process'
5
5
  import { parseArgs } from 'node:util'
6
- import { fileURLToPath } from 'node:url'
7
6
  import { readdir, writeFile, unlink, rename } from 'node:fs/promises'
8
7
 
9
8
  import { isFile } from './utils/fs-utils.js'
10
9
 
11
10
 
12
11
  const USAGE = `
13
- Usage: npx mediasnacks qdir [folder]
12
+ Usage: mediasnacks qdir [folder]
14
13
 
15
14
  Sequentially runs all *.sh files in a folder (cwd by default).
16
15
  `.trim()
package/src/resize.js CHANGED
@@ -10,7 +10,7 @@ import { ffmpeg, videoAttrs, assertUserHasFFmpeg } from './utils/ffmpeg.js'
10
10
 
11
11
 
12
12
  const USAGE = `
13
- Usage: npx mediasnacks resize [--width=<num>] [--height=<num>] [-y | --overwrite] [--output-dir=<dir>] <files>
13
+ Usage: mediasnacks resize [--width=<num>] [--height=<num>] [-y | --overwrite] [--output-dir=<dir>] <files>
14
14
 
15
15
  Resizes videos and images. The aspect ratio is preserved when only one dimension is specified.
16
16
 
package/src/seqcheck.js CHANGED
@@ -2,11 +2,10 @@
2
2
 
3
3
  import { parseArgs } from 'node:util'
4
4
  import { readdirSync } from 'node:fs'
5
- import { fileURLToPath } from 'node:url'
6
5
 
7
6
 
8
7
  const USAGE = `
9
- Usage: npx mediasnacks seqcheck [options] [folder]
8
+ Usage: mediasnacks seqcheck [options] [folder]
10
9
 
11
10
  Find missing numbered files in a sequence.
12
11
 
package/src/sqcrop.js CHANGED
@@ -9,7 +9,7 @@ import { parseOptions } from './utils/parseOptions.js'
9
9
 
10
10
 
11
11
  const USAGE = `
12
- Usage: npx mediasnacks sqcrop [-y | --overwrite] [--output-dir=<dir>] <images>
12
+ Usage: mediasnacks sqcrop [-y | --overwrite] [--output-dir=<dir>] <images>
13
13
 
14
14
  Square crops images
15
15
  `.trim()
package/src/unemoji.sh CHANGED
@@ -17,6 +17,9 @@ find . -depth | while IFS= read -r file; do
17
17
  s/[\x{1FA70}-\x{1FAFF}]//g; # Symbols and Pictographs Extended-A
18
18
  s/[\x{1F1E6}-\x{1F1FF}]//g; # Regional Indicator Symbols
19
19
  ')
20
+
21
+ # Normalize
22
+ newbase=$(printf '%s' "$newbase" | perl -CSD -MUnicode::Normalize -pe '$_ = NFKC($_)')
20
23
 
21
24
  if [ "$base" != "$newbase" ]; then
22
25
  newpath="$dir/$newbase"
@@ -2,7 +2,7 @@ import { join } from 'node:path'
2
2
  import { tmpdir } from 'node:os'
3
3
  import { spawnSync } from 'node:child_process'
4
4
  import { createHash } from 'node:crypto'
5
- import { mkdtempSync, readFileSync } from 'node:fs'
5
+ import { mkdtempSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs'
6
6
 
7
7
  const rel = f => join(import.meta.dirname, f)
8
8
 
@@ -19,3 +19,12 @@ export function sha1(filePath) {
19
19
  .update(readFileSync(filePath))
20
20
  .digest('base64')
21
21
  }
22
+
23
+ export function dir(...args) {
24
+ return mkdirSync(join(...args), { recursive: true })
25
+ }
26
+
27
+ export function touch(...args) {
28
+ return writeFileSync(join(...args), '')
29
+ }
30
+
package/src/vsplit.js CHANGED
@@ -10,7 +10,7 @@ import { assertUserHasFFmpeg, run } from './utils/ffmpeg.js'
10
10
  // TODO looks like it's missing a frame (perhaps becaue of -c copy)
11
11
 
12
12
  const USAGE = `
13
- Usage: npx mediasnacks vsplit <csv> <video>
13
+ Usage: mediasnacks vsplit <csv> <video>
14
14
 
15
15
  Splits a video into multiple clips from CSV timestamps.
16
16