@osaas/client-transcode 0.2.0 → 0.4.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/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/packager.d.ts +4 -0
- package/lib/packager.d.ts.map +1 -0
- package/lib/packager.js +28 -0
- package/lib/packager.js.map +1 -0
- package/lib/pool.d.ts +20 -0
- package/lib/pool.d.ts.map +1 -1
- package/lib/pool.js +20 -0
- package/lib/pool.js.map +1 -1
- package/lib/vmaf.d.ts +22 -0
- package/lib/vmaf.d.ts.map +1 -0
- package/lib/vmaf.js +48 -0
- package/lib/vmaf.js.map +1 -0
- package/package.json +4 -5
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QueuePool = void 0;
|
|
3
|
+
exports.createStreamingPackage = exports.vmafCompare = exports.QueuePool = void 0;
|
|
4
4
|
var pool_1 = require("./pool");
|
|
5
5
|
Object.defineProperty(exports, "QueuePool", { enumerable: true, get: function () { return pool_1.QueuePool; } });
|
|
6
|
+
var vmaf_1 = require("./vmaf");
|
|
7
|
+
Object.defineProperty(exports, "vmafCompare", { enumerable: true, get: function () { return vmaf_1.vmafCompare; } });
|
|
8
|
+
var packager_1 = require("./packager");
|
|
9
|
+
Object.defineProperty(exports, "createStreamingPackage", { enumerable: true, get: function () { return packager_1.createStreamingPackage; } });
|
|
6
10
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AAA1B,iGAAA,SAAS,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AAA1B,iGAAA,SAAS,OAAA;AAClB,+BAAqC;AAA5B,mGAAA,WAAW,OAAA;AACpB,uCAAoD;AAA3C,kHAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packager.d.ts","sourceRoot":"","sources":["../src/packager.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,OAAO,EAIR,MAAM,oBAAoB,CAAC;AAE5B,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,GAAG,EACjB,MAAM,EAAE,MAAM,EAAE,EAChB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,GAAG,iBAoClB"}
|
package/lib/packager.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStreamingPackage = void 0;
|
|
4
|
+
const client_core_1 = require("@osaas/client-core");
|
|
5
|
+
async function createStreamingPackage(ctx, sourceBucket, videos, audio, resultBucket) {
|
|
6
|
+
const serviceAccessToken = await ctx.getServiceAccessToken('eyevinn-shaka-packager-s3');
|
|
7
|
+
if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
|
|
8
|
+
throw new Error('AWS credentials not set');
|
|
9
|
+
}
|
|
10
|
+
const jobId = Math.random().toString(36).substring(7);
|
|
11
|
+
let idx = 1;
|
|
12
|
+
let inputArgs = `-i a:${idx}=${audio}`;
|
|
13
|
+
videos.forEach((video) => {
|
|
14
|
+
inputArgs += ` -i v:${idx++}=${video}`;
|
|
15
|
+
});
|
|
16
|
+
const cmdLineArgs = `${sourceBucket.toString()} ${resultBucket.toString()} ${inputArgs}`;
|
|
17
|
+
const job = await (0, client_core_1.createJob)(ctx, 'eyevinn-shaka-packager-s3', serviceAccessToken, {
|
|
18
|
+
name: jobId,
|
|
19
|
+
awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
20
|
+
awsSecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
21
|
+
cmdLineArgs
|
|
22
|
+
});
|
|
23
|
+
(0, client_core_1.Log)().debug(`Creating streaming package for ${videos.length} video(s) and 1 audio file`);
|
|
24
|
+
await (0, client_core_1.waitForJobToComplete)(ctx, 'eyevinn-shaka-packager-s3', job.name, serviceAccessToken);
|
|
25
|
+
(0, client_core_1.Log)().debug(`Streaming package ${job.name} created`);
|
|
26
|
+
}
|
|
27
|
+
exports.createStreamingPackage = createStreamingPackage;
|
|
28
|
+
//# sourceMappingURL=packager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packager.js","sourceRoot":"","sources":["../src/packager.ts"],"names":[],"mappings":";;;AAAA,oDAK4B;AAErB,KAAK,UAAU,sBAAsB,CAC1C,GAAY,EACZ,YAAiB,EACjB,MAAgB,EAChB,KAAa,EACb,YAAiB;IAEjB,MAAM,kBAAkB,GAAG,MAAM,GAAG,CAAC,qBAAqB,CACxD,2BAA2B,CAC5B,CAAC;IACF,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE;QACxE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACtD,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,SAAS,GAAG,QAAQ,GAAG,IAAI,KAAK,EAAE,CAAC;IACvC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACvB,SAAS,IAAI,SAAS,GAAG,EAAE,IAAI,KAAK,EAAE,CAAC;IACzC,CAAC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,GAAG,YAAY,CAAC,QAAQ,EAAE,IAAI,YAAY,CAAC,QAAQ,EAAE,IAAI,SAAS,EAAE,CAAC;IACzF,MAAM,GAAG,GAAG,MAAM,IAAA,uBAAS,EACzB,GAAG,EACH,2BAA2B,EAC3B,kBAAkB,EAClB;QACE,IAAI,EAAE,KAAK;QACX,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;QAC7C,kBAAkB,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;QACrD,WAAW;KACZ,CACF,CAAC;IACF,IAAA,iBAAG,GAAE,CAAC,KAAK,CACT,kCAAkC,MAAM,CAAC,MAAM,4BAA4B,CAC5E,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,UAAU,CAAC,CAAC;AACvD,CAAC;AAzCD,wDAyCC"}
|
package/lib/pool.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export declare class QueuePool {
|
|
|
20
20
|
* @param {QueuePoolOptions} options - Queue Pool options
|
|
21
21
|
* @example
|
|
22
22
|
* import { Context } from '@osaas/client-core';
|
|
23
|
+
* import { QueuePool } from '@osaas/client-transcode';
|
|
23
24
|
* const ctx = new Context();
|
|
24
25
|
* // Create a new pool with 2 queues
|
|
25
26
|
* const pool = new QueuePool({ context: ctx, size: 2 });
|
|
@@ -43,6 +44,25 @@ export declare class QueuePool {
|
|
|
43
44
|
* await pool.destroy();
|
|
44
45
|
*/
|
|
45
46
|
destroy(): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* @typedef TranscodeOptions
|
|
49
|
+
* @type object
|
|
50
|
+
* @property {string?} profile - Transcoding profile to use (default: program)
|
|
51
|
+
* @property {number?} duration - Duration in seconds (default: entire file)
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* Transcodes a media file into an ABR bundle that is transferred to a destination
|
|
55
|
+
* @async
|
|
56
|
+
* @param {URL} source - Source URL of the media file (supported protocols: http, https)
|
|
57
|
+
* @param {URL} destination - Destination URL of the transcoded media files (supported protocols: s3)
|
|
58
|
+
* @param {TranscodeOptions} options - Transcode options
|
|
59
|
+
* @example
|
|
60
|
+
* const source = new URL('https://example.com/video.mp4');
|
|
61
|
+
* const destination = new URL('s3://mybucket/video/');
|
|
62
|
+
*
|
|
63
|
+
* // Transcode the first 10 seconds of the video
|
|
64
|
+
* await pool.transcode(source, destination, { duration: 10 });
|
|
65
|
+
*/
|
|
46
66
|
transcode(source: URL, destination: URL, { profile, duration }: {
|
|
47
67
|
profile?: string;
|
|
48
68
|
duration?: number;
|
package/lib/pool.d.ts.map
CHANGED
|
@@ -1 +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
|
|
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;;;;;;;;;;;OAWG;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;IASpB;;;;;OAKG;IAEH;;;;;;;;;;;;OAYG;IACU,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
CHANGED
|
@@ -27,6 +27,7 @@ class QueuePool {
|
|
|
27
27
|
* @param {QueuePoolOptions} options - Queue Pool options
|
|
28
28
|
* @example
|
|
29
29
|
* import { Context } from '@osaas/client-core';
|
|
30
|
+
* import { QueuePool } from '@osaas/client-transcode';
|
|
30
31
|
* const ctx = new Context();
|
|
31
32
|
* // Create a new pool with 2 queues
|
|
32
33
|
* const pool = new QueuePool({ context: ctx, size: 2 });
|
|
@@ -81,6 +82,25 @@ class QueuePool {
|
|
|
81
82
|
await (0, client_core_1.removeInstance)(this.context, 'encore', instance, this.token);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* @typedef TranscodeOptions
|
|
87
|
+
* @type object
|
|
88
|
+
* @property {string?} profile - Transcoding profile to use (default: program)
|
|
89
|
+
* @property {number?} duration - Duration in seconds (default: entire file)
|
|
90
|
+
*/
|
|
91
|
+
/**
|
|
92
|
+
* Transcodes a media file into an ABR bundle that is transferred to a destination
|
|
93
|
+
* @async
|
|
94
|
+
* @param {URL} source - Source URL of the media file (supported protocols: http, https)
|
|
95
|
+
* @param {URL} destination - Destination URL of the transcoded media files (supported protocols: s3)
|
|
96
|
+
* @param {TranscodeOptions} options - Transcode options
|
|
97
|
+
* @example
|
|
98
|
+
* const source = new URL('https://example.com/video.mp4');
|
|
99
|
+
* const destination = new URL('s3://mybucket/video/');
|
|
100
|
+
*
|
|
101
|
+
* // Transcode the first 10 seconds of the video
|
|
102
|
+
* await pool.transcode(source, destination, { duration: 10 });
|
|
103
|
+
*/
|
|
84
104
|
async transcode(source, destination, { profile, duration }) {
|
|
85
105
|
if (!this.token) {
|
|
86
106
|
throw new Error('Pool not initialized');
|
package/lib/pool.js.map
CHANGED
|
@@ -1 +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
|
|
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;;;;;;;;;;;OAWG;IACH,YAAY,EAAE,OAAO,EAAE,IAAI,EAAuC;QAChE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB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@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Context } from '@osaas/client-core';
|
|
3
|
+
/**
|
|
4
|
+
* Compare two video files using VMAF
|
|
5
|
+
*
|
|
6
|
+
* @param {Context} ctx - Open Source Cloud configuration context
|
|
7
|
+
* @param {URL} reference - URL to reference video file (supported protocols: s3)
|
|
8
|
+
* @param {URL} distorted - URL to distorted video file (supported protocols: s3)
|
|
9
|
+
* @param {URL} resultBucket - URL to S3 bucket where result file will be stored
|
|
10
|
+
* @returns S3 URL to result file
|
|
11
|
+
* @example
|
|
12
|
+
* import { Context } from '@osaas/client-core';
|
|
13
|
+
* import { vmafCompare } from '@osaas/client-transcode';
|
|
14
|
+
*
|
|
15
|
+
* const ctx = new Context();
|
|
16
|
+
* const reference = new URL('s3://video/reference.mp4');
|
|
17
|
+
* const distorted = new URL('s3://video/distorted.mp4');
|
|
18
|
+
* const resultBucket = new URL('s3://video/results');
|
|
19
|
+
* const resultFile = await vmafCompare(ctx, reference, distorted, resultBucket);
|
|
20
|
+
*/
|
|
21
|
+
export declare function vmafCompare(ctx: Context, reference: URL, distorted: URL, resultBucket: URL): Promise<URL>;
|
|
22
|
+
//# sourceMappingURL=vmaf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vmaf.d.ts","sourceRoot":"","sources":["../src/vmaf.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,OAAO,EAIR,MAAM,oBAAoB,CAAC;AAG5B;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,GAAG,EACd,YAAY,EAAE,GAAG,GAChB,OAAO,CAAC,GAAG,CAAC,CA6Bd"}
|
package/lib/vmaf.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
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.vmafCompare = void 0;
|
|
7
|
+
const client_core_1 = require("@osaas/client-core");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
/**
|
|
10
|
+
* Compare two video files using VMAF
|
|
11
|
+
*
|
|
12
|
+
* @param {Context} ctx - Open Source Cloud configuration context
|
|
13
|
+
* @param {URL} reference - URL to reference video file (supported protocols: s3)
|
|
14
|
+
* @param {URL} distorted - URL to distorted video file (supported protocols: s3)
|
|
15
|
+
* @param {URL} resultBucket - URL to S3 bucket where result file will be stored
|
|
16
|
+
* @returns S3 URL to result file
|
|
17
|
+
* @example
|
|
18
|
+
* import { Context } from '@osaas/client-core';
|
|
19
|
+
* import { vmafCompare } from '@osaas/client-transcode';
|
|
20
|
+
*
|
|
21
|
+
* const ctx = new Context();
|
|
22
|
+
* const reference = new URL('s3://video/reference.mp4');
|
|
23
|
+
* const distorted = new URL('s3://video/distorted.mp4');
|
|
24
|
+
* const resultBucket = new URL('s3://video/results');
|
|
25
|
+
* const resultFile = await vmafCompare(ctx, reference, distorted, resultBucket);
|
|
26
|
+
*/
|
|
27
|
+
async function vmafCompare(ctx, reference, distorted, resultBucket) {
|
|
28
|
+
const serviceAccessToken = await ctx.getServiceAccessToken('eyevinn-easyvmaf-s3');
|
|
29
|
+
const jobId = Math.random().toString(36).substring(7);
|
|
30
|
+
const resultFile = `${resultBucket
|
|
31
|
+
.toString()
|
|
32
|
+
.replace(/\/$/, '')}/${node_path_1.default.basename(distorted.pathname)}_${jobId}.json`;
|
|
33
|
+
if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
|
|
34
|
+
throw new Error('AWS credentials not set');
|
|
35
|
+
}
|
|
36
|
+
const job = await (0, client_core_1.createJob)(ctx, 'eyevinn-easyvmaf-s3', serviceAccessToken, {
|
|
37
|
+
name: jobId,
|
|
38
|
+
awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
39
|
+
awsSecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
40
|
+
cmdLineArgs: `-r ${reference.toString()} -d ${distorted.toString()} -o ${resultFile}`
|
|
41
|
+
});
|
|
42
|
+
(0, client_core_1.Log)().debug(`Comparing file ${reference.toString()} with ${reference.toString()}`);
|
|
43
|
+
await (0, client_core_1.waitForJobToComplete)(ctx, 'eyevinn-easyvmaf-s3', job.name, serviceAccessToken);
|
|
44
|
+
(0, client_core_1.Log)().debug(`VMAF comparison ${job.name} completed`);
|
|
45
|
+
return new URL(resultFile);
|
|
46
|
+
}
|
|
47
|
+
exports.vmafCompare = vmafCompare;
|
|
48
|
+
//# sourceMappingURL=vmaf.js.map
|
package/lib/vmaf.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vmaf.js","sourceRoot":"","sources":["../src/vmaf.ts"],"names":[],"mappings":";;;;;;AAAA,oDAK4B;AAC5B,0DAA6B;AAE7B;;;;;;;;;;;;;;;;;GAiBG;AACI,KAAK,UAAU,WAAW,CAC/B,GAAY,EACZ,SAAc,EACd,SAAc,EACd,YAAiB;IAEjB,MAAM,kBAAkB,GAAG,MAAM,GAAG,CAAC,qBAAqB,CACxD,qBAAqB,CACtB,CAAC;IACF,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,UAAU,GAAG,GAAG,YAAY;SAC/B,QAAQ,EAAE;SACV,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,mBAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC;IAE3E,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE;QACxE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;IACD,MAAM,GAAG,GAAG,MAAM,IAAA,uBAAS,EAAC,GAAG,EAAE,qBAAqB,EAAE,kBAAkB,EAAE;QAC1E,IAAI,EAAE,KAAK;QACX,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;QAC7C,kBAAkB,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;QACrD,WAAW,EAAE,MAAM,SAAS,CAAC,QAAQ,EAAE,OAAO,SAAS,CAAC,QAAQ,EAAE,OAAO,UAAU,EAAE;KACtF,CAAC,CAAC;IACH,IAAA,iBAAG,GAAE,CAAC,KAAK,CACT,kBAAkB,SAAS,CAAC,QAAQ,EAAE,SAAS,SAAS,CAAC,QAAQ,EAAE,EAAE,CACtE,CAAC;IACF,MAAM,IAAA,kCAAoB,EACxB,GAAG,EACH,qBAAqB,EACrB,GAAG,CAAC,IAAI,EACR,kBAAkB,CACnB,CAAC;IACF,IAAA,iBAAG,GAAE,CAAC,KAAK,CAAC,mBAAmB,GAAG,CAAC,IAAI,YAAY,CAAC,CAAC;IACrD,OAAO,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC;AAlCD,kCAkCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osaas/client-transcode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Open Source Cloud Client SDK transcode library",
|
|
5
5
|
"author": "Eyevinn Technology <work@eyevinn.se>",
|
|
6
6
|
"homepage": "https://www.osaas.io",
|
|
@@ -22,15 +22,14 @@
|
|
|
22
22
|
"lint": "eslint .",
|
|
23
23
|
"pretty": "prettier --check --ignore-unknown .",
|
|
24
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/"
|
|
25
|
+
"test": "jest --passWithNoTests"
|
|
27
26
|
},
|
|
28
27
|
"dependencies": {
|
|
29
|
-
"@osaas/client-core": "^0.5.
|
|
28
|
+
"@osaas/client-core": "^0.5.1",
|
|
30
29
|
"chalk": "4.1.2"
|
|
31
30
|
},
|
|
32
31
|
"publishConfig": {
|
|
33
32
|
"access": "public"
|
|
34
33
|
},
|
|
35
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "1cd9bcf9e53033687345cbffa58d61853ade3a1f"
|
|
36
35
|
}
|