@barbapapazes/video-toolkit 0.0.0 → 0.1.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 +21 -0
- package/README.md +150 -0
- package/dist/cli.mjs +152 -0
- package/dist/dist-CDY8lwMJ.mjs +62 -0
- package/dist/dist-U7tm8DJ9.mjs +1 -0
- package/dist/json5-DLnwT-qd.mjs +14 -0
- package/dist/jsonc-Cqp8CO2B.mjs +1 -0
- package/dist/multipart-parser-DMrr6Wla.mjs +2 -0
- package/dist/node-Xk6BB16L.mjs +16 -0
- package/dist/toml-DtpvDoI0.mjs +212 -0
- package/dist/yaml-r2t34r7_.mjs +33 -0
- package/package.json +39 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 - Estéban Soubiran <esteban@soubiran.dev> (https://soubiran.dev)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# @barbapapazes/video-toolkit
|
|
2
|
+
|
|
3
|
+
A simple and efficient CLI toolkit for video automation. It automates the process of extracting audio, generating transcriptions using OpenAI Whisper, and creating video thumbnails with text overlays.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Audio Extraction**: Automatically extracts audio from video files using `ffmpeg`.
|
|
8
|
+
- **AI Transcription**: Generates high-quality SRT subtitles using OpenAI's `whisper-1` model (defaulted to French).
|
|
9
|
+
- **Thumbnail Generation**:
|
|
10
|
+
- Extracts 5 frames from the video (Start, 25%, 50%, 75%, and End).
|
|
11
|
+
- Overlays custom text using SVG templates with `sharp` for high-quality rendering.
|
|
12
|
+
- Supports multiple SVG templates - choose different templates for different video series.
|
|
13
|
+
- Generates 5 distinct PNG thumbnails for you to choose from.
|
|
14
|
+
- **Template Management**: Easily add and manage SVG templates for different use cases.
|
|
15
|
+
- **Automatic Cleanup**: Removes temporary audio and image files after processing.
|
|
16
|
+
- **Global Configuration**: Use a global configuration file to set up your preferences once and use the tool from anywhere.
|
|
17
|
+
|
|
18
|
+
## Prerequisites
|
|
19
|
+
|
|
20
|
+
- [Node.js](https://nodejs.org/) (v22 or later recommended)
|
|
21
|
+
- [ffmpeg](https://ffmpeg.org/) installed and available in your PATH.
|
|
22
|
+
- [OpenAI API Key](https://platform.openai.com/)
|
|
23
|
+
- macOS (this tool is designed for macOS only)
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm install @barbapapazes/video-toolkit
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Configuration
|
|
32
|
+
|
|
33
|
+
The toolkit uses [c12](https://github.com/unjs/c12) for configuration loading from a global config file.
|
|
34
|
+
|
|
35
|
+
Create a configuration file at `~/.video-toolkitrc`:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"openaiApiKey": "your-api-key-here",
|
|
40
|
+
"language": "fr",
|
|
41
|
+
"model": "whisper-1"
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Configuration Options
|
|
46
|
+
|
|
47
|
+
| Option | Type | Default | Description |
|
|
48
|
+
|--------|------|---------|-------------|
|
|
49
|
+
| `openaiApiKey` | string | - | **Required.** Your OpenAI API key |
|
|
50
|
+
| `language` | string | `'fr'` | Language code for transcription (e.g., 'en', 'fr', 'es', 'de') |
|
|
51
|
+
| `model` | string | `'whisper-1'` | OpenAI Whisper model to use |
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
You can run the toolkit directly using `npx` or by installing it globally.
|
|
56
|
+
|
|
57
|
+
### Process a specific video
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
video-toolkit path/to/your-video.mp4
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Interactive selection
|
|
64
|
+
|
|
65
|
+
If you run the command without arguments, it will list all `.mp4` files in the current directory and let you choose one:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
video-toolkit
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Add a template
|
|
72
|
+
|
|
73
|
+
Add an SVG template to your templates directory:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
video-toolkit add-template path/to/your-template.svg
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
You'll be prompted to name the template (use lowercase letters, numbers, and hyphens, e.g., `series-x`, `youtube-intro`).
|
|
80
|
+
|
|
81
|
+
### Workflow
|
|
82
|
+
|
|
83
|
+
1. **Select Video**: Provide a path or choose from the list.
|
|
84
|
+
2. **Transcription**: The tool extracts audio and sends it to OpenAI.
|
|
85
|
+
3. **Thumbnail Text**: You will be prompted to enter text for the thumbnails.
|
|
86
|
+
- If you provide text, you'll be asked to select a template.
|
|
87
|
+
- 5 thumbnails will be generated with that text using the selected template.
|
|
88
|
+
- If you leave it empty, thumbnail generation will be skipped.
|
|
89
|
+
4. **Results**: SRT subtitles and PNG thumbnails are saved in the same directory as the video.
|
|
90
|
+
|
|
91
|
+
## SVG Templates
|
|
92
|
+
|
|
93
|
+
The toolkit uses SVG templates to render text overlays on thumbnails using the `sharp` library.
|
|
94
|
+
|
|
95
|
+
### Template Location
|
|
96
|
+
|
|
97
|
+
Templates are stored in `~/.config/video-toolkit/templates/`. Each template is a separate SVG file.
|
|
98
|
+
|
|
99
|
+
### Template Naming Convention
|
|
100
|
+
|
|
101
|
+
Template names should use lowercase letters, numbers, and hyphens only:
|
|
102
|
+
- ✅ `series-x.svg`
|
|
103
|
+
- ✅ `youtube-intro.svg`
|
|
104
|
+
- ✅ `podcast-2024.svg`
|
|
105
|
+
- ❌ `Series X.svg`
|
|
106
|
+
- ❌ `MyTemplate.svg`
|
|
107
|
+
|
|
108
|
+
### Creating a Template
|
|
109
|
+
|
|
110
|
+
Create an SVG file with a `{{text}}` placeholder where you want the text to appear:
|
|
111
|
+
|
|
112
|
+
```xml
|
|
113
|
+
<svg width="1920" height="1080" viewBox="0 0 1920 1080" xmlns="http://www.w3.org/2000/svg">
|
|
114
|
+
<!-- Semi-transparent overlay -->
|
|
115
|
+
<rect width="1920" height="1080" fill="rgba(0, 0, 0, 0.5)" />
|
|
116
|
+
|
|
117
|
+
<!-- Text placeholder -->
|
|
118
|
+
<text x="960" y="540" font-family="Arial, Helvetica, sans-serif"
|
|
119
|
+
font-size="80" font-weight="bold" fill="#ffffff"
|
|
120
|
+
text-anchor="middle" dominant-baseline="middle">
|
|
121
|
+
{{text}}
|
|
122
|
+
</text>
|
|
123
|
+
</svg>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The `{{text}}` placeholder will be replaced with the actual text you provide during thumbnail generation. The SVG should match the dimensions of your video frames (typically 1920x1080 for HD video).
|
|
127
|
+
|
|
128
|
+
### Managing Multiple Templates
|
|
129
|
+
|
|
130
|
+
You can have multiple templates for different purposes:
|
|
131
|
+
- `series-x.svg` - For your X video series
|
|
132
|
+
- `series-y.svg` - For your Y video series
|
|
133
|
+
- `youtube-intro.svg` - For YouTube introductions
|
|
134
|
+
- `podcast.svg` - For podcast episodes
|
|
135
|
+
|
|
136
|
+
Use the `add-template` command to easily add new templates, and during thumbnail generation, you'll be prompted to select which template to use.
|
|
137
|
+
|
|
138
|
+
## Output Files
|
|
139
|
+
|
|
140
|
+
For an input file `my-video.mp4`, the tool generates:
|
|
141
|
+
- `my-video.srt`: The generated subtitles.
|
|
142
|
+
- `my-video_thumbnail_first.png`: Thumbnail from the first frame.
|
|
143
|
+
- `my-video_thumbnail_25.png`: Thumbnail at 25% duration.
|
|
144
|
+
- `my-video_thumbnail_50.png`: Thumbnail at 50% duration.
|
|
145
|
+
- `my-video_thumbnail_75.png`: Thumbnail at 75% duration.
|
|
146
|
+
- `my-video_thumbnail_last.png`: Thumbnail from the last frame.
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
MIT
|