@verygoodffmpeg/sdk 0.1.0 → 1.0.1
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/README.md +136 -0
- package/package.json +9 -1
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# @verygoodffmpeg/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the Very Good FFmpeg API — run FFmpeg jobs in the cloud.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@verygoodffmpeg/sdk)
|
|
6
|
+
|
|
7
|
+
[Homepage](https://verygoodffmpeg.com) · [API Docs](https://verygoodffmpeg.com/docs) · [GitHub](https://github.com/verygoodffmpeg/Very-Good-FFmpeg-Typescript-SDK)
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm install @verygoodffmpeg/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import VGF from "@verygoodffmpeg/sdk";
|
|
17
|
+
|
|
18
|
+
const client = new VGF(process.env.VGF_API_KEY);
|
|
19
|
+
|
|
20
|
+
// Create a job and wait for it to complete
|
|
21
|
+
const job = await client.run(
|
|
22
|
+
{
|
|
23
|
+
input_files: {
|
|
24
|
+
"input.mp4": "https://example.com/input.mp4",
|
|
25
|
+
},
|
|
26
|
+
output_files: ["output.mp4"],
|
|
27
|
+
ffmpeg_commands: ["-i input.mp4 -vf scale=1280:720 output.mp4"],
|
|
28
|
+
},
|
|
29
|
+
{ wait: true },
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// Fetch the job again by ID
|
|
33
|
+
const fetched = await client.jobs.get(job.id);
|
|
34
|
+
console.log(fetched.status); // "succeeded"
|
|
35
|
+
console.log(fetched.output_files); // { "output.mp4": "https://..." }
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Reference
|
|
39
|
+
|
|
40
|
+
### Create a job — `client.run(params, options?)`
|
|
41
|
+
|
|
42
|
+
Submits an FFmpeg job. Pass `{ wait: true }` to block until the job reaches a terminal state.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
const job = await client.run(
|
|
46
|
+
{
|
|
47
|
+
input_files: { "input.mp4": "https://example.com/input.mp4" },
|
|
48
|
+
output_files: ["output.mp4"],
|
|
49
|
+
ffmpeg_commands: ["-i input.mp4 -c:v libx264 output.mp4"],
|
|
50
|
+
webhook_url: "https://example.com/webhook", // optional
|
|
51
|
+
machine: "nvidia", // optional: "cpu" | "nvidia"
|
|
52
|
+
},
|
|
53
|
+
{ wait: true }, // optional
|
|
54
|
+
);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Get a job — `client.jobs.get(id)`
|
|
58
|
+
|
|
59
|
+
Fetches a single job by ID.
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
const job = await client.jobs.get("job_abc123");
|
|
63
|
+
console.log(job.status); // "queued" | "running" | "succeeded" | "failed" | "cancelled"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### List jobs — `client.jobs.list(params?)`
|
|
67
|
+
|
|
68
|
+
Returns a paginated list of jobs.
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const { data, pagingParams } = await client.jobs.list({ limit: 20, offset: 0 });
|
|
72
|
+
console.log(data); // Job[]
|
|
73
|
+
console.log(pagingParams); // { limit, offset, total, hasMore }
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Cancel a job — `client.jobs.cancel(id)`
|
|
77
|
+
|
|
78
|
+
Cancels a queued or running job.
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
const job = await client.jobs.cancel("job_abc123");
|
|
82
|
+
console.log(job.status); // "cancelled"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Upload a file — `client.files.upload(data, contentType?)`
|
|
86
|
+
|
|
87
|
+
Uploads a file to temporary storage and returns a URL you can use as an `input_files` value.
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { readFileSync } from "fs";
|
|
91
|
+
|
|
92
|
+
const url = await client.files.upload(readFileSync("input.mp4"), "video/mp4");
|
|
93
|
+
|
|
94
|
+
const job = await client.run({
|
|
95
|
+
input_files: { "input.mp4": url },
|
|
96
|
+
output_files: ["output.mp4"],
|
|
97
|
+
ffmpeg_commands: ["-i input.mp4 -vf scale=1280:720 output.mp4"],
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Prepare upload — `client.files.prepareUpload()`
|
|
102
|
+
|
|
103
|
+
Returns a presigned `upload_url` and `download_url` directly, useful when you need to stream a large file yourself rather than buffering it in memory.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { createReadStream, statSync } from "fs";
|
|
107
|
+
|
|
108
|
+
const { upload_url, download_url } = await client.files.prepareUpload();
|
|
109
|
+
|
|
110
|
+
await fetch(upload_url, {
|
|
111
|
+
method: "PUT",
|
|
112
|
+
headers: {
|
|
113
|
+
"Content-Type": "video/mp4",
|
|
114
|
+
"Content-Length": String(statSync("large.mp4").size),
|
|
115
|
+
},
|
|
116
|
+
body: createReadStream("large.mp4"),
|
|
117
|
+
duplex: "half",
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const job = await client.run({
|
|
121
|
+
input_files: { "input.mp4": download_url },
|
|
122
|
+
output_files: ["output.mp4"],
|
|
123
|
+
ffmpeg_commands: ["-i input.mp4 -vf scale=1280:720 output.mp4"],
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Complete examples
|
|
128
|
+
|
|
129
|
+
See the [`examples/`](./examples) folder for minimal runnable examples:
|
|
130
|
+
|
|
131
|
+
- [`examples/node-cjs`](./examples/node-cjs) — Node.js CommonJS
|
|
132
|
+
- [`examples/ts-esm`](./examples/ts-esm) — TypeScript ESM
|
|
133
|
+
|
|
134
|
+
## Support
|
|
135
|
+
|
|
136
|
+
Open an issue at [github.com/verygoodffmpeg/Very-Good-FFmpeg-Typescript-SDK](https://github.com/verygoodffmpeg/Very-Good-FFmpeg-Typescript-SDK) or email [please_help@verygoodffmpeg.com](mailto:please_help@verygoodffmpeg.com).
|
package/package.json
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verygoodffmpeg/sdk",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "TypeScript SDK for the Very Good FFmpeg API",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/verygoodffmpeg/Very-Good-FFmpeg-Typescript-SDK.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/verygoodffmpeg/Very-Good-FFmpeg-Typescript-SDK#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/verygoodffmpeg/Very-Good-FFmpeg-Typescript-SDK/issues"
|
|
12
|
+
},
|
|
5
13
|
"type": "module",
|
|
6
14
|
"main": "./dist/index.cjs",
|
|
7
15
|
"module": "./dist/index.js",
|