@editframe/api 0.7.0-beta.6 → 0.8.0-beta.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/dist/client.d.ts +8 -0
- package/dist/client.js +26 -7
- package/dist/index.d.ts +8 -0
- package/dist/index.js +11 -1
- package/dist/resources/caption-file.d.ts +20 -0
- package/dist/resources/caption-file.js +1 -2
- package/dist/resources/image-file.d.ts +29 -0
- package/dist/resources/image-file.js +1 -2
- package/dist/resources/isobmff-file.d.ts +20 -0
- package/dist/resources/isobmff-file.js +1 -2
- package/dist/resources/isobmff-track.d.ts +271 -0
- package/dist/resources/isobmff-track.js +1 -2
- package/dist/resources/renders.d.ts +35 -0
- package/dist/resources/renders.js +1 -2
- package/dist/resources/signed-url.d.ts +6 -0
- package/dist/resources/signed-url.js +20 -0
- package/dist/resources/unprocessed-file.d.ts +43 -0
- package/dist/resources/unprocessed-file.js +142 -0
- package/package.json +9 -10
- package/src/resources/caption-file.ts +2 -3
- package/src/resources/image-file.ts +2 -3
- package/src/resources/isobmff-file.ts +2 -3
- package/src/resources/isobmff-track.ts +2 -3
- package/src/resources/renders.ts +2 -3
- package/src/resources/signed-url.ts +27 -0
- package/src/resources/unprocessed-file.ts +192 -0
- package/dist/client.cjs +0 -28
- package/dist/index.cjs +0 -24
- package/dist/resources/caption-file.cjs +0 -57
- package/dist/resources/image-file.cjs +0 -53
- package/dist/resources/isobmff-file.cjs +0 -57
- package/dist/resources/isobmff-track.cjs +0 -72
- package/dist/resources/renders.cjs +0 -57
- package/dist/util/nodeStreamToWebStream.cjs +0 -21
- package/dist/util/nodeStreamToWebStream.js +0 -21
- package/src/util/nodeStreamToWebStream.ts +0 -20
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RequestInit } from 'node-fetch';
|
|
2
|
+
import * as jwt from "jsonwebtoken";
|
|
3
|
+
export declare class Client {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(token: string, efHost?: string);
|
|
6
|
+
authenticatedFetch: (path: string, init?: RequestInit) => Promise<import('node-fetch').Response>;
|
|
7
|
+
sign(payload: Record<string, unknown>, expiresIn?: Parameters<typeof jwt.sign>[2]["expiresIn"]): string;
|
|
8
|
+
}
|
package/dist/client.js
CHANGED
|
@@ -1,26 +1,45 @@
|
|
|
1
1
|
import debug from "debug";
|
|
2
|
+
import * as jwt from "jsonwebtoken";
|
|
3
|
+
import fetch from "node-fetch";
|
|
2
4
|
const log = debug("ef:api:client");
|
|
3
5
|
class Client {
|
|
4
|
-
constructor(token, efHost) {
|
|
5
|
-
this.token = token;
|
|
6
|
-
this.efHost = efHost;
|
|
6
|
+
constructor(token, efHost = "https://editframe.dev") {
|
|
7
7
|
this.authenticatedFetch = async (path, init = {}) => {
|
|
8
8
|
init.headers ||= {};
|
|
9
|
+
const url = new URL(path, this.#efHost);
|
|
9
10
|
log(
|
|
10
11
|
"Authenticated fetch",
|
|
11
|
-
{
|
|
12
|
+
{ url, init },
|
|
12
13
|
"(Token will be added as Bearer token)"
|
|
13
14
|
);
|
|
14
15
|
Object.assign(init.headers, {
|
|
15
|
-
Authorization: `Bearer ${this
|
|
16
|
+
Authorization: `Bearer ${this.#token}`,
|
|
16
17
|
"Content-Type": "application/json"
|
|
17
18
|
});
|
|
18
|
-
const url = new URL(path, this.efHost);
|
|
19
19
|
const response = await fetch(url, init);
|
|
20
20
|
log("Authenticated fetch response", response.status, response.statusText);
|
|
21
21
|
return response;
|
|
22
22
|
};
|
|
23
|
-
log("Creating client with efHost", efHost,
|
|
23
|
+
log("Creating client with efHost", { efHost, tokenIsSet: !!token });
|
|
24
|
+
this.#token = token;
|
|
25
|
+
this.#efHost = efHost;
|
|
26
|
+
const { apiKey, apiSecret } = token.match(/^(?<apiSecret>ef_[^_]+)_(?<apiKey>.+)$/)?.groups ?? {};
|
|
27
|
+
if (!apiKey || !apiSecret) {
|
|
28
|
+
throw new Error("Invalid token format");
|
|
29
|
+
}
|
|
30
|
+
this.#apiKey = apiKey;
|
|
31
|
+
this.#apiSecret = apiSecret;
|
|
32
|
+
}
|
|
33
|
+
#apiKey;
|
|
34
|
+
#apiSecret;
|
|
35
|
+
#token;
|
|
36
|
+
#efHost;
|
|
37
|
+
sign(payload, expiresIn = 60) {
|
|
38
|
+
payload.cid = this.#apiKey;
|
|
39
|
+
return jwt.sign(payload, this.#apiSecret, {
|
|
40
|
+
algorithm: "HS256",
|
|
41
|
+
expiresIn
|
|
42
|
+
});
|
|
24
43
|
}
|
|
25
44
|
}
|
|
26
45
|
export {
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createCaptionFile, CreateCaptionFilePayload, type CreateCaptionFileResult, uploadCaptionFile, } from './resources/caption-file.ts';
|
|
2
|
+
export { createImageFile, CreateImageFilePayload, type CreateImageFileResult, uploadImageFile, } from './resources/image-file.ts';
|
|
3
|
+
export { createISOBMFFFile, CreateISOBMFFFilePayload, type CreateISOBMFFFileResult, uploadFragmentIndex, } from './resources/isobmff-file.ts';
|
|
4
|
+
export { createISOBMFFTrack, CreateISOBMFFTrackPayload, type CreateISOBMFFTrackResult, uploadISOBMFFTrack, } from './resources/isobmff-track.ts';
|
|
5
|
+
export { createRender, CreateRenderPayload, type CreateRenderResult, uploadRender, } from './resources/renders.ts';
|
|
6
|
+
export { createSignedURL, type SignedURLResult, } from './resources/signed-url.ts';
|
|
7
|
+
export { createUnprocessedFile, CreateUnprocessedFilePayload, type CreateUnprocessedFileResult, updateUnprocessedFile, UpdateUnprocessedFilePayload, type UpdateUnprocessedFileResult, uploadUnprocessedFile, processAVFile, processAVFileBuffer, } from './resources/unprocessed-file.ts';
|
|
8
|
+
export { Client } from './client.ts';
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,8 @@ import { CreateImageFilePayload, createImageFile, uploadImageFile } from "./reso
|
|
|
3
3
|
import { CreateISOBMFFFilePayload, createISOBMFFFile, uploadFragmentIndex } from "./resources/isobmff-file.js";
|
|
4
4
|
import { CreateISOBMFFTrackPayload, createISOBMFFTrack, uploadISOBMFFTrack } from "./resources/isobmff-track.js";
|
|
5
5
|
import { CreateRenderPayload, createRender, uploadRender } from "./resources/renders.js";
|
|
6
|
+
import { createSignedURL } from "./resources/signed-url.js";
|
|
7
|
+
import { CreateUnprocessedFilePayload, UpdateUnprocessedFilePayload, createUnprocessedFile, processAVFile, processAVFileBuffer, updateUnprocessedFile, uploadUnprocessedFile } from "./resources/unprocessed-file.js";
|
|
6
8
|
import { Client } from "./client.js";
|
|
7
9
|
export {
|
|
8
10
|
Client,
|
|
@@ -11,14 +13,22 @@ export {
|
|
|
11
13
|
CreateISOBMFFTrackPayload,
|
|
12
14
|
CreateImageFilePayload,
|
|
13
15
|
CreateRenderPayload,
|
|
16
|
+
CreateUnprocessedFilePayload,
|
|
17
|
+
UpdateUnprocessedFilePayload,
|
|
14
18
|
createCaptionFile,
|
|
15
19
|
createISOBMFFFile,
|
|
16
20
|
createISOBMFFTrack,
|
|
17
21
|
createImageFile,
|
|
18
22
|
createRender,
|
|
23
|
+
createSignedURL,
|
|
24
|
+
createUnprocessedFile,
|
|
25
|
+
processAVFile,
|
|
26
|
+
processAVFileBuffer,
|
|
27
|
+
updateUnprocessedFile,
|
|
19
28
|
uploadCaptionFile,
|
|
20
29
|
uploadFragmentIndex,
|
|
21
30
|
uploadISOBMFFTrack,
|
|
22
31
|
uploadImageFile,
|
|
23
|
-
uploadRender
|
|
32
|
+
uploadRender,
|
|
33
|
+
uploadUnprocessedFile
|
|
24
34
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Client } from '../client.ts';
|
|
4
|
+
|
|
5
|
+
export declare const CreateCaptionFilePayload: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
filename: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
id: string;
|
|
10
|
+
filename: string;
|
|
11
|
+
}, {
|
|
12
|
+
id: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
}>;
|
|
15
|
+
export interface CreateCaptionFileResult {
|
|
16
|
+
complete: boolean | null;
|
|
17
|
+
id: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const createCaptionFile: (client: Client, payload: z.infer<typeof CreateCaptionFilePayload>) => Promise<CreateCaptionFileResult | undefined>;
|
|
20
|
+
export declare const uploadCaptionFile: (client: Client, fileId: string, fileStream: Readable) => Promise<unknown>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import debug from "debug";
|
|
3
|
-
import { nodeStreamToWebStream } from "../util/nodeStreamToWebStream.js";
|
|
4
3
|
const log = debug("ef:api:caption-file");
|
|
5
4
|
const CreateCaptionFilePayload = z.object({
|
|
6
5
|
id: z.string(),
|
|
@@ -34,7 +33,7 @@ const uploadCaptionFile = async (client, fileId, fileStream) => {
|
|
|
34
33
|
`/api/video2/caption_files/${fileId}/upload`,
|
|
35
34
|
{
|
|
36
35
|
method: "POST",
|
|
37
|
-
body:
|
|
36
|
+
body: fileStream
|
|
38
37
|
}
|
|
39
38
|
);
|
|
40
39
|
log("Caption file uploaded", fileIndex);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Client } from '../client.ts';
|
|
4
|
+
|
|
5
|
+
export declare const CreateImageFilePayload: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
height: z.ZodNumber;
|
|
8
|
+
width: z.ZodNumber;
|
|
9
|
+
mime_type: z.ZodEnum<["image/jpeg", "image/png", "image/jpg", "image/webp"]>;
|
|
10
|
+
filename: z.ZodString;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
id: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
height: number;
|
|
15
|
+
width: number;
|
|
16
|
+
mime_type: "image/jpeg" | "image/png" | "image/jpg" | "image/webp";
|
|
17
|
+
}, {
|
|
18
|
+
id: string;
|
|
19
|
+
filename: string;
|
|
20
|
+
height: number;
|
|
21
|
+
width: number;
|
|
22
|
+
mime_type: "image/jpeg" | "image/png" | "image/jpg" | "image/webp";
|
|
23
|
+
}>;
|
|
24
|
+
export interface CreateImageFileResult {
|
|
25
|
+
complete: boolean | null;
|
|
26
|
+
id: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const createImageFile: (client: Client, payload: z.infer<typeof CreateImageFilePayload>) => Promise<CreateImageFileResult | undefined>;
|
|
29
|
+
export declare const uploadImageFile: (client: Client, fileId: string, fileStream: Readable) => Promise<unknown>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import debug from "debug";
|
|
3
|
-
import { nodeStreamToWebStream } from "../util/nodeStreamToWebStream.js";
|
|
4
3
|
const log = debug("ef:api:image-file");
|
|
5
4
|
const CreateImageFilePayload = z.object({
|
|
6
5
|
id: z.string(),
|
|
@@ -33,7 +32,7 @@ const uploadImageFile = async (client, fileId, fileStream) => {
|
|
|
33
32
|
`/api/video2/image_files/${fileId}/upload`,
|
|
34
33
|
{
|
|
35
34
|
method: "POST",
|
|
36
|
-
body:
|
|
35
|
+
body: fileStream
|
|
37
36
|
}
|
|
38
37
|
);
|
|
39
38
|
switch (fileIndex.status) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Client } from '../client.ts';
|
|
4
|
+
|
|
5
|
+
export declare const CreateISOBMFFFilePayload: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
filename: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
id: string;
|
|
10
|
+
filename: string;
|
|
11
|
+
}, {
|
|
12
|
+
id: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
}>;
|
|
15
|
+
export interface CreateISOBMFFFileResult {
|
|
16
|
+
fragment_index_complete: boolean;
|
|
17
|
+
id: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const createISOBMFFFile: (client: Client, payload: z.infer<typeof CreateISOBMFFFilePayload>) => Promise<CreateISOBMFFFileResult | undefined>;
|
|
20
|
+
export declare const uploadFragmentIndex: (client: Client, fileId: string, fileStream: Readable) => Promise<unknown>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import debug from "debug";
|
|
3
|
-
import { nodeStreamToWebStream } from "../util/nodeStreamToWebStream.js";
|
|
4
3
|
const log = debug("ef:api:isobmff-file");
|
|
5
4
|
const CreateISOBMFFFilePayload = z.object({
|
|
6
5
|
id: z.string(),
|
|
@@ -34,7 +33,7 @@ const uploadFragmentIndex = async (client, fileId, fileStream) => {
|
|
|
34
33
|
`/api/video2/isobmff_files/${fileId}/index/upload`,
|
|
35
34
|
{
|
|
36
35
|
method: "POST",
|
|
37
|
-
body:
|
|
36
|
+
body: fileStream
|
|
38
37
|
}
|
|
39
38
|
);
|
|
40
39
|
log("Fragment index uploaded", fileIndex);
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Client } from '../client.ts';
|
|
4
|
+
|
|
5
|
+
export declare const CreateISOBMFFTrackPayload: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
6
|
+
file_id: z.ZodString;
|
|
7
|
+
track_id: z.ZodNumber;
|
|
8
|
+
type: z.ZodLiteral<"audio">;
|
|
9
|
+
probe_info: z.ZodObject<{
|
|
10
|
+
index: z.ZodNumber;
|
|
11
|
+
codec_name: z.ZodString;
|
|
12
|
+
codec_long_name: z.ZodString;
|
|
13
|
+
codec_type: z.ZodLiteral<"audio">;
|
|
14
|
+
codec_tag_string: z.ZodString;
|
|
15
|
+
codec_tag: z.ZodString;
|
|
16
|
+
sample_fmt: z.ZodString;
|
|
17
|
+
sample_rate: z.ZodString;
|
|
18
|
+
channels: z.ZodNumber;
|
|
19
|
+
channel_layout: z.ZodString;
|
|
20
|
+
bits_per_sample: z.ZodNumber;
|
|
21
|
+
initial_padding: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
r_frame_rate: z.ZodString;
|
|
23
|
+
avg_frame_rate: z.ZodString;
|
|
24
|
+
time_base: z.ZodString;
|
|
25
|
+
start_pts: z.ZodNumber;
|
|
26
|
+
start_time: z.ZodNumber;
|
|
27
|
+
duration_ts: z.ZodNumber;
|
|
28
|
+
duration: z.ZodNumber;
|
|
29
|
+
bit_rate: z.ZodString;
|
|
30
|
+
disposition: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
duration: number;
|
|
33
|
+
index: number;
|
|
34
|
+
codec_name: string;
|
|
35
|
+
codec_long_name: string;
|
|
36
|
+
codec_type: "audio";
|
|
37
|
+
codec_tag_string: string;
|
|
38
|
+
codec_tag: string;
|
|
39
|
+
sample_fmt: string;
|
|
40
|
+
sample_rate: string;
|
|
41
|
+
channels: number;
|
|
42
|
+
channel_layout: string;
|
|
43
|
+
bits_per_sample: number;
|
|
44
|
+
r_frame_rate: string;
|
|
45
|
+
avg_frame_rate: string;
|
|
46
|
+
time_base: string;
|
|
47
|
+
start_pts: number;
|
|
48
|
+
start_time: number;
|
|
49
|
+
duration_ts: number;
|
|
50
|
+
bit_rate: string;
|
|
51
|
+
disposition: Record<string, unknown>;
|
|
52
|
+
initial_padding?: number | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
duration: number;
|
|
55
|
+
index: number;
|
|
56
|
+
codec_name: string;
|
|
57
|
+
codec_long_name: string;
|
|
58
|
+
codec_type: "audio";
|
|
59
|
+
codec_tag_string: string;
|
|
60
|
+
codec_tag: string;
|
|
61
|
+
sample_fmt: string;
|
|
62
|
+
sample_rate: string;
|
|
63
|
+
channels: number;
|
|
64
|
+
channel_layout: string;
|
|
65
|
+
bits_per_sample: number;
|
|
66
|
+
r_frame_rate: string;
|
|
67
|
+
avg_frame_rate: string;
|
|
68
|
+
time_base: string;
|
|
69
|
+
start_pts: number;
|
|
70
|
+
start_time: number;
|
|
71
|
+
duration_ts: number;
|
|
72
|
+
bit_rate: string;
|
|
73
|
+
disposition: Record<string, unknown>;
|
|
74
|
+
initial_padding?: number | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
duration_ms: z.ZodNumber;
|
|
77
|
+
codec_name: z.ZodString;
|
|
78
|
+
byte_size: z.ZodNumber;
|
|
79
|
+
}, "strip", z.ZodTypeAny, {
|
|
80
|
+
type: "audio";
|
|
81
|
+
file_id: string;
|
|
82
|
+
track_id: number;
|
|
83
|
+
probe_info: {
|
|
84
|
+
duration: number;
|
|
85
|
+
index: number;
|
|
86
|
+
codec_name: string;
|
|
87
|
+
codec_long_name: string;
|
|
88
|
+
codec_type: "audio";
|
|
89
|
+
codec_tag_string: string;
|
|
90
|
+
codec_tag: string;
|
|
91
|
+
sample_fmt: string;
|
|
92
|
+
sample_rate: string;
|
|
93
|
+
channels: number;
|
|
94
|
+
channel_layout: string;
|
|
95
|
+
bits_per_sample: number;
|
|
96
|
+
r_frame_rate: string;
|
|
97
|
+
avg_frame_rate: string;
|
|
98
|
+
time_base: string;
|
|
99
|
+
start_pts: number;
|
|
100
|
+
start_time: number;
|
|
101
|
+
duration_ts: number;
|
|
102
|
+
bit_rate: string;
|
|
103
|
+
disposition: Record<string, unknown>;
|
|
104
|
+
initial_padding?: number | undefined;
|
|
105
|
+
};
|
|
106
|
+
duration_ms: number;
|
|
107
|
+
codec_name: string;
|
|
108
|
+
byte_size: number;
|
|
109
|
+
}, {
|
|
110
|
+
type: "audio";
|
|
111
|
+
file_id: string;
|
|
112
|
+
track_id: number;
|
|
113
|
+
probe_info: {
|
|
114
|
+
duration: number;
|
|
115
|
+
index: number;
|
|
116
|
+
codec_name: string;
|
|
117
|
+
codec_long_name: string;
|
|
118
|
+
codec_type: "audio";
|
|
119
|
+
codec_tag_string: string;
|
|
120
|
+
codec_tag: string;
|
|
121
|
+
sample_fmt: string;
|
|
122
|
+
sample_rate: string;
|
|
123
|
+
channels: number;
|
|
124
|
+
channel_layout: string;
|
|
125
|
+
bits_per_sample: number;
|
|
126
|
+
r_frame_rate: string;
|
|
127
|
+
avg_frame_rate: string;
|
|
128
|
+
time_base: string;
|
|
129
|
+
start_pts: number;
|
|
130
|
+
start_time: number;
|
|
131
|
+
duration_ts: number;
|
|
132
|
+
bit_rate: string;
|
|
133
|
+
disposition: Record<string, unknown>;
|
|
134
|
+
initial_padding?: number | undefined;
|
|
135
|
+
};
|
|
136
|
+
duration_ms: number;
|
|
137
|
+
codec_name: string;
|
|
138
|
+
byte_size: number;
|
|
139
|
+
}>, z.ZodObject<{
|
|
140
|
+
file_id: z.ZodString;
|
|
141
|
+
track_id: z.ZodNumber;
|
|
142
|
+
type: z.ZodLiteral<"video">;
|
|
143
|
+
probe_info: z.ZodObject<{
|
|
144
|
+
index: z.ZodNumber;
|
|
145
|
+
codec_name: z.ZodString;
|
|
146
|
+
codec_long_name: z.ZodString;
|
|
147
|
+
codec_type: z.ZodLiteral<"video">;
|
|
148
|
+
codec_tag_string: z.ZodString;
|
|
149
|
+
codec_tag: z.ZodString;
|
|
150
|
+
width: z.ZodNumber;
|
|
151
|
+
height: z.ZodNumber;
|
|
152
|
+
coded_width: z.ZodNumber;
|
|
153
|
+
coded_height: z.ZodNumber;
|
|
154
|
+
r_frame_rate: z.ZodString;
|
|
155
|
+
avg_frame_rate: z.ZodString;
|
|
156
|
+
time_base: z.ZodString;
|
|
157
|
+
start_pts: z.ZodOptional<z.ZodNumber>;
|
|
158
|
+
start_time: z.ZodOptional<z.ZodNumber>;
|
|
159
|
+
duration_ts: z.ZodOptional<z.ZodNumber>;
|
|
160
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
bit_rate: z.ZodOptional<z.ZodString>;
|
|
162
|
+
disposition: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
163
|
+
}, "strip", z.ZodTypeAny, {
|
|
164
|
+
index: number;
|
|
165
|
+
codec_name: string;
|
|
166
|
+
codec_long_name: string;
|
|
167
|
+
codec_type: "video";
|
|
168
|
+
codec_tag_string: string;
|
|
169
|
+
codec_tag: string;
|
|
170
|
+
r_frame_rate: string;
|
|
171
|
+
avg_frame_rate: string;
|
|
172
|
+
time_base: string;
|
|
173
|
+
disposition: Record<string, unknown>;
|
|
174
|
+
width: number;
|
|
175
|
+
height: number;
|
|
176
|
+
coded_width: number;
|
|
177
|
+
coded_height: number;
|
|
178
|
+
duration?: number | undefined;
|
|
179
|
+
start_pts?: number | undefined;
|
|
180
|
+
start_time?: number | undefined;
|
|
181
|
+
duration_ts?: number | undefined;
|
|
182
|
+
bit_rate?: string | undefined;
|
|
183
|
+
}, {
|
|
184
|
+
index: number;
|
|
185
|
+
codec_name: string;
|
|
186
|
+
codec_long_name: string;
|
|
187
|
+
codec_type: "video";
|
|
188
|
+
codec_tag_string: string;
|
|
189
|
+
codec_tag: string;
|
|
190
|
+
r_frame_rate: string;
|
|
191
|
+
avg_frame_rate: string;
|
|
192
|
+
time_base: string;
|
|
193
|
+
disposition: Record<string, unknown>;
|
|
194
|
+
width: number;
|
|
195
|
+
height: number;
|
|
196
|
+
coded_width: number;
|
|
197
|
+
coded_height: number;
|
|
198
|
+
duration?: number | undefined;
|
|
199
|
+
start_pts?: number | undefined;
|
|
200
|
+
start_time?: number | undefined;
|
|
201
|
+
duration_ts?: number | undefined;
|
|
202
|
+
bit_rate?: string | undefined;
|
|
203
|
+
}>;
|
|
204
|
+
duration_ms: z.ZodNumber;
|
|
205
|
+
codec_name: z.ZodString;
|
|
206
|
+
byte_size: z.ZodNumber;
|
|
207
|
+
}, "strip", z.ZodTypeAny, {
|
|
208
|
+
type: "video";
|
|
209
|
+
file_id: string;
|
|
210
|
+
track_id: number;
|
|
211
|
+
probe_info: {
|
|
212
|
+
index: number;
|
|
213
|
+
codec_name: string;
|
|
214
|
+
codec_long_name: string;
|
|
215
|
+
codec_type: "video";
|
|
216
|
+
codec_tag_string: string;
|
|
217
|
+
codec_tag: string;
|
|
218
|
+
r_frame_rate: string;
|
|
219
|
+
avg_frame_rate: string;
|
|
220
|
+
time_base: string;
|
|
221
|
+
disposition: Record<string, unknown>;
|
|
222
|
+
width: number;
|
|
223
|
+
height: number;
|
|
224
|
+
coded_width: number;
|
|
225
|
+
coded_height: number;
|
|
226
|
+
duration?: number | undefined;
|
|
227
|
+
start_pts?: number | undefined;
|
|
228
|
+
start_time?: number | undefined;
|
|
229
|
+
duration_ts?: number | undefined;
|
|
230
|
+
bit_rate?: string | undefined;
|
|
231
|
+
};
|
|
232
|
+
duration_ms: number;
|
|
233
|
+
codec_name: string;
|
|
234
|
+
byte_size: number;
|
|
235
|
+
}, {
|
|
236
|
+
type: "video";
|
|
237
|
+
file_id: string;
|
|
238
|
+
track_id: number;
|
|
239
|
+
probe_info: {
|
|
240
|
+
index: number;
|
|
241
|
+
codec_name: string;
|
|
242
|
+
codec_long_name: string;
|
|
243
|
+
codec_type: "video";
|
|
244
|
+
codec_tag_string: string;
|
|
245
|
+
codec_tag: string;
|
|
246
|
+
r_frame_rate: string;
|
|
247
|
+
avg_frame_rate: string;
|
|
248
|
+
time_base: string;
|
|
249
|
+
disposition: Record<string, unknown>;
|
|
250
|
+
width: number;
|
|
251
|
+
height: number;
|
|
252
|
+
coded_width: number;
|
|
253
|
+
coded_height: number;
|
|
254
|
+
duration?: number | undefined;
|
|
255
|
+
start_pts?: number | undefined;
|
|
256
|
+
start_time?: number | undefined;
|
|
257
|
+
duration_ts?: number | undefined;
|
|
258
|
+
bit_rate?: string | undefined;
|
|
259
|
+
};
|
|
260
|
+
duration_ms: number;
|
|
261
|
+
codec_name: string;
|
|
262
|
+
byte_size: number;
|
|
263
|
+
}>]>;
|
|
264
|
+
export interface CreateISOBMFFTrackResult {
|
|
265
|
+
last_received_byte: number;
|
|
266
|
+
byte_size: number;
|
|
267
|
+
track_id: number;
|
|
268
|
+
file_id: string;
|
|
269
|
+
}
|
|
270
|
+
export declare const createISOBMFFTrack: (client: Client, payload: z.infer<typeof CreateISOBMFFTrackPayload>) => Promise<CreateISOBMFFTrackResult | undefined>;
|
|
271
|
+
export declare const uploadISOBMFFTrack: (client: Client, fileId: string, trackId: number, fileStream: Readable) => Promise<unknown>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import debug from "debug";
|
|
3
3
|
import { AudioStreamSchema, VideoStreamSchema } from "@editframe/assets";
|
|
4
|
-
import { nodeStreamToWebStream } from "../util/nodeStreamToWebStream.js";
|
|
5
4
|
const log = debug("ef:api:isobmff-track");
|
|
6
5
|
const CreateISOBMFFTrackPayload = z.discriminatedUnion("type", [
|
|
7
6
|
z.object({
|
|
@@ -50,7 +49,7 @@ const uploadISOBMFFTrack = async (client, fileId, trackId, fileStream) => {
|
|
|
50
49
|
`/api/video2/isobmff_tracks/${fileId}/${trackId}/upload`,
|
|
51
50
|
{
|
|
52
51
|
method: "POST",
|
|
53
|
-
body:
|
|
52
|
+
body: fileStream
|
|
54
53
|
}
|
|
55
54
|
);
|
|
56
55
|
log("ISOBMFF track uploaded", trackIndex);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Client } from '../client.ts';
|
|
4
|
+
|
|
5
|
+
export declare const CreateRenderPayload: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
fps: z.ZodNumber;
|
|
8
|
+
width: z.ZodNumber;
|
|
9
|
+
height: z.ZodNumber;
|
|
10
|
+
work_slice_ms: z.ZodNumber;
|
|
11
|
+
duration_ms: z.ZodNumber;
|
|
12
|
+
strategy: z.ZodEnum<["v1", "v2"]>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
id: string;
|
|
15
|
+
height: number;
|
|
16
|
+
width: number;
|
|
17
|
+
duration_ms: number;
|
|
18
|
+
fps: number;
|
|
19
|
+
work_slice_ms: number;
|
|
20
|
+
strategy: "v1" | "v2";
|
|
21
|
+
}, {
|
|
22
|
+
id: string;
|
|
23
|
+
height: number;
|
|
24
|
+
width: number;
|
|
25
|
+
duration_ms: number;
|
|
26
|
+
fps: number;
|
|
27
|
+
work_slice_ms: number;
|
|
28
|
+
strategy: "v1" | "v2";
|
|
29
|
+
}>;
|
|
30
|
+
export interface CreateRenderResult {
|
|
31
|
+
status: "complete" | "created" | "failed" | "pending" | "rendering";
|
|
32
|
+
id: string;
|
|
33
|
+
}
|
|
34
|
+
export declare const createRender: (client: Client, payload: z.infer<typeof CreateRenderPayload>) => Promise<CreateRenderResult | undefined>;
|
|
35
|
+
export declare const uploadRender: (client: Client, fileId: string, fileStream: Readable) => Promise<unknown>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import debug from "debug";
|
|
3
|
-
import { nodeStreamToWebStream } from "../util/nodeStreamToWebStream.js";
|
|
4
3
|
const log = debug("ef:api:renders");
|
|
5
4
|
const CreateRenderPayload = z.object({
|
|
6
5
|
id: z.string().uuid(),
|
|
@@ -35,7 +34,7 @@ const uploadRender = async (client, fileId, fileStream) => {
|
|
|
35
34
|
`/api/video2/renders/${fileId}/upload`,
|
|
36
35
|
{
|
|
37
36
|
method: "POST",
|
|
38
|
-
body:
|
|
37
|
+
body: fileStream
|
|
39
38
|
}
|
|
40
39
|
);
|
|
41
40
|
log("Render uploaded", fileIndex);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import debug from "debug";
|
|
2
|
+
const log = debug("ef:api:signed-url");
|
|
3
|
+
const createSignedURL = async (client, url) => {
|
|
4
|
+
log("Creating signed url for", url);
|
|
5
|
+
const response = await client.authenticatedFetch("/api/v1/signed-url", {
|
|
6
|
+
method: "POST",
|
|
7
|
+
body: JSON.stringify({
|
|
8
|
+
url
|
|
9
|
+
})
|
|
10
|
+
});
|
|
11
|
+
if (!response.ok) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`Failed to create signed url: ${response.status} ${response.statusText} ${await response.text()}`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return (await response.json()).url;
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
createSignedURL
|
|
20
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Client } from '../client.ts';
|
|
4
|
+
|
|
5
|
+
declare const FileProcessors: z.ZodEffects<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"isobmff">, z.ZodLiteral<"captions">]>, "many">, ("isobmff" | "captions")[], ("isobmff" | "captions")[]>;
|
|
6
|
+
export declare const CreateUnprocessedFilePayload: z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
filename: z.ZodString;
|
|
9
|
+
processes: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"isobmff">, z.ZodLiteral<"captions">]>, "many">, ("isobmff" | "captions")[], ("isobmff" | "captions")[]>>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
id: string;
|
|
12
|
+
filename: string;
|
|
13
|
+
processes?: ("isobmff" | "captions")[] | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
id: string;
|
|
16
|
+
filename: string;
|
|
17
|
+
processes?: ("isobmff" | "captions")[] | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const UpdateUnprocessedFilePayload: z.ZodObject<{
|
|
20
|
+
processes: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"isobmff">, z.ZodLiteral<"captions">]>, "many">, ("isobmff" | "captions")[], ("isobmff" | "captions")[]>>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
processes?: ("isobmff" | "captions")[] | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
processes?: ("isobmff" | "captions")[] | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
export interface CreateUnprocessedFileResult {
|
|
27
|
+
byte_size: number;
|
|
28
|
+
last_received_byte: number;
|
|
29
|
+
id: string;
|
|
30
|
+
processes: z.infer<typeof FileProcessors>;
|
|
31
|
+
}
|
|
32
|
+
export interface UpdateUnprocessedFileResult {
|
|
33
|
+
byte_size: number;
|
|
34
|
+
last_received_byte: number;
|
|
35
|
+
id: string;
|
|
36
|
+
processes: z.infer<typeof FileProcessors>;
|
|
37
|
+
}
|
|
38
|
+
export declare const createUnprocessedFile: (client: Client, payload: z.infer<typeof CreateUnprocessedFilePayload>) => Promise<CreateUnprocessedFileResult>;
|
|
39
|
+
export declare const updateUnprocessedFile: (client: Client, fileId: string, payload: Partial<z.infer<typeof UpdateUnprocessedFilePayload>>) => Promise<UpdateUnprocessedFileResult>;
|
|
40
|
+
export declare const uploadUnprocessedFile: (client: Client, fileId: string, fileStream: Readable) => Promise<unknown>;
|
|
41
|
+
export declare const processAVFileBuffer: (client: Client, buffer: Buffer, filename?: string) => Promise<UpdateUnprocessedFileResult>;
|
|
42
|
+
export declare const processAVFile: (client: Client, filePath: string) => Promise<UpdateUnprocessedFileResult>;
|
|
43
|
+
export {};
|