mediasnacks 0.16.5 → 0.17.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.
@@ -16,6 +16,7 @@ _mediasnacks_commands=(
16
16
  'vdiff:Plays a video with the difference of two videos'
17
17
  'vsplit:Splits a video into multiple clips from CSV timestamps'
18
18
  'vtrim:Trims video from start to end time'
19
+ 'prores:Converts video to Apple ProRes'
19
20
 
20
21
  'flattendir:Moves unique files to the top dir and deletes empty dirs'
21
22
  'seqcheck:Finds missing sequence number'
@@ -37,7 +38,7 @@ fi
37
38
 
38
39
  local cmd="$words[2]"
39
40
  case "$cmd" in
40
- avif|resize|sqcrop|moov2front|dropdups|edgespic|seqcheck|hev1tohvc1|framediff|vdiff|vconcat|vsplit|vtrim|dlaudio|dlvideo|unemoji|rmcover|curltime|gif|flattendir)
41
+ avif|resize|sqcrop|moov2front|dropdups|edgespic|seqcheck|hev1tohvc1|framediff|vdiff|vconcat|vsplit|vtrim|dlaudio|dlvideo|unemoji|rmcover|curltime|gif|flattendir|prores)
41
42
  _files
42
43
  ;;
43
44
  qdir)
package/README.md CHANGED
@@ -28,6 +28,7 @@ npx mediasnacks <command> <args>
28
28
  - `vdiff`: Plays a video with the difference of two videos
29
29
  - `vsplit`: Splits a video into multiple clips from CSV timestamps
30
30
  - `vtrim`: Trims video from start to end time
31
+ - `prores`: Converts video to Apple ProRes
31
32
 
32
33
 
33
34
  - `flattendir`: Moves unique files to the top dir and deletes empty dirs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasnacks",
3
- "version": "0.16.5",
3
+ "version": "0.17.0",
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/cli.js CHANGED
@@ -21,7 +21,8 @@ const COMMANDS = {
21
21
  vconcat: ['vconcat.sh', 'Concatenates videos'],
22
22
  vdiff: ['vdiff.sh', 'Plays a video with the difference of two videos'],
23
23
  vsplit: ['vsplit.js', 'Splits a video into multiple clips from CSV timestamps'],
24
- vtrim: ['vtrim.sh', 'Trims video from start to end time\n'],
24
+ vtrim: ['vtrim.sh', 'Trims video from start to end time'],
25
+ prores: ['prores.js', 'Converts video to ProRes\n'],
25
26
 
26
27
  flattendir: ['flattendir.sh', 'Moves all files to top dir and deletes dirs'],
27
28
  qdir: ['qdir.js', 'Sequentially runs all *.sh files in a folder'],
package/src/prores.js ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { resolve, parse, join } from 'node:path'
4
+
5
+ import { parseOptions } from './utils/parseOptions.js'
6
+ import { assertUserHasFFmpeg, run } from './utils/ffmpeg.js'
7
+
8
+ const PRORES_PROFILES = {
9
+ 'proxy': 0,
10
+ 'lt': 1,
11
+ 'standard': 2,
12
+ 'hq': 3,
13
+ '4444': 4,
14
+ '4444xq': 5,
15
+ }
16
+
17
+ const USAGE = `
18
+ Usage: mediasnacks prores [options] <video>
19
+
20
+ Converts a video to ProRes format.
21
+
22
+ Arguments:
23
+ <video> Video file to convert
24
+
25
+ Options:
26
+ --profile <n> ProRes profile (default: 3 (HQ))
27
+ -h, --help Show this help message
28
+
29
+ Example:
30
+ npx mediasnacks prores video.mov
31
+ npx mediasnacks prores --profile 2 video.mov
32
+
33
+ Outputs: video.prores.mov
34
+ `.trim()
35
+
36
+
37
+ async function main() {
38
+ await assertUserHasFFmpeg()
39
+
40
+ const { values, files } = await parseOptions({
41
+ help: { short: 'h', type: 'boolean' },
42
+ profile: { short: 'p', type: 'string', default: String(PRORES_PROFILES.hq) },
43
+ })
44
+
45
+ if (values.help) {
46
+ console.log(USAGE)
47
+ process.exit(0)
48
+ }
49
+
50
+ if (files.length !== 1)
51
+ throw new Error('Expected 1 argument: video file. See npx mediasnacks prores --help')
52
+
53
+ const videoPath = resolve(files[0])
54
+ const { name, dir } = parse(videoPath)
55
+ const outputPath = join(dir, `${name}.prores.mov`)
56
+
57
+ console.log(`Converting to ProRes…`)
58
+ await run('ffmpeg', [
59
+ '-v', 'error',
60
+ '-stats',
61
+ '-i', videoPath,
62
+ '-c:v', 'prores_ks',
63
+ '-profile:v', values.profile,
64
+ '-pix_fmt', 'yuv422p10le',
65
+ outputPath
66
+ ])
67
+ }
68
+
69
+ main().catch(err => {
70
+ console.error(err.message || err)
71
+ process.exit(1)
72
+ })