@osaas/client-transcode 0.2.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Eyevinn Technology Open Source Software Center
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,49 @@
1
+ # @osaas/client-transcode
2
+
3
+ SDK for transcoding with Encore in Open Source Cloud and transfer result to S3 bucket
4
+
5
+ ## Usage
6
+
7
+ Prerequisites
8
+
9
+ - An account on [Open Source Cloud](www.osaas.io)
10
+
11
+ ```
12
+ npm install --save @osaas/client-transcode
13
+ ```
14
+
15
+ Example code
16
+
17
+ ```javascript
18
+ import { Context, Log } from '@osaas/client-core';
19
+ import { QueuePool } from '@osaas/client-transcode';
20
+
21
+ async function main() {
22
+ const ctx = new Context();
23
+
24
+ try {
25
+ const pool = new QueuePool({ context: ctx });
26
+ await pool.init();
27
+ await pool.transcode(
28
+ new URL(
29
+ 'https://testcontent.eyevinn.technology/mp4/stswe-tvplus-promo.mp4'
30
+ ),
31
+ new URL('s3://lab-testcontent-store/birme/'),
32
+ {}
33
+ );
34
+ await pool.destroy();
35
+ } catch (err) {
36
+ Log().error(err);
37
+ }
38
+ }
39
+
40
+ main();
41
+ ```
42
+
43
+ ## About Open Source Cloud
44
+
45
+ Open Source Cloud reduces the barrier to get started with open source without having to host it on your own infrastructure.
46
+
47
+ Start building software solutions based on open and detachable ready-to-run cloud components with Open Source Cloud. Full code transparency, never locked in and a business model that contributes back to the open source community. Offering a wide range of components from media and more to help you build the best solution for you and your users.
48
+
49
+ www.osaas.io
@@ -0,0 +1,11 @@
1
+ export type FileOutput = {
2
+ file: string;
3
+ fileSize: number;
4
+ format: string;
5
+ overallBitrate: number;
6
+ duration: number;
7
+ videoStreams: any[];
8
+ audioStreams: any[];
9
+ type: string;
10
+ };
11
+ //# sourceMappingURL=encore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encore.d.ts","sourceRoot":"","sources":["../src/encore.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,GAAG,EAAE,CAAC;IACpB,YAAY,EAAE,GAAG,EAAE,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
package/lib/encore.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=encore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encore.js","sourceRoot":"","sources":["../src/encore.ts"],"names":[],"mappings":""}
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { QueuePool } from './pool';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueuePool = void 0;
4
+ var pool_1 = require("./pool");
5
+ Object.defineProperty(exports, "QueuePool", { enumerable: true, get: function () { return pool_1.QueuePool; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AAA1B,iGAAA,SAAS,OAAA"}
package/lib/pool.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ /// <reference types="node" />
2
+ import { Context } from '@osaas/client-core';
3
+ /**
4
+ * Represents a pool of Encore queues (instances) in Open Source Cloud
5
+ */
6
+ export declare class QueuePool {
7
+ private context;
8
+ private token?;
9
+ private instances;
10
+ private queueSize;
11
+ /**
12
+ * @typedef QueuePoolOptions
13
+ * @type object
14
+ * @property {Context} context - Open Source Cloud configuration context
15
+ * @property {number} size - Number of queues in the pool
16
+ */
17
+ /**
18
+ * Creates a new Queue Pool
19
+ * @constructor
20
+ * @param {QueuePoolOptions} options - Queue Pool options
21
+ * @example
22
+ * import { Context } from '@osaas/client-core';
23
+ * const ctx = new Context();
24
+ * // Create a new pool with 2 queues
25
+ * const pool = new QueuePool({ context: ctx, size: 2 });
26
+ * await pool.init();
27
+ */
28
+ constructor({ context, size }: {
29
+ context: Context;
30
+ size?: number;
31
+ });
32
+ /**
33
+ * Initializes the pool by creating the queues
34
+ * @async
35
+ * @example
36
+ * await pool.init();
37
+ */
38
+ init(): Promise<void>;
39
+ /**
40
+ * Destroys the pool by removing the queues
41
+ * @async
42
+ * @example
43
+ * await pool.destroy();
44
+ */
45
+ destroy(): Promise<void>;
46
+ transcode(source: URL, destination: URL, { profile, duration }: {
47
+ profile?: string;
48
+ duration?: number;
49
+ }): Promise<void>;
50
+ }
51
+ //# sourceMappingURL=pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,OAAO,EAMR,MAAM,oBAAoB,CAAC;AAK5B;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAAC,CAAS;IACvB,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,SAAS,CAAS;IAE1B;;;;;OAKG;IAEH;;;;;;;;;;OAUG;gBACS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;IAMlE;;;;;OAKG;IACU,IAAI;IAmCjB;;;;;OAKG;IACU,OAAO;IASP,SAAS,CACpB,MAAM,EAAE,GAAG,EACX,WAAW,EAAE,GAAG,EAChB,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;CA0DjE"}
package/lib/pool.js ADDED
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.QueuePool = void 0;
7
+ const client_core_1 = require("@osaas/client-core");
8
+ const util_1 = require("./util");
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ /**
11
+ * Represents a pool of Encore queues (instances) in Open Source Cloud
12
+ */
13
+ class QueuePool {
14
+ context;
15
+ token;
16
+ instances;
17
+ queueSize;
18
+ /**
19
+ * @typedef QueuePoolOptions
20
+ * @type object
21
+ * @property {Context} context - Open Source Cloud configuration context
22
+ * @property {number} size - Number of queues in the pool
23
+ */
24
+ /**
25
+ * Creates a new Queue Pool
26
+ * @constructor
27
+ * @param {QueuePoolOptions} options - Queue Pool options
28
+ * @example
29
+ * import { Context } from '@osaas/client-core';
30
+ * const ctx = new Context();
31
+ * // Create a new pool with 2 queues
32
+ * const pool = new QueuePool({ context: ctx, size: 2 });
33
+ * await pool.init();
34
+ */
35
+ constructor({ context, size }) {
36
+ this.context = context;
37
+ this.instances = [];
38
+ this.queueSize = size || 1;
39
+ }
40
+ /**
41
+ * Initializes the pool by creating the queues
42
+ * @async
43
+ * @example
44
+ * await pool.init();
45
+ */
46
+ async init() {
47
+ this.token = await this.context.getServiceAccessToken('encore');
48
+ if (this.instances.length > 0) {
49
+ throw new Error('Pool already initialized');
50
+ }
51
+ const names = [];
52
+ for (let i = 0; i < this.queueSize; i++) {
53
+ names.push(`node${i + 1}`);
54
+ }
55
+ for (const name of names) {
56
+ const instance = await (0, client_core_1.getInstance)(this.context, 'encore', name, this.token);
57
+ if (!instance) {
58
+ (0, client_core_1.Log)().debug(`Creating pool instance ${name}`);
59
+ const instance = await (0, client_core_1.createInstance)(this.context, 'encore', this.token, {
60
+ name
61
+ });
62
+ await (0, util_1.delay)(5000);
63
+ this.instances.push(instance.name);
64
+ }
65
+ else {
66
+ this.instances.push(instance.name);
67
+ }
68
+ }
69
+ }
70
+ /**
71
+ * Destroys the pool by removing the queues
72
+ * @async
73
+ * @example
74
+ * await pool.destroy();
75
+ */
76
+ async destroy() {
77
+ if (!this.token) {
78
+ throw new Error('Pool not initialized');
79
+ }
80
+ for (const instance of this.instances) {
81
+ await (0, client_core_1.removeInstance)(this.context, 'encore', instance, this.token);
82
+ }
83
+ }
84
+ async transcode(source, destination, { profile, duration }) {
85
+ if (!this.token) {
86
+ throw new Error('Pool not initialized');
87
+ }
88
+ if (this.instances.length == 0) {
89
+ throw new Error('Pool not initialized');
90
+ }
91
+ const name = this.instances[Math.floor(Math.random() * this.instances.length)];
92
+ const instance = await (0, client_core_1.getInstance)(this.context, 'encore', name, this.token);
93
+ const jobId = Math.random().toString(36).substring(7);
94
+ const encoreJobUrl = new URL('/encoreJobs', instance.url);
95
+ const data = await (0, client_core_1.createFetch)(encoreJobUrl, {
96
+ method: 'POST',
97
+ body: JSON.stringify({
98
+ profile: profile || 'program',
99
+ outputFolder: `/usercontent/${jobId}`,
100
+ baseName: jobId,
101
+ duration: duration,
102
+ inputs: [
103
+ {
104
+ type: 'AudioVideo',
105
+ uri: source.toString()
106
+ }
107
+ ]
108
+ }),
109
+ headers: {
110
+ 'x-jwt': `Bearer ${this.token}`,
111
+ 'Content-Type': 'application/json'
112
+ }
113
+ });
114
+ const encoreJob = JSON.parse(data);
115
+ const job = await (0, util_1.waitForEncoreJobToComplete)(new URL(encoreJobUrl.toString() + '/' + encoreJob.id), this.token);
116
+ (0, client_core_1.Log)().debug(job);
117
+ const outputFiles = job.output.filter((file) => file.type === 'VideoFile' || file.type === 'AudioFile');
118
+ const transferPromises = outputFiles.map((file) => (0, util_1.transferFile)(this.context, node_path_1.default.basename(file.file), new URL(file.file, instance.url), destination, this.token || ''));
119
+ await Promise.all(transferPromises);
120
+ }
121
+ }
122
+ exports.QueuePool = QueuePool;
123
+ //# sourceMappingURL=pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool.js","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":";;;;;;AAAA,oDAO4B;AAC5B,iCAAyE;AAEzE,0DAA6B;AAE7B;;GAEG;AACH,MAAa,SAAS;IACZ,OAAO,CAAU;IACjB,KAAK,CAAU;IACf,SAAS,CAAW;IACpB,SAAS,CAAS;IAE1B;;;;;OAKG;IAEH;;;;;;;;;;OAUG;IACH,YAAY,EAAE,OAAO,EAAE,IAAI,EAAuC;QAChE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,C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@@
1
+ /// <reference types="node" />
2
+ import { Context } from '@osaas/client-core';
3
+ export declare const delay: (ms: number) => Promise<unknown>;
4
+ export declare function waitForEncoreJobToComplete(jobUrl: URL, token: string): Promise<any>;
5
+ export declare function transferFile(ctx: Context, name: string, source: URL, destination: URL, token: string): Promise<void>;
6
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,OAAO,EAKR,MAAM,oBAAoB,CAAC;AAI5B,eAAO,MAAM,KAAK,OAAQ,MAAM,qBAA8C,CAAC;AAE/E,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,gBAgB1E;AAED,wBAAsB,YAAY,CAChC,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,GAAG,EACX,WAAW,EAAE,GAAG,EAChB,KAAK,EAAE,MAAM,iBA2Bd"}
package/lib/util.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transferFile = exports.waitForEncoreJobToComplete = exports.delay = void 0;
4
+ const client_core_1 = require("@osaas/client-core");
5
+ const MAX_ITER = 1000;
6
+ const delay = (ms) => new Promise((res) => setTimeout(res, ms));
7
+ exports.delay = delay;
8
+ async function waitForEncoreJobToComplete(jobUrl, token) {
9
+ for (const _ of Array(MAX_ITER)) {
10
+ const data = await (0, client_core_1.createFetch)(jobUrl, {
11
+ method: 'GET',
12
+ headers: {
13
+ 'x-jwt': `Bearer ${token}`,
14
+ 'Content-Type': 'application/json'
15
+ }
16
+ });
17
+ const job = JSON.parse(data);
18
+ (0, client_core_1.Log)().debug(`Progress: ${job.progress}`);
19
+ if (job.status === 'SUCCESSFUL') {
20
+ return job;
21
+ }
22
+ await (0, exports.delay)(10000);
23
+ }
24
+ }
25
+ exports.waitForEncoreJobToComplete = waitForEncoreJobToComplete;
26
+ async function transferFile(ctx, name, source, destination, token) {
27
+ const serviceAccessToken = await ctx.getServiceAccessToken('eyevinn-docker-retransfer');
28
+ const job = await (0, client_core_1.createJob)(ctx, 'eyevinn-docker-retransfer', serviceAccessToken, {
29
+ name,
30
+ awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID,
31
+ awsSecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
32
+ cmdLineArgs: `--sat ${token} ${source.toString()} ${destination.toString()}`
33
+ });
34
+ (0, client_core_1.Log)().debug(`Transfer file ${source.toString()} to ${destination.toString()}`);
35
+ await (0, client_core_1.waitForJobToComplete)(ctx, 'eyevinn-docker-retransfer', job.name, serviceAccessToken);
36
+ (0, client_core_1.Log)().debug(`File transfer job ${job.name} completed`);
37
+ }
38
+ exports.transferFile = transferFile;
39
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAAA,oDAM4B;AAE5B,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEf,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;AAAlE,QAAA,KAAK,SAA6D;AAExE,KAAK,UAAU,0BAA0B,CAAC,MAAW,EAAE,KAAa;IACzE,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE;QAC/B,MAAM,IAAI,GAAG,MAAM,IAAA,yBAAW,EAAM,MAAM,EAAE;YAC1C,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU,KAAK,EAAE;gBAC1B,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAA,iBAAG,GAAE,CAAC,KAAK,CAAC,aAAa,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzC,IAAI,GAAG,CAAC,MAAM,KAAK,YAAY,EAAE;YAC/B,OAAO,GAAG,CAAC;SACZ;QACD,MAAM,IAAA,aAAK,EAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAhBD,gEAgBC;AAEM,KAAK,UAAU,YAAY,CAChC,GAAY,EACZ,IAAY,EACZ,MAAW,EACX,WAAgB,EAChB,KAAa;IAEb,MAAM,kBAAkB,GAAG,MAAM,GAAG,CAAC,qBAAqB,CACxD,2BAA2B,CAC5B,CAAC;IAEF,MAAM,GAAG,GAAG,MAAM,IAAA,uBAAS,EACzB,GAAG,EACH,2BAA2B,EAC3B,kBAAkB,EAClB;QACE,IAAI;QACJ,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;QAC7C,kBAAkB,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;QACrD,WAAW,EAAE,SAAS,KAAK,IAAI,MAAM,CAAC,QAAQ,EAAE,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE;KAC7E,CACF,CAAC;IACF,IAAA,iBAAG,GAAE,CAAC,KAAK,CACT,iBAAiB,MAAM,CAAC,QAAQ,EAAE,OAAO,WAAW,CAAC,QAAQ,EAAE,EAAE,CAClE,CAAC;IACF,MAAM,IAAA,kCAAoB,EACxB,GAAG,EACH,2BAA2B,EAC3B,GAAG,CAAC,IAAI,EACR,kBAAkB,CACnB,CAAC;IACF,IAAA,iBAAG,GAAE,CAAC,KAAK,CAAC,qBAAqB,GAAG,CAAC,IAAI,YAAY,CAAC,CAAC;AACzD,CAAC;AAhCD,oCAgCC"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@osaas/client-transcode",
3
+ "version": "0.2.0",
4
+ "description": "Open Source Cloud Client SDK transcode library",
5
+ "author": "Eyevinn Technology <work@eyevinn.se>",
6
+ "homepage": "https://www.osaas.io",
7
+ "license": "MIT",
8
+ "main": "lib/index.js",
9
+ "types": "lib/index.d.ts",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/Eyevinn/osaas-client-ts.git"
13
+ },
14
+ "directories": {
15
+ "lib": "lib"
16
+ },
17
+ "files": [
18
+ "lib"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.json",
22
+ "lint": "eslint .",
23
+ "pretty": "prettier --check --ignore-unknown .",
24
+ "typecheck": "tsc --noEmit -p tsconfig.json",
25
+ "test": "jest --passWithNoTests",
26
+ "build:doc": "npm run build && jsdoc -r -R ./README.md -d docs lib/"
27
+ },
28
+ "dependencies": {
29
+ "@osaas/client-core": "^0.5.0",
30
+ "chalk": "4.1.2"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "gitHead": "d6ac76ccd8ee1463c3484a67757271131b3ac5f2"
36
+ }